alki 0.1.0 → 0.2.0
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 +4 -4
- data/lib/alki/overlay_delegator.rb +1 -1
- data/lib/alki/version.rb +1 -1
- data/test/fixtures/example/config/handlers.rb +6 -5
- data/test/fixtures/example/lib/log_overlay.rb +10 -0
- metadata +4 -6
- data/test/unit/application_settings_test.rb +0 -56
- data/test/unit/application_test.rb +0 -159
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: bab3b631c216a5a4ca029904251c38faec707269
         | 
| 4 | 
            +
              data.tar.gz: 3e495653eb662df01c8e5b3e0e65a0a07bc88d34
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 50dec6b5e5a8dfa767d1b21e05041a95033f8a2e5e76282d6f4a1306b9d7169364d83a252d9e83a96012047ac1ff31d9d02ca6e21a4a2b27077bf42340d5d7e2
         | 
| 7 | 
            +
              data.tar.gz: e8b4b00970c0baea4f6486dbcc2d9e34f810dc38ec48288ac856851433b5727670e3174e47bdabf60770de2fae96d95b9acc1f0ac521f67e45812fc41fa0f8d1
         | 
    
        data/lib/alki/version.rb
    CHANGED
    
    
| @@ -5,25 +5,26 @@ Alki do | |
| 5 5 | 
             
                  NumHandler.new num, str, output
         | 
| 6 6 | 
             
                }
         | 
| 7 7 | 
             
              end
         | 
| 8 | 
            +
             | 
| 8 9 | 
             
              service :fizz do
         | 
| 9 10 | 
             
                num_handler 3, settings.fizz
         | 
| 10 11 | 
             
              end
         | 
| 12 | 
            +
             | 
| 11 13 | 
             
              service :buzz do
         | 
| 12 14 | 
             
                num_handler 5, settings.buzz
         | 
| 13 15 | 
             
              end
         | 
| 16 | 
            +
             | 
| 14 17 | 
             
              service :fizzbuzz do
         | 
| 15 18 | 
             
                num_handler 15, settings.fizzbuzz
         | 
| 16 19 | 
             
              end
         | 
| 20 | 
            +
             | 
| 17 21 | 
             
              service :echo do
         | 
| 18 22 | 
             
                require 'echo_handler'
         | 
| 19 23 | 
             
                EchoHandler.new output
         | 
| 20 24 | 
             
              end
         | 
| 21 25 |  | 
| 22 26 | 
             
              overlay do
         | 
| 23 | 
            -
                 | 
| 24 | 
            -
                 | 
| 25 | 
            -
                  log_obj << "Calling #{name}##{method} #{args.join(", ")}\n"
         | 
| 26 | 
            -
                  obj.public_send method, *args, &blk
         | 
| 27 | 
            -
                }
         | 
| 27 | 
            +
                require 'log_overlay'
         | 
| 28 | 
            +
                LogOverlay.new log
         | 
| 28 29 | 
             
              end
         | 
| 29 30 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: alki
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Matt Edlefsen
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2016-10- | 
| 11 | 
            +
            date: 2016-10-04 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -76,14 +76,13 @@ files: | |
| 76 76 | 
             
            - test/fixtures/example/lib/array_output.rb
         | 
| 77 77 | 
             
            - test/fixtures/example/lib/echo_handler.rb
         | 
| 78 78 | 
             
            - test/fixtures/example/lib/example.rb
         | 
| 79 | 
            +
            - test/fixtures/example/lib/log_overlay.rb
         | 
| 79 80 | 
             
            - test/fixtures/example/lib/num_handler.rb
         | 
| 80 81 | 
             
            - test/fixtures/example/lib/range_handler.rb
         | 
| 81 82 | 
             
            - test/fixtures/example/lib/switch_handler.rb
         | 
| 82 83 | 
             
            - test/integration/class_builder_test.rb
         | 
| 83 84 | 
             
            - test/integration/loader_test.rb
         | 
| 84 85 | 
             
            - test/test_helper.rb
         | 
| 85 | 
            -
            - test/unit/application_settings_test.rb
         | 
| 86 | 
            -
            - test/unit/application_test.rb
         | 
| 87 86 | 
             
            - test/unit/package_processor_test.rb
         | 
| 88 87 | 
             
            homepage: https://gitlab.xforty.com/matt/base-alki
         | 
| 89 88 | 
             
            licenses:
         | 
| @@ -118,12 +117,11 @@ test_files: | |
| 118 117 | 
             
            - test/fixtures/example/lib/array_output.rb
         | 
| 119 118 | 
             
            - test/fixtures/example/lib/echo_handler.rb
         | 
| 120 119 | 
             
            - test/fixtures/example/lib/example.rb
         | 
| 120 | 
            +
            - test/fixtures/example/lib/log_overlay.rb
         | 
| 121 121 | 
             
            - test/fixtures/example/lib/num_handler.rb
         | 
| 122 122 | 
             
            - test/fixtures/example/lib/range_handler.rb
         | 
| 123 123 | 
             
            - test/fixtures/example/lib/switch_handler.rb
         | 
| 124 124 | 
             
            - test/integration/class_builder_test.rb
         | 
| 125 125 | 
             
            - test/integration/loader_test.rb
         | 
| 126 126 | 
             
            - test/test_helper.rb
         | 
| 127 | 
            -
            - test/unit/application_settings_test.rb
         | 
| 128 | 
            -
            - test/unit/application_test.rb
         | 
| 129 127 | 
             
            - test/unit/package_processor_test.rb
         | 
| @@ -1,56 +0,0 @@ | |
| 1 | 
            -
            require_relative '../test_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'alki/application_settings'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            describe Alki::ApplicationSettings do
         | 
| 6 | 
            -
              before do
         | 
| 7 | 
            -
                @settings = Alki::ApplicationSettings.new
         | 
| 8 | 
            -
              end
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              describe :initialize do
         | 
| 11 | 
            -
                it 'should set environment to development by default' do
         | 
| 12 | 
            -
                  @settings.environment.must_equal :development
         | 
| 13 | 
            -
                end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              describe :set do
         | 
| 17 | 
            -
                it 'should add setting as method and make it available as an index' do
         | 
| 18 | 
            -
                  @settings.respond_to?(:test).must_equal false
         | 
| 19 | 
            -
                  @settings.set :test, :test_value
         | 
| 20 | 
            -
                  @settings.test.must_equal :test_value
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                it 'should make setting available as an index' do
         | 
| 24 | 
            -
                  @settings[:test].must_equal nil
         | 
| 25 | 
            -
                  @settings.set :test, :test_value
         | 
| 26 | 
            -
                  @settings[:test].must_equal :test_value
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
              describe :environment? do
         | 
| 31 | 
            -
                it 'should return whether environment is one of the arguments' do
         | 
| 32 | 
            -
                  @settings.environment?(:development).must_equal true
         | 
| 33 | 
            -
                  @settings.environment?(:production,:development).must_equal true
         | 
| 34 | 
            -
                  @settings.environment?(:production,:test).must_equal false
         | 
| 35 | 
            -
                end
         | 
| 36 | 
            -
             | 
| 37 | 
            -
                it 'should run provided block if true' do
         | 
| 38 | 
            -
                  test = false
         | 
| 39 | 
            -
                  @settings.environment?(:test) { test = true }
         | 
| 40 | 
            -
                  test.must_equal false
         | 
| 41 | 
            -
                  @settings.environment?(:development) { test = true }
         | 
| 42 | 
            -
                  test.must_equal true
         | 
| 43 | 
            -
                end
         | 
| 44 | 
            -
              end
         | 
| 45 | 
            -
             | 
| 46 | 
            -
              describe :configure do
         | 
| 47 | 
            -
                it 'should run provided block in object context' do
         | 
| 48 | 
            -
                  @settings.respond_to?(:test).must_equal false
         | 
| 49 | 
            -
                  @settings.configure do
         | 
| 50 | 
            -
                    set :test, :test_value
         | 
| 51 | 
            -
                    test.must_equal :test_value
         | 
| 52 | 
            -
                  end
         | 
| 53 | 
            -
                  @settings.test.must_equal :test_value
         | 
| 54 | 
            -
                end
         | 
| 55 | 
            -
              end
         | 
| 56 | 
            -
            end
         | 
| @@ -1,159 +0,0 @@ | |
| 1 | 
            -
            require_relative '../test_helper'
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            require 'alki/application'
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            describe Alki::Application do
         | 
| 6 | 
            -
              before do
         | 
| 7 | 
            -
                @settings = {test: 1}
         | 
| 8 | 
            -
                @app = Alki::Application.new @settings
         | 
| 9 | 
            -
              end
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              describe :settings do
         | 
| 12 | 
            -
                it 'should return settings passed into new' do
         | 
| 13 | 
            -
                  @app.settings.must_be_same_as @settings
         | 
| 14 | 
            -
                end
         | 
| 15 | 
            -
              end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
              describe :configure do
         | 
| 18 | 
            -
                it 'should allow calling methods as a DSL' do
         | 
| 19 | 
            -
                  @app.configure do
         | 
| 20 | 
            -
                    service :test_m do
         | 
| 21 | 
            -
                      :test
         | 
| 22 | 
            -
                    end
         | 
| 23 | 
            -
                  end
         | 
| 24 | 
            -
                  @app.test_m.must_equal :test
         | 
| 25 | 
            -
                end
         | 
| 26 | 
            -
              end
         | 
| 27 | 
            -
             | 
| 28 | 
            -
              describe :root do
         | 
| 29 | 
            -
                it 'should allow extracting the root group from the application' do
         | 
| 30 | 
            -
                  @app.service(:test_m) { :test }
         | 
| 31 | 
            -
                  @app.root.test_m.must_equal :test
         | 
| 32 | 
            -
                end
         | 
| 33 | 
            -
              end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
              describe :service do
         | 
| 36 | 
            -
                it 'should create method that gets result of block' do
         | 
| 37 | 
            -
                  @app.service(:test_m) { :test }
         | 
| 38 | 
            -
                  @app.respond_to?(:test_m).must_equal true
         | 
| 39 | 
            -
                  @app.test_m.must_equal :test
         | 
| 40 | 
            -
                end
         | 
| 41 | 
            -
             | 
| 42 | 
            -
                it 'generated method should run on demand' do
         | 
| 43 | 
            -
                  count = 0
         | 
| 44 | 
            -
                  @app.service(:test_m){ count += 1; :test }
         | 
| 45 | 
            -
                  count.must_equal 0
         | 
| 46 | 
            -
                  @app.test_m
         | 
| 47 | 
            -
                  count.must_equal 1
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                it 'generated method should run only once' do
         | 
| 51 | 
            -
                  count = 0
         | 
| 52 | 
            -
                  @app.service(:test_m){ count += 1; :test }
         | 
| 53 | 
            -
                  @app.test_m
         | 
| 54 | 
            -
                  @app.test_m
         | 
| 55 | 
            -
                  count.must_equal 1
         | 
| 56 | 
            -
                end
         | 
| 57 | 
            -
              end
         | 
| 58 | 
            -
             | 
| 59 | 
            -
              describe :group do
         | 
| 60 | 
            -
                it 'should create group with block' do
         | 
| 61 | 
            -
                  @app.configure do
         | 
| 62 | 
            -
                    group :g1 do
         | 
| 63 | 
            -
                    end
         | 
| 64 | 
            -
                  end
         | 
| 65 | 
            -
                  @app.g1.wont_be_nil
         | 
| 66 | 
            -
                end
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                it 'should add services to group' do
         | 
| 69 | 
            -
                  @app.configure do
         | 
| 70 | 
            -
                    group :g1 do
         | 
| 71 | 
            -
                      service(:testm1) { :test1 }
         | 
| 72 | 
            -
                    end
         | 
| 73 | 
            -
                    group :g1 do
         | 
| 74 | 
            -
                      service(:testm2) { :test2 }
         | 
| 75 | 
            -
                    end
         | 
| 76 | 
            -
                  end
         | 
| 77 | 
            -
                  @app.g1.testm1.must_equal :test1
         | 
| 78 | 
            -
                  @app.g1.testm2.must_equal :test2
         | 
| 79 | 
            -
                end
         | 
| 80 | 
            -
             | 
| 81 | 
            -
                it 'should allow creation of subgroups' do
         | 
| 82 | 
            -
                  @app.configure do
         | 
| 83 | 
            -
                    group :g1 do
         | 
| 84 | 
            -
                      group :g2 do
         | 
| 85 | 
            -
                        service(:test_m) { :test }
         | 
| 86 | 
            -
                      end
         | 
| 87 | 
            -
                    end
         | 
| 88 | 
            -
                  end
         | 
| 89 | 
            -
                  @app.g1.g2.test_m.must_equal :test
         | 
| 90 | 
            -
                end
         | 
| 91 | 
            -
             | 
| 92 | 
            -
                it 'should allow calling services of parent groups' do
         | 
| 93 | 
            -
                  @app.configure do
         | 
| 94 | 
            -
                    service(:test1) { :test1 }
         | 
| 95 | 
            -
                    group :g1 do
         | 
| 96 | 
            -
                      service(:test2) { :test2 }
         | 
| 97 | 
            -
                      group :g2 do
         | 
| 98 | 
            -
                        service(:test3) { [test1,test2] }
         | 
| 99 | 
            -
                      end
         | 
| 100 | 
            -
                    end
         | 
| 101 | 
            -
                  end
         | 
| 102 | 
            -
                  @app.g1.g2.test3.must_equal [:test1,:test2]
         | 
| 103 | 
            -
                end
         | 
| 104 | 
            -
             | 
| 105 | 
            -
                it 'should allow aliasing groups' do
         | 
| 106 | 
            -
                  @app.configure do
         | 
| 107 | 
            -
                    group :g1 do
         | 
| 108 | 
            -
                      service(:test_m) { :test }
         | 
| 109 | 
            -
                    end
         | 
| 110 | 
            -
                  end
         | 
| 111 | 
            -
                  @app.group(:g2,@app.g1)
         | 
| 112 | 
            -
                  @app[:g2].test_m.must_equal :test
         | 
| 113 | 
            -
                end
         | 
| 114 | 
            -
             | 
| 115 | 
            -
                it 'should allow moving groups to other applications' do
         | 
| 116 | 
            -
                  app2 = Alki::Application.new
         | 
| 117 | 
            -
                  app2.service(:test_m) { :test }
         | 
| 118 | 
            -
                  @app.group(:other,app2.root)
         | 
| 119 | 
            -
                  @app.other.test_m.must_equal :test
         | 
| 120 | 
            -
                end
         | 
| 121 | 
            -
             | 
| 122 | 
            -
                it 'should raise ArgumentError if non-group is provided' do
         | 
| 123 | 
            -
                  assert_raises ArgumentError do
         | 
| 124 | 
            -
                    @app.group(:test, {})
         | 
| 125 | 
            -
                  end
         | 
| 126 | 
            -
                end
         | 
| 127 | 
            -
              end
         | 
| 128 | 
            -
             | 
| 129 | 
            -
              describe :lookup do
         | 
| 130 | 
            -
                it 'should allow lookups of services by string' do
         | 
| 131 | 
            -
                  @app.service(:test_m) { :test }
         | 
| 132 | 
            -
                  @app.lookup('test_m').must_equal :test
         | 
| 133 | 
            -
                end
         | 
| 134 | 
            -
             | 
| 135 | 
            -
                it 'should allow looking up services in groups using dot separators' do
         | 
| 136 | 
            -
                  @app.configure do
         | 
| 137 | 
            -
                    group :g1 do
         | 
| 138 | 
            -
                      service(:test_m) { :test1 }
         | 
| 139 | 
            -
                      group :g2 do
         | 
| 140 | 
            -
                        service(:test_m) { :test2 }
         | 
| 141 | 
            -
                      end
         | 
| 142 | 
            -
                    end
         | 
| 143 | 
            -
                  end
         | 
| 144 | 
            -
                  @app.lookup('g1.test_m').must_equal :test1
         | 
| 145 | 
            -
                  @app.lookup('g1.g2.test_m').must_equal :test2
         | 
| 146 | 
            -
                end
         | 
| 147 | 
            -
              end
         | 
| 148 | 
            -
             | 
| 149 | 
            -
              describe :delegate do
         | 
| 150 | 
            -
                it 'should allow service reference cycles' do
         | 
| 151 | 
            -
                  @app.configure do
         | 
| 152 | 
            -
                    service(:all) { {print_all: delegate(:print_all)} }
         | 
| 153 | 
            -
                    service(:print_all) { list = all.keys; ->{ p list } }
         | 
| 154 | 
            -
                  end
         | 
| 155 | 
            -
             | 
| 156 | 
            -
                  @app.print_all.call.must_equal [:print_all]
         | 
| 157 | 
            -
                end
         | 
| 158 | 
            -
              end
         | 
| 159 | 
            -
            end
         |