egi 0.0.2 → 0.0.3
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.
- data/.travis.yml +5 -0
 - data/CHANGELOG.md +5 -0
 - data/README.md +34 -7
 - data/Rakefile +8 -0
 - data/VERSION +1 -1
 - data/egi.gemspec +3 -2
 - data/lib/egi/env.rb +8 -3
 - data/lib/egi/group.rb +12 -2
 - data/lib/egi/sandbox.rb +18 -11
 - data/lib/egi.rb +18 -1
 - data/spec/egi_spec.rb +92 -85
 - metadata +18 -6
 
    
        data/CHANGELOG.md
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,4 +1,6 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            # egi
         
     | 
| 
      
 1 
     | 
    
         
            +
            # egi [](http://travis-ci.org/okitan/egi)
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            tested in ruby 1.8.7, 1.9.2, 1.9.3, and head
         
     | 
| 
       2 
4 
     | 
    
         | 
| 
       3 
5 
     | 
    
         
             
            ## About egi
         
     | 
| 
       4 
6 
     | 
    
         
             
            environment, group, and item
         
     | 
| 
         @@ -7,6 +9,9 @@ environment, group, and item 
     | 
|
| 
       7 
9 
     | 
    
         | 
| 
       8 
10 
     | 
    
         
             
                % cat egi.conf
         
     | 
| 
       9 
11 
     | 
    
         
             
                env(:development) {
         
     | 
| 
      
 12 
     | 
    
         
            +
                  item :vhost0301, { :tags => [ :mysqld, :rails ] }
         
     | 
| 
      
 13 
     | 
    
         
            +
                }
         
     | 
| 
      
 14 
     | 
    
         
            +
                env(:production) {
         
     | 
| 
       10 
15 
     | 
    
         
             
                  group(:mysqld) {
         
     | 
| 
       11 
16 
     | 
    
         
             
                    item :vhost0421, { :tags => [ :master ] }
         
     | 
| 
       12 
17 
     | 
    
         
             
                    item :vhost0422
         
     | 
| 
         @@ -15,7 +20,7 @@ environment, group, and item 
     | 
|
| 
       15 
20 
     | 
    
         
             
                  # you can define item without group
         
     | 
| 
       16 
21 
     | 
    
         
             
                  item :vhost0423, { :tags => [ :rails ] }
         
     | 
| 
       17 
22 
     | 
    
         
             
                }
         
     | 
| 
       18 
     | 
    
         
            -
                % EGI_ENV= 
     | 
| 
      
 23 
     | 
    
         
            +
                % EGI_ENV=production irb
         
     | 
| 
       19 
24 
     | 
    
         
             
                > require 'egi'
         
     | 
| 
       20 
25 
     | 
    
         
             
                > # find by group or tag
         
     | 
| 
       21 
26 
     | 
    
         
             
                > Egi.env.mysqld #=> [ { :name => :vhost0421, :tags => [ :mysqld, :master ] },
         
     | 
| 
         @@ -24,19 +29,41 @@ environment, group, and item 
     | 
|
| 
       24 
29 
     | 
    
         
             
                > Egi.env.master #=> [ { :name => :vhost0421, :tags => [ :mysqld, :master ] } ]
         
     | 
| 
       25 
30 
     | 
    
         
             
                > # fetch by name
         
     | 
| 
       26 
31 
     | 
    
         
             
                > Egi.env.vhost0423 #=> { :name => :vhost0423, :tags => [ :rails ]}, 
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
      
 32 
     | 
    
         
            +
                % EGI_ENV=development irb
         
     | 
| 
      
 33 
     | 
    
         
            +
                > require 'egi'
         
     | 
| 
      
 34 
     | 
    
         
            +
                > Egi.env.mysqld #=> [ { :name => :vhost0301, :tags => [ :mysqld, :rails ] } ]
         
     | 
| 
      
 35 
     | 
    
         
            +
                # can not fetch other envs
         
     | 
| 
      
 36 
     | 
    
         
            +
                > Egi.env.vhost0421 #=> nil
         
     | 
| 
       28 
37 
     | 
    
         | 
| 
       29 
38 
     | 
    
         
             
            ## Syntax
         
     | 
| 
       30 
39 
     | 
    
         | 
| 
       31 
40 
     | 
    
         
             
            ### env
         
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
      
 41 
     | 
    
         
            +
                env(name, &block)
         
     | 
| 
      
 42 
     | 
    
         
            +
            * name
         
     | 
| 
      
 43 
     | 
    
         
            +
                * the name of env
         
     | 
| 
      
 44 
     | 
    
         
            +
            * &block
         
     | 
| 
      
 45 
     | 
    
         
            +
                * to define item
         
     | 
| 
       33 
46 
     | 
    
         | 
| 
       34 
47 
     | 
    
         
             
            ### group
         
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 48 
     | 
    
         
            +
            tag to the member of the group.
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                group(name, &block)
         
     | 
| 
      
 51 
     | 
    
         
            +
            * name
         
     | 
| 
      
 52 
     | 
    
         
            +
                * the name of group
         
     | 
| 
      
 53 
     | 
    
         
            +
                * tagged to the member of the group
         
     | 
| 
      
 54 
     | 
    
         
            +
            * &block
         
     | 
| 
      
 55 
     | 
    
         
            +
                * to define item for the member of the group
         
     | 
| 
       36 
56 
     | 
    
         | 
| 
       37 
57 
     | 
    
         
             
            ### item
         
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
                item(name, hash)
         
     | 
| 
      
 59 
     | 
    
         
            +
            * name
         
     | 
| 
      
 60 
     | 
    
         
            +
                * the name of item
         
     | 
| 
      
 61 
     | 
    
         
            +
                * if defined the same name, hash will be merged
         
     | 
| 
      
 62 
     | 
    
         
            +
            * hash
         
     | 
| 
      
 63 
     | 
    
         
            +
                * the property of item
         
     | 
| 
      
 64 
     | 
    
         
            +
                * :tags
         
     | 
| 
      
 65 
     | 
    
         
            +
                    * you can search by tags
         
     | 
| 
       39 
66 
     | 
    
         | 
| 
       40 
67 
     | 
    
         
             
            ## Aliases
         
     | 
| 
       41 
68 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
      
 69 
     | 
    
         
            +
            not yet implemented
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/VERSION
    CHANGED
    
    | 
         @@ -1 +1 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            0.0. 
     | 
| 
      
 1 
     | 
    
         
            +
            0.0.3
         
     | 
    
        data/egi.gemspec
    CHANGED
    
    | 
         @@ -19,8 +19,9 @@ Gem::Specification.new do |s| 
     | 
|
| 
       19 
19 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
21 
     | 
    
         
             
              # specify any dependencies here; for example:
         
     | 
| 
       22 
     | 
    
         
            -
              [ [ ' 
     | 
| 
       23 
     | 
    
         
            -
                [ ' 
     | 
| 
      
 22 
     | 
    
         
            +
              [ [ 'rake' ],
         
     | 
| 
      
 23 
     | 
    
         
            +
                [ 'rspec' ],
         
     | 
| 
      
 24 
     | 
    
         
            +
                [ 'autowatchr' ],
         
     | 
| 
       24 
25 
     | 
    
         
             
              ].each do |gem, version|
         
     | 
| 
       25 
26 
     | 
    
         
             
                s.add_development_dependency gem, version
         
     | 
| 
       26 
27 
     | 
    
         
             
              end
         
     | 
    
        data/lib/egi/env.rb
    CHANGED
    
    | 
         @@ -1,7 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module Egi
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Env
         
     | 
| 
       3 
3 
     | 
    
         
             
                def initialize(name)
         
     | 
| 
       4 
     | 
    
         
            -
                  @name 
     | 
| 
      
 4 
     | 
    
         
            +
                  @name    = name
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @default = {}
         
     | 
| 
      
 6 
     | 
    
         
            +
                end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def set(default = {})
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @default = default
         
     | 
| 
       5 
10 
     | 
    
         
             
                end
         
     | 
| 
       6 
11 
     | 
    
         | 
| 
       7 
12 
     | 
    
         
             
                def merge!(other)
         
     | 
| 
         @@ -15,10 +20,10 @@ module Egi 
     | 
|
| 
       15 
20 
     | 
    
         
             
                end
         
     | 
| 
       16 
21 
     | 
    
         | 
| 
       17 
22 
     | 
    
         
             
                def items
         
     | 
| 
       18 
     | 
    
         
            -
                  @items ||= Hash.new {|hash, key| hash[key] = Item[:name => key] }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @items ||= Hash.new {|hash, key| hash[key] = Item[{ :name => key }.merge(@default)] }
         
     | 
| 
       19 
24 
     | 
    
         
             
                end
         
     | 
| 
       20 
25 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
                def item(name, hash)
         
     | 
| 
      
 26 
     | 
    
         
            +
                def item(name, hash = {})
         
     | 
| 
       22 
27 
     | 
    
         
             
                  items[name.to_sym].update(hash)
         
     | 
| 
       23 
28 
     | 
    
         
             
                end
         
     | 
| 
       24 
29 
     | 
    
         
             
              end
         
     | 
    
        data/lib/egi/group.rb
    CHANGED
    
    | 
         @@ -2,13 +2,23 @@ module Egi 
     | 
|
| 
       2 
2 
     | 
    
         
             
              class Group
         
     | 
| 
       3 
3 
     | 
    
         
             
                def initialize(name = nil)
         
     | 
| 
       4 
4 
     | 
    
         
             
                  @tags = name ? [ name ] : [ ]
         
     | 
| 
      
 5 
     | 
    
         
            +
                  @default = {}
         
     | 
| 
      
 6 
     | 
    
         
            +
                end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                def set(default)
         
     | 
| 
      
 9 
     | 
    
         
            +
                  @default = default
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                def instance_eval(&block)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  super
         
     | 
| 
      
 14 
     | 
    
         
            +
                  self # for method chain
         
     | 
| 
       5 
15 
     | 
    
         
             
                end
         
     | 
| 
       6 
16 
     | 
    
         | 
| 
       7 
17 
     | 
    
         
             
                def items
         
     | 
| 
       8 
     | 
    
         
            -
                  @items ||= Hash.new {|hash, key| hash[key] = Item[:name => key, :tags => @tags] }
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @items ||= Hash.new {|hash, key| hash[key] = Item[{ :name => key, :tags => @tags }.merge(@default)] }
         
     | 
| 
       9 
19 
     | 
    
         
             
                end
         
     | 
| 
       10 
20 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
                def item(name, hash)
         
     | 
| 
      
 21 
     | 
    
         
            +
                def item(name, hash = {})
         
     | 
| 
       12 
22 
     | 
    
         
             
                  items[name.to_sym].update(hash)
         
     | 
| 
       13 
23 
     | 
    
         
             
                  self # for method chain
         
     | 
| 
       14 
24 
     | 
    
         
             
                end
         
     | 
    
        data/lib/egi/sandbox.rb
    CHANGED
    
    | 
         @@ -13,24 +13,31 @@ module Egi 
     | 
|
| 
       13 
13 
     | 
    
         
             
                  @current_env = name
         
     | 
| 
       14 
14 
     | 
    
         | 
| 
       15 
15 
     | 
    
         
             
                  to_load = opts[:load]
         
     | 
| 
       16 
     | 
    
         
            -
                   
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
       18 
     | 
    
         
            -
                  env.instance_eval(&block) if block_given?
         
     | 
| 
       19 
     | 
    
         
            -
                  
         
     | 
| 
       20 
     | 
    
         
            -
                  # define method_missing to access item
         
     | 
| 
       21 
     | 
    
         
            -
                  def env.method_missing(name, *args)
         
     | 
| 
       22 
     | 
    
         
            -
                    raise MethodMissing if args.size > 0
         
     | 
| 
       23 
     | 
    
         
            -
                    items.has_key?(name) ? items[name] : nil
         
     | 
| 
       24 
     | 
    
         
            -
                  end
         
     | 
| 
      
 16 
     | 
    
         
            +
                  envs[name].merge!(envs[to_load]) if envs.has_key?(to_load)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  envs[name].instance_eval(&block) if block_given?
         
     | 
| 
       25 
18 
     | 
    
         
             
                end
         
     | 
| 
       26 
19 
     | 
    
         | 
| 
       27 
20 
     | 
    
         
             
                def eval(str)
         
     | 
| 
       28 
21 
     | 
    
         
             
                  instance_eval(str)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  
         
     | 
| 
      
 23 
     | 
    
         
            +
                  # define method_missing to access items
         
     | 
| 
      
 24 
     | 
    
         
            +
                  envs.each_value do |env|
         
     | 
| 
      
 25 
     | 
    
         
            +
                    def env.method_missing(name, *args)
         
     | 
| 
      
 26 
     | 
    
         
            +
                      super if args.size > 0
         
     | 
| 
      
 27 
     | 
    
         
            +
                      items.has_key?(name) ? items[name] : nil
         
     | 
| 
      
 28 
     | 
    
         
            +
                    end
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
       29 
31 
     | 
    
         
             
                  envs
         
     | 
| 
       30 
32 
     | 
    
         
             
                end
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
     | 
    
         
            -
                def method_missing(name, *args)
         
     | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
      
 34 
     | 
    
         
            +
                def method_missing(name, *args, &block)
         
     | 
| 
      
 35 
     | 
    
         
            +
                  begin
         
     | 
| 
      
 36 
     | 
    
         
            +
                    envs[@current_env].send(name, *args, &block)
         
     | 
| 
      
 37 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
      
 38 
     | 
    
         
            +
                    puts "#{name}(#{args}) #{block_given? ? "with block" : ""} is called at #{@current_env} env"
         
     | 
| 
      
 39 
     | 
    
         
            +
                    raise e
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end        
         
     | 
| 
       34 
41 
     | 
    
         
             
                end
         
     | 
| 
       35 
42 
     | 
    
         
             
              end
         
     | 
| 
       36 
43 
     | 
    
         
             
            end
         
     | 
    
        data/lib/egi.rb
    CHANGED
    
    | 
         @@ -7,6 +7,8 @@ module Egi 
     | 
|
| 
       7 
7 
     | 
    
         
             
              autoload :Item,    'egi/item'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
              def env
         
     | 
| 
      
 10 
     | 
    
         
            +
                load_file(config_file) unless @env
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
       10 
12 
     | 
    
         
             
                name = ENV['EGI_ENV'] || 'default'
         
     | 
| 
       11 
13 
     | 
    
         
             
                self[name]
         
     | 
| 
       12 
14 
     | 
    
         
             
              end
         
     | 
| 
         @@ -15,6 +17,10 @@ module Egi 
     | 
|
| 
       15 
17 
     | 
    
         
             
                @env.has_key?(name) ? @env[name] : nil
         
     | 
| 
       16 
18 
     | 
    
         
             
              end
         
     | 
| 
       17 
19 
     | 
    
         | 
| 
      
 20 
     | 
    
         
            +
              def load_file(file)
         
     | 
| 
      
 21 
     | 
    
         
            +
                load(File.read(file))
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       18 
24 
     | 
    
         
             
              def load(str)
         
     | 
| 
       19 
25 
     | 
    
         
             
                @env = Sandbox.new.eval(str)
         
     | 
| 
       20 
26 
     | 
    
         
             
              end
         
     | 
| 
         @@ -22,5 +28,16 @@ module Egi 
     | 
|
| 
       22 
28 
     | 
    
         
             
              def reset
         
     | 
| 
       23 
29 
     | 
    
         
             
                @env = nil
         
     | 
| 
       24 
30 
     | 
    
         
             
              end
         
     | 
| 
       25 
     | 
    
         
            -
               
     | 
| 
      
 31 
     | 
    
         
            +
              def config_file
         
     | 
| 
      
 32 
     | 
    
         
            +
                @config_file || 
         
     | 
| 
      
 33 
     | 
    
         
            +
                  ( File.exist?('./egi.conf')    && './egi.conf' ) ||
         
     | 
| 
      
 34 
     | 
    
         
            +
                  ( File.exist?('/etc/egi.conf') && '/etc/egi.conf') ||
         
     | 
| 
      
 35 
     | 
    
         
            +
                  raise('you should set Egi.config_file or put ./egi.conf or /etc/egi.conf')
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              def config_file=(file)
         
     | 
| 
      
 39 
     | 
    
         
            +
                @config_file = file
         
     | 
| 
      
 40 
     | 
    
         
            +
              end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
              module_function :env, :[], :load, :reset, :config_file, :config_file=
         
     | 
| 
       26 
43 
     | 
    
         
             
            end
         
     | 
    
        data/spec/egi_spec.rb
    CHANGED
    
    | 
         @@ -14,21 +14,82 @@ RSpec::Matchers.define :have_item do |key, value| 
     | 
|
| 
       14 
14 
     | 
    
         
             
              diffable
         
     | 
| 
       15 
15 
     | 
    
         
             
            end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
      
 17 
     | 
    
         
            +
            shared_examples_for :sample_environments do
         
     | 
| 
      
 18 
     | 
    
         
            +
              context 'makes env1' do
         
     | 
| 
      
 19 
     | 
    
         
            +
                subject { described_class[:env1] }
         
     | 
| 
      
 20 
     | 
    
         
            +
                
         
     | 
| 
      
 21 
     | 
    
         
            +
                it { should have_item(:a, :hoge => :fuga) }
         
     | 
| 
      
 22 
     | 
    
         
            +
                it { should have_item(:b, :fuga => :ugu)  }
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
              
         
     | 
| 
      
 25 
     | 
    
         
            +
              context 'makes env_group' do
         
     | 
| 
      
 26 
     | 
    
         
            +
                subject { described_class[:env_group] }
         
     | 
| 
      
 27 
     | 
    
         
            +
                it { should have_item(:a, :hoge => :fuga, :tags => [ :hoge ]) }
         
     | 
| 
      
 28 
     | 
    
         
            +
                it { should have_item(:b, :tags => [ :hoge, :fuga ]) }
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
              
         
     | 
| 
      
 31 
     | 
    
         
            +
              context 'makes env2' do
         
     | 
| 
      
 32 
     | 
    
         
            +
                subject { described_class[:env2] }
         
     | 
| 
      
 33 
     | 
    
         
            +
                
         
     | 
| 
      
 34 
     | 
    
         
            +
                it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
      
 35 
     | 
    
         
            +
                its(:b) { should be_nil }
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              context 'makes loaded_env1 which loads env1' do
         
     | 
| 
      
 39 
     | 
    
         
            +
                subject { described_class[:loaded_env1] }
         
     | 
| 
      
 40 
     | 
    
         
            +
                
         
     | 
| 
      
 41 
     | 
    
         
            +
                it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
      
 42 
     | 
    
         
            +
                it { should have_item(:b, :fuga => :ugu) }
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              context 'makes env with default' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                subject { described_class[:env_with_default] }
         
     | 
| 
      
 47 
     | 
    
         
            +
                
         
     | 
| 
      
 48 
     | 
    
         
            +
                it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
      
 49 
     | 
    
         
            +
                it { should have_item(:b, :hoge => :fuga) }
         
     | 
| 
      
 50 
     | 
    
         
            +
                it { should have_item(:c, :hoge => :piyo, :tags => []) }
         
     | 
| 
      
 51 
     | 
    
         
            +
                it { should have_item(:d, :hoge => :puyo, :tags => []) }
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
              
         
     | 
| 
      
 54 
     | 
    
         
            +
              context 'does not make env3' do
         
     | 
| 
      
 55 
     | 
    
         
            +
                subject { described_class[:env3] }
         
     | 
| 
      
 56 
     | 
    
         
            +
                it { should be_nil }
         
     | 
| 
      
 57 
     | 
    
         
            +
              end
         
     | 
| 
      
 58 
     | 
    
         
            +
            end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
       17 
60 
     | 
    
         
             
            describe klass, '.load environments:' do
         
     | 
| 
       18 
61 
     | 
    
         
             
              environments = <<-EOS
         
     | 
| 
       19 
62 
     | 
    
         
             
            env(:env1) {
         
     | 
| 
       20 
     | 
    
         
            -
              item :a,  
     | 
| 
       21 
     | 
    
         
            -
              item :b,  
     | 
| 
      
 63 
     | 
    
         
            +
              item :a, :hoge => :fuga
         
     | 
| 
      
 64 
     | 
    
         
            +
              item :b, :fuga => :ugu
         
     | 
| 
       22 
65 
     | 
    
         
             
            }
         
     | 
| 
       23 
66 
     | 
    
         | 
| 
      
 67 
     | 
    
         
            +
            env(:env_group) {
         
     | 
| 
      
 68 
     | 
    
         
            +
              group(:hoge) {
         
     | 
| 
      
 69 
     | 
    
         
            +
                item :a, :hoge => :fuga
         
     | 
| 
      
 70 
     | 
    
         
            +
                item :b, :tags => [ :fuga ]
         
     | 
| 
      
 71 
     | 
    
         
            +
              }
         
     | 
| 
      
 72 
     | 
    
         
            +
            }
         
     | 
| 
      
 73 
     | 
    
         
            +
             
         
     | 
| 
       24 
74 
     | 
    
         
             
            env(:env2) {
         
     | 
| 
       25 
     | 
    
         
            -
              item :a,  
     | 
| 
      
 75 
     | 
    
         
            +
              item :a, :hoge => :ugu
         
     | 
| 
       26 
76 
     | 
    
         
             
            }
         
     | 
| 
       27 
77 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
            env(: 
     | 
| 
       29 
     | 
    
         
            -
               
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 78 
     | 
    
         
            +
            env(:loaded_env1, :load => :env1) {
         
     | 
| 
      
 79 
     | 
    
         
            +
              item :a, :hoge => :ugu
         
     | 
| 
      
 80 
     | 
    
         
            +
            }
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            env(:env_with_default) {
         
     | 
| 
      
 83 
     | 
    
         
            +
              set :hoge => :ugu
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
              item :a
         
     | 
| 
      
 86 
     | 
    
         
            +
              item :b, :hoge => :fuga
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
              group {
         
     | 
| 
      
 89 
     | 
    
         
            +
                set :hoge => :piyo
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                item :c
         
     | 
| 
      
 92 
     | 
    
         
            +
                item :d, :hoge => :puyo
         
     | 
| 
       32 
93 
     | 
    
         
             
              }
         
     | 
| 
       33 
94 
     | 
    
         
             
            }
         
     | 
| 
       34 
95 
     | 
    
         
             
              EOS
         
     | 
| 
         @@ -37,99 +98,45 @@ env(:env_group) { 
     | 
|
| 
       37 
98 
     | 
    
         
             
                before(:all) { described_class.load(environments) }
         
     | 
| 
       38 
99 
     | 
    
         
             
                after(:all)  { described_class.reset }
         
     | 
| 
       39 
100 
     | 
    
         | 
| 
       40 
     | 
    
         
            -
                 
     | 
| 
       41 
     | 
    
         
            -
                  subject { described_class[:env1] }
         
     | 
| 
       42 
     | 
    
         
            -
                  
         
     | 
| 
       43 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :fuga) }
         
     | 
| 
       44 
     | 
    
         
            -
                  it { should have_item(:b, :fuga => :ugu)  }
         
     | 
| 
       45 
     | 
    
         
            -
                end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                context 'makes env2' do
         
     | 
| 
       48 
     | 
    
         
            -
                  subject { described_class[:env2] }
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
       51 
     | 
    
         
            -
                  its(:b) { should be_nil }
         
     | 
| 
       52 
     | 
    
         
            -
                end
         
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
                context 'makes env_group' do
         
     | 
| 
       55 
     | 
    
         
            -
                  subject { described_class[:env_group] }
         
     | 
| 
       56 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :fuga, :tags => [ :hoge ]) }
         
     | 
| 
       57 
     | 
    
         
            -
                  it { should have_item(:b, :tags => [ :hoge, :fuga ]) }
         
     | 
| 
       58 
     | 
    
         
            -
                end
         
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
                context 'does not make env3' do
         
     | 
| 
       61 
     | 
    
         
            -
                  subject { described_class[:env3] }
         
     | 
| 
       62 
     | 
    
         
            -
                  it { should be_nil }
         
     | 
| 
       63 
     | 
    
         
            -
                end
         
     | 
| 
      
 101 
     | 
    
         
            +
                it_should_behave_like :sample_environments
         
     | 
| 
       64 
102 
     | 
    
         
             
              end
         
     | 
| 
       65 
103 
     | 
    
         
             
            end
         
     | 
| 
       66 
104 
     | 
    
         | 
| 
       67 
     | 
    
         
            -
            describe klass, '.load environments:' do
         
     | 
| 
      
 105 
     | 
    
         
            +
            describe klass, '.load flat environments:' do
         
     | 
| 
       68 
106 
     | 
    
         
             
              environments = <<-EOS
         
     | 
| 
       69 
107 
     | 
    
         
             
            env :env1
         
     | 
| 
       70 
     | 
    
         
            -
            item :a,  
     | 
| 
       71 
     | 
    
         
            -
            item :b,  
     | 
| 
      
 108 
     | 
    
         
            +
            item :a, :hoge => :fuga
         
     | 
| 
      
 109 
     | 
    
         
            +
            item :b, :fuga => :ugu
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
            env :env_group
         
     | 
| 
      
 112 
     | 
    
         
            +
            group(:hoge) {
         
     | 
| 
      
 113 
     | 
    
         
            +
              item :a, :hoge => :fuga
         
     | 
| 
      
 114 
     | 
    
         
            +
              item :b, :tags => [ :fuga ]
         
     | 
| 
      
 115 
     | 
    
         
            +
            }
         
     | 
| 
       72 
116 
     | 
    
         | 
| 
       73 
117 
     | 
    
         
             
            env :env2
         
     | 
| 
       74 
     | 
    
         
            -
            item :a,  
     | 
| 
       75 
     | 
    
         
            -
              EOS
         
     | 
| 
      
 118 
     | 
    
         
            +
            item :a, :hoge => :ugu
         
     | 
| 
       76 
119 
     | 
    
         | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                after(:all)  { described_class.reset }
         
     | 
| 
       80 
     | 
    
         
            -
                
         
     | 
| 
       81 
     | 
    
         
            -
                context 'makes env1' do
         
     | 
| 
       82 
     | 
    
         
            -
                  subject { described_class[:env1] }
         
     | 
| 
       83 
     | 
    
         
            -
                  
         
     | 
| 
       84 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :fuga) }
         
     | 
| 
       85 
     | 
    
         
            -
                  it { should have_item(:b, :fuga => :ugu)  }
         
     | 
| 
       86 
     | 
    
         
            -
                end
         
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
                context 'makes env2' do
         
     | 
| 
       89 
     | 
    
         
            -
                  subject { described_class[:env2] }
         
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
       92 
     | 
    
         
            -
                  its(:b) { should be_nil }
         
     | 
| 
       93 
     | 
    
         
            -
                end
         
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
                context 'does not make env3' do
         
     | 
| 
       96 
     | 
    
         
            -
                  subject { described_class[:env3] }
         
     | 
| 
       97 
     | 
    
         
            -
                  it { should be_nil }
         
     | 
| 
       98 
     | 
    
         
            -
                end
         
     | 
| 
       99 
     | 
    
         
            -
              end
         
     | 
| 
       100 
     | 
    
         
            -
            end
         
     | 
| 
      
 120 
     | 
    
         
            +
            env :loaded_env1, :load => :env1
         
     | 
| 
      
 121 
     | 
    
         
            +
            item :a, :hoge => :ugu
         
     | 
| 
       101 
122 
     | 
    
         | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
            env :env1
         
     | 
| 
       105 
     | 
    
         
            -
            item :a, { :hoge => :fuga }
         
     | 
| 
       106 
     | 
    
         
            -
            item :b, { :fuga => :ugu  }
         
     | 
| 
      
 123 
     | 
    
         
            +
            env :env_with_default
         
     | 
| 
      
 124 
     | 
    
         
            +
            set :hoge => :ugu
         
     | 
| 
       107 
125 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
            item : 
     | 
| 
      
 126 
     | 
    
         
            +
            item :a
         
     | 
| 
      
 127 
     | 
    
         
            +
            item :b, :hoge => :fuga
         
     | 
| 
      
 128 
     | 
    
         
            +
            group {
         
     | 
| 
      
 129 
     | 
    
         
            +
              set :hoge => :piyo
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
              item :c
         
     | 
| 
      
 132 
     | 
    
         
            +
              item :d, :hoge => :puyo
         
     | 
| 
      
 133 
     | 
    
         
            +
            }
         
     | 
| 
       110 
134 
     | 
    
         
             
              EOS
         
     | 
| 
       111 
135 
     | 
    
         | 
| 
       112 
136 
     | 
    
         
             
              context "\n#{environments}" do
         
     | 
| 
       113 
137 
     | 
    
         
             
                before(:all) { described_class.load(environments) }
         
     | 
| 
       114 
138 
     | 
    
         
             
                after(:all)  { described_class.reset }
         
     | 
| 
       115 
139 
     | 
    
         | 
| 
       116 
     | 
    
         
            -
                 
     | 
| 
       117 
     | 
    
         
            -
                  subject { described_class[:env1] }
         
     | 
| 
       118 
     | 
    
         
            -
                  
         
     | 
| 
       119 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :fuga) }
         
     | 
| 
       120 
     | 
    
         
            -
                  it { should have_item(:b, :fuga => :ugu)  }
         
     | 
| 
       121 
     | 
    
         
            -
                end
         
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
                context 'makes env2' do
         
     | 
| 
       124 
     | 
    
         
            -
                  subject { described_class[:env2] }
         
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
                  it { should have_item(:a, :hoge => :ugu) }
         
     | 
| 
       127 
     | 
    
         
            -
                  it { should have_item(:b, :fuga => :ugu) }
         
     | 
| 
       128 
     | 
    
         
            -
                end
         
     | 
| 
       129 
     | 
    
         
            -
             
     | 
| 
       130 
     | 
    
         
            -
                context 'does not make env3' do
         
     | 
| 
       131 
     | 
    
         
            -
                  subject { described_class[:env3] }
         
     | 
| 
       132 
     | 
    
         
            -
                  it { should be_nil }
         
     | 
| 
       133 
     | 
    
         
            -
                end
         
     | 
| 
      
 140 
     | 
    
         
            +
                it_should_behave_like :sample_environments
         
     | 
| 
       134 
141 
     | 
    
         
             
              end
         
     | 
| 
       135 
142 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: egi
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.3
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       7 
7 
     | 
    
         
             
            authors:
         
     | 
| 
         @@ -9,11 +9,22 @@ authors: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       10 
10 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       11 
11 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       12 
     | 
    
         
            -
            date: 2011-11- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2011-11-28 00:00:00.000000000 Z
         
     | 
| 
       13 
13 
     | 
    
         
             
            dependencies:
         
     | 
| 
      
 14 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 15 
     | 
    
         
            +
              name: rake
         
     | 
| 
      
 16 
     | 
    
         
            +
              requirement: &84892960 !ruby/object:Gem::Requirement
         
     | 
| 
      
 17 
     | 
    
         
            +
                none: false
         
     | 
| 
      
 18 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 19 
     | 
    
         
            +
                - - ! '>='
         
     | 
| 
      
 20 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 21 
     | 
    
         
            +
                    version: '0'
         
     | 
| 
      
 22 
     | 
    
         
            +
              type: :development
         
     | 
| 
      
 23 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 24 
     | 
    
         
            +
              version_requirements: *84892960
         
     | 
| 
       14 
25 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       15 
26 
     | 
    
         
             
              name: rspec
         
     | 
| 
       16 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 27 
     | 
    
         
            +
              requirement: &84892670 !ruby/object:Gem::Requirement
         
     | 
| 
       17 
28 
     | 
    
         
             
                none: false
         
     | 
| 
       18 
29 
     | 
    
         
             
                requirements:
         
     | 
| 
       19 
30 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -21,10 +32,10 @@ dependencies: 
     | 
|
| 
       21 
32 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       22 
33 
     | 
    
         
             
              type: :development
         
     | 
| 
       23 
34 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       24 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 35 
     | 
    
         
            +
              version_requirements: *84892670
         
     | 
| 
       25 
36 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       26 
37 
     | 
    
         
             
              name: autowatchr
         
     | 
| 
       27 
     | 
    
         
            -
              requirement: & 
     | 
| 
      
 38 
     | 
    
         
            +
              requirement: &84892430 !ruby/object:Gem::Requirement
         
     | 
| 
       28 
39 
     | 
    
         
             
                none: false
         
     | 
| 
       29 
40 
     | 
    
         
             
                requirements:
         
     | 
| 
       30 
41 
     | 
    
         
             
                - - ! '>='
         
     | 
| 
         @@ -32,7 +43,7 @@ dependencies: 
     | 
|
| 
       32 
43 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       33 
44 
     | 
    
         
             
              type: :development
         
     | 
| 
       34 
45 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       35 
     | 
    
         
            -
              version_requirements: * 
     | 
| 
      
 46 
     | 
    
         
            +
              version_requirements: *84892430
         
     | 
| 
       36 
47 
     | 
    
         
             
            description: manage multi-environments
         
     | 
| 
       37 
48 
     | 
    
         
             
            email:
         
     | 
| 
       38 
49 
     | 
    
         
             
            - okitakunio@gmail.com
         
     | 
| 
         @@ -43,6 +54,7 @@ files: 
     | 
|
| 
       43 
54 
     | 
    
         
             
            - .gitignore
         
     | 
| 
       44 
55 
     | 
    
         
             
            - .rspec
         
     | 
| 
       45 
56 
     | 
    
         
             
            - .rvmrc
         
     | 
| 
      
 57 
     | 
    
         
            +
            - .travis.yml
         
     | 
| 
       46 
58 
     | 
    
         
             
            - CHANGELOG.md
         
     | 
| 
       47 
59 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       48 
60 
     | 
    
         
             
            - README.md
         
     |