expo 0.2.4 → 0.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/expo.rb +46 -22
- metadata +4 -6
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            !binary "U0hBMQ==":
         | 
| 3 | 
            +
              metadata.gz: !binary |-
         | 
| 4 | 
            +
                ZWEwMDY2NzQyNTJkYTE5OGE3NzU3OWJmYjM0YmM1YmQ4OGFjZDgwZA==
         | 
| 5 | 
            +
              data.tar.gz: !binary |-
         | 
| 6 | 
            +
                YWQ1ZWEyNGMyNGRkNWJiZmViMjc3ZmNmM2JjZDcxOGEyZTM5ZmRiYw==
         | 
| 7 | 
            +
            !binary "U0hBNTEy":
         | 
| 8 | 
            +
              metadata.gz: !binary |-
         | 
| 9 | 
            +
                MDMwM2ZmMWM3N2U0OTExNzYwNTgzZjBmZmIzZGI1NGEyMGQ1MWNjYWM3NjUw
         | 
| 10 | 
            +
                NmU5MjQzOGZhNmYzMDA2ZTA1YmM4MTBkMGNkNThjNTc5YTI0MGQ3ZWRmMzE3
         | 
| 11 | 
            +
                YjBhYjI3NzM1ODE2ZjFkMzlmNDgzYzdhNDBkYzQ2ZTc1ODZlNTE=
         | 
| 12 | 
            +
              data.tar.gz: !binary |-
         | 
| 13 | 
            +
                OTE2YjU3YmQxNGJhNDA1YjgwNTRjNGY1Y2YyZmFmMTNjYTgyYWFkZDA1Mjc2
         | 
| 14 | 
            +
                ZDAzMDY4YzU1Y2FiOGU2NjQ2NjZjYWNkMjlmY2Y3M2JmZmJkZmYzZTU4NzMx
         | 
| 15 | 
            +
                NDc3YTM0NmU1ZDhlMjYzZWRiZmQ5ZTIzYzllYWE1NGQ5NWVmZWQ=
         | 
    
        data/lib/expo.rb
    CHANGED
    
    | @@ -1,7 +1,5 @@ | |
| 1 1 | 
             
            class Expo
         | 
| 2 2 | 
             
              CALL_ORDER = [:aside, :expose, :sub_expo, :collection]
         | 
| 3 | 
            -
              CALL_IMMEDIATELY = [:aside, :expose]
         | 
| 4 | 
            -
              CALL_LATER = [:sub_expo, :collection]
         | 
| 5 3 | 
             
              TRIVIAL_PRESENTER = Class.new do
         | 
| 6 4 | 
             
                def present(object)
         | 
| 7 5 | 
             
                  object
         | 
| @@ -15,6 +13,7 @@ class Expo | |
| 15 13 | 
             
                @subs = {}
         | 
| 16 14 | 
             
                @collections = {}
         | 
| 17 15 | 
             
                @inner_calls = []
         | 
| 16 | 
            +
                @id = self.object_id
         | 
| 18 17 | 
             
              end
         | 
| 19 18 |  | 
| 20 19 | 
             
              def expo_collection(objects, context={})
         | 
| @@ -23,7 +22,15 @@ class Expo | |
| 23 22 | 
             
                end
         | 
| 24 23 | 
             
              end
         | 
| 25 24 |  | 
| 25 | 
            +
              def reset
         | 
| 26 | 
            +
                @message_map = {}
         | 
| 27 | 
            +
                @subs = {}
         | 
| 28 | 
            +
                @collections = {}
         | 
| 29 | 
            +
                @inner_calls = []
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
             | 
| 26 32 | 
             
              def expo(object, context={})
         | 
| 33 | 
            +
             | 
| 27 34 | 
             
                @object = object
         | 
| 28 35 | 
             
                @context = context
         | 
| 29 36 | 
             
                if object.nil?
         | 
| @@ -37,16 +44,16 @@ class Expo | |
| 37 44 | 
             
                  return {}
         | 
| 38 45 | 
             
                end
         | 
| 39 46 | 
             
                block_return = self.instance_exec @object, context, &@block
         | 
| 40 | 
            -
                @inner_calls. | 
| 47 | 
            +
                @inner_calls.each do |call|
         | 
| 41 48 | 
             
                  self.send(call[:method], *call[:args], &call[:block])
         | 
| 42 49 | 
             
                end
         | 
| 43 50 | 
             
                exposition = {}
         | 
| 44 51 | 
             
                @message_map.each do |k,v|
         | 
| 45 | 
            -
                  # puts "sending #{k}"
         | 
| 46 52 | 
             
                  exposition[v] = @preso.send(k)
         | 
| 47 53 | 
             
                end
         | 
| 48 54 | 
             
                exposition.merge!(@subs)
         | 
| 49 55 | 
             
                exposition.merge!(@collections)
         | 
| 56 | 
            +
                self.reset
         | 
| 50 57 | 
             
                if block_return
         | 
| 51 58 | 
             
                  exposition.merge(block_return)
         | 
| 52 59 | 
             
                else
         | 
| @@ -56,25 +63,38 @@ class Expo | |
| 56 63 |  | 
| 57 64 | 
             
              private
         | 
| 58 65 |  | 
| 59 | 
            -
              def  | 
| 60 | 
            -
                 | 
| 61 | 
            -
                   | 
| 62 | 
            -
             | 
| 63 | 
            -
             | 
| 64 | 
            -
             | 
| 65 | 
            -
             | 
| 66 | 
            -
             | 
| 67 | 
            -
                    block: block
         | 
| 68 | 
            -
                  }
         | 
| 69 | 
            -
                end
         | 
| 66 | 
            +
              def sub_expo(object, sub_expo_passed, key)
         | 
| 67 | 
            +
                @inner_calls << {
         | 
| 68 | 
            +
                  method: :sub_expo_inner,
         | 
| 69 | 
            +
                  args: [object, sub_expo_passed, key],
         | 
| 70 | 
            +
                  block: nil
         | 
| 71 | 
            +
                }
         | 
| 72 | 
            +
                nil
         | 
| 73 | 
            +
              end
         | 
| 70 74 |  | 
| 75 | 
            +
              def collection(key, collection, item_expo)
         | 
| 76 | 
            +
                @inner_calls << {
         | 
| 77 | 
            +
                  method: :collection_inner,
         | 
| 78 | 
            +
                  args: [key, collection, item_expo],
         | 
| 79 | 
            +
                  block: nil
         | 
| 80 | 
            +
                }
         | 
| 71 81 | 
             
                nil
         | 
| 72 82 | 
             
              end
         | 
| 73 83 |  | 
| 84 | 
            +
              def set_id(id)
         | 
| 85 | 
            +
                @id = id
         | 
| 86 | 
            +
                self
         | 
| 87 | 
            +
              end
         | 
| 88 | 
            +
             | 
| 89 | 
            +
              def get_id
         | 
| 90 | 
            +
                @id
         | 
| 91 | 
            +
              end
         | 
| 92 | 
            +
             | 
| 74 93 | 
             
              def sub_expo_inner(object, sub_expo_passed, key)
         | 
| 75 94 | 
             
                recurse_expo = sub_expo_passed
         | 
| 76 | 
            -
                 | 
| 77 | 
            -
             | 
| 95 | 
            +
                sub_id = sub_expo_passed.send(:get_id)
         | 
| 96 | 
            +
                if sub_id == @id
         | 
| 97 | 
            +
                  recurse_expo = Expo.new(@presenter, &@block).send(:set_id, @id)
         | 
| 78 98 | 
             
                end
         | 
| 79 99 | 
             
                sub = recurse_expo.expo(object, @context)
         | 
| 80 100 | 
             
                @subs[key] = sub if sub
         | 
| @@ -83,8 +103,13 @@ class Expo | |
| 83 103 |  | 
| 84 104 | 
             
              def collection_inner(key, collection, item_expo)
         | 
| 85 105 | 
             
                recurse_expo = item_expo
         | 
| 86 | 
            -
                 | 
| 87 | 
            -
             | 
| 106 | 
            +
                sub_id = item_expo.send(:get_id)
         | 
| 107 | 
            +
                if sub_id == @id
         | 
| 108 | 
            +
                  recurse_expo = Expo.new(@presenter, &@block).send(:set_id, @id)
         | 
| 109 | 
            +
                end
         | 
| 110 | 
            +
                if !collection
         | 
| 111 | 
            +
                  @collections[key] = nil
         | 
| 112 | 
            +
                  return nil
         | 
| 88 113 | 
             
                end
         | 
| 89 114 | 
             
                collection_exposition = []
         | 
| 90 115 | 
             
                collection.each.with_index do |item, index|
         | 
| @@ -96,7 +121,7 @@ class Expo | |
| 96 121 | 
             
                nil
         | 
| 97 122 | 
             
              end
         | 
| 98 123 |  | 
| 99 | 
            -
              def  | 
| 124 | 
            +
              def aside(*messages)
         | 
| 100 125 | 
             
                receiver = @preso
         | 
| 101 126 | 
             
                last = messages.pop
         | 
| 102 127 | 
             
                if last.is_a?(Hash)
         | 
| @@ -112,7 +137,7 @@ class Expo | |
| 112 137 | 
             
                nil
         | 
| 113 138 | 
             
              end
         | 
| 114 139 |  | 
| 115 | 
            -
              def  | 
| 140 | 
            +
              def expose(*messages)
         | 
| 116 141 | 
             
                last = messages.pop
         | 
| 117 142 | 
             
                if last.is_a?(Hash)
         | 
| 118 143 | 
             
                  @message_map.merge!(last)
         | 
| @@ -135,7 +160,6 @@ class Expo | |
| 135 160 | 
             
                end
         | 
| 136 161 |  | 
| 137 162 | 
             
                def method_missing(method, *args, &block)
         | 
| 138 | 
            -
                  # puts "missing #{method}"
         | 
| 139 163 | 
             
                  @objects.detect{|obj| obj.respond_to? method}.send(
         | 
| 140 164 | 
             
                    method, *args, &block
         | 
| 141 165 | 
             
                  )
         | 
    
        metadata
    CHANGED
    
    | @@ -1,8 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: expo
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.2. | 
| 5 | 
            -
              prerelease: 
         | 
| 4 | 
            +
              version: 0.2.5
         | 
| 6 5 | 
             
            platform: ruby
         | 
| 7 6 | 
             
            authors:
         | 
| 8 7 | 
             
            - Serguei Filimonov
         | 
| @@ -20,26 +19,25 @@ files: | |
| 20 19 | 
             
            - lib/expo.rb
         | 
| 21 20 | 
             
            homepage: https://github.com/sergueif/expo
         | 
| 22 21 | 
             
            licenses: []
         | 
| 22 | 
            +
            metadata: {}
         | 
| 23 23 | 
             
            post_install_message: 
         | 
| 24 24 | 
             
            rdoc_options: []
         | 
| 25 25 | 
             
            require_paths:
         | 
| 26 26 | 
             
            - lib
         | 
| 27 27 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 28 | 
            -
              none: false
         | 
| 29 28 | 
             
              requirements:
         | 
| 30 29 | 
             
              - - ! '>='
         | 
| 31 30 | 
             
                - !ruby/object:Gem::Version
         | 
| 32 31 | 
             
                  version: '0'
         | 
| 33 32 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 34 | 
            -
              none: false
         | 
| 35 33 | 
             
              requirements:
         | 
| 36 34 | 
             
              - - ! '>='
         | 
| 37 35 | 
             
                - !ruby/object:Gem::Version
         | 
| 38 36 | 
             
                  version: '0'
         | 
| 39 37 | 
             
            requirements: []
         | 
| 40 38 | 
             
            rubyforge_project: 
         | 
| 41 | 
            -
            rubygems_version:  | 
| 39 | 
            +
            rubygems_version: 2.0.3
         | 
| 42 40 | 
             
            signing_key: 
         | 
| 43 | 
            -
            specification_version:  | 
| 41 | 
            +
            specification_version: 4
         | 
| 44 42 | 
             
            summary: Expo of object presentations
         | 
| 45 43 | 
             
            test_files: []
         |