blueprints 0.3.1 → 0.3.2
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/lib/blueprints/buildable.rb
    CHANGED
    
    | 
         @@ -7,7 +7,7 @@ module Blueprints 
     | 
|
| 
       7 
7 
     | 
    
         
             
                  @name, parents = parse_name(name)
         
     | 
| 
       8 
8 
     | 
    
         
             
                  depends_on(*parents)
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
     | 
    
         
            -
                  Namespace.root.add_child(self) if Namespace.root 
     | 
| 
      
 10 
     | 
    
         
            +
                  Namespace.root.add_child(self) if Namespace.root
         
     | 
| 
       11 
11 
     | 
    
         
             
                end
         
     | 
| 
       12 
12 
     | 
    
         | 
| 
       13 
13 
     | 
    
         
             
                def depends_on(*scenarios)
         
     | 
| 
         @@ -15,7 +15,8 @@ module Blueprints 
     | 
|
| 
       15 
15 
     | 
    
         
             
                end
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
                def build
         
     | 
| 
       18 
     | 
    
         
            -
                  namespace 
     | 
| 
      
 18 
     | 
    
         
            +
                  namespace = self
         
     | 
| 
      
 19 
     | 
    
         
            +
                  namespace.build_parent_plans while namespace = namespace.namespace
         
     | 
| 
       19 
20 
     | 
    
         
             
                  build_parent_plans
         
     | 
| 
       20 
21 
     | 
    
         
             
                  build_plan
         
     | 
| 
       21 
22 
     | 
    
         
             
                end
         
     | 
| 
         @@ -34,8 +35,7 @@ module Blueprints 
     | 
|
| 
       34 
35 
     | 
    
         
             
                      Namespace.root[p]
         
     | 
| 
       35 
36 
     | 
    
         
             
                    end
         
     | 
| 
       36 
37 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                    parent. 
     | 
| 
       38 
     | 
    
         
            -
                    parent.build_plan
         
     | 
| 
      
 38 
     | 
    
         
            +
                    parent.build
         
     | 
| 
       39 
39 
     | 
    
         
             
                  end
         
     | 
| 
       40 
40 
     | 
    
         
             
                end
         
     | 
| 
       41 
41 
     | 
    
         | 
    
        data/lib/blueprints/helper.rb
    CHANGED
    
    | 
         @@ -14,9 +14,9 @@ module Blueprints 
     | 
|
| 
       14 
14 
     | 
    
         
             
                  if options[:undo] == :all
         
     | 
| 
       15 
15 
     | 
    
         
             
                    Namespace.root.executed_plans.clear
         
     | 
| 
       16 
16 
     | 
    
         
             
                  else
         
     | 
| 
       17 
     | 
    
         
            -
                    undo = [options[:undo]].flatten.compact
         
     | 
| 
      
 17 
     | 
    
         
            +
                    undo = [options[:undo]].flatten.compact.collect {|bp| bp.to_s }
         
     | 
| 
       18 
18 
     | 
    
         
             
                    unless (not_found = undo - Namespace.root.executed_plans.to_a).blank?
         
     | 
| 
       19 
     | 
    
         
            -
                      raise( 
     | 
| 
      
 19 
     | 
    
         
            +
                      raise(PlanNotFoundError, not_found)
         
     | 
| 
       20 
20 
     | 
    
         
             
                    end
         
     | 
| 
       21 
21 
     | 
    
         
             
                    Namespace.root.executed_plans -= undo
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
    
        data/lib/blueprints/plan.rb
    CHANGED
    
    | 
         @@ -11,8 +11,8 @@ module Blueprints 
     | 
|
| 
       11 
11 
     | 
    
         
             
                      @result = Namespace.root.context.module_eval(&@block)
         
     | 
| 
       12 
12 
     | 
    
         
             
                      Namespace.root.add_variable(path, @result)
         
     | 
| 
       13 
13 
     | 
    
         
             
                    end
         
     | 
| 
       14 
     | 
    
         
            -
                  end unless Namespace.root.executed_plans.include?( 
     | 
| 
       15 
     | 
    
         
            -
                  Namespace.root.executed_plans <<  
     | 
| 
      
 14 
     | 
    
         
            +
                  end unless Namespace.root.executed_plans.include?(path)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  Namespace.root.executed_plans << path
         
     | 
| 
       16 
16 
     | 
    
         
             
                  @result
         
     | 
| 
       17 
17 
     | 
    
         
             
                end
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
         @@ -24,7 +24,7 @@ module Blueprints 
     | 
|
| 
       24 
24 
     | 
    
         | 
| 
       25 
25 
     | 
    
         
             
                def prebuild(plans)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  @context = @global_context
         
     | 
| 
       27 
     | 
    
         
            -
                  @global_scenarios = build(plans) if plans
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @global_scenarios = build(*plans) if plans
         
     | 
| 
       28 
28 
     | 
    
         
             
                  @global_executed_plans = @executed_plans
         
     | 
| 
       29 
29 
     | 
    
         
             
                  @global_context = YAML.dump(@global_context)
         
     | 
| 
       30 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -40,4 +40,4 @@ module Blueprints 
     | 
|
| 
       40 
40 
     | 
    
         | 
| 
       41 
41 
     | 
    
         
             
                @@root = RootNamespace.new
         
     | 
| 
       42 
42 
     | 
    
         
             
              end
         
     | 
| 
       43 
     | 
    
         
            -
            end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -47,7 +47,7 @@ namespace :pitted => :pine do 
     | 
|
| 
       47 
47 
     | 
    
         
             
              Fruit.blueprint(:peach, :species => 'pitted peach', :tree => :@peach_tree).depends_on(:peach_tree)
         
     | 
| 
       48 
48 
     | 
    
         
             
              Fruit.blueprint(:acorn, :species => 'pitted acorn', :tree => :@oak).depends_on(:oak)
         
     | 
| 
       49 
49 
     | 
    
         | 
| 
       50 
     | 
    
         
            -
              namespace :red do
         
     | 
| 
      
 50 
     | 
    
         
            +
              namespace :red => :orange do
         
     | 
| 
       51 
51 
     | 
    
         
             
                Fruit.blueprint(:apple, :species => 'pitted red apple')
         
     | 
| 
       52 
52 
     | 
    
         
             
              end
         
     | 
| 
       53 
53 
     | 
    
         
             
            end
         
     | 
| 
         @@ -123,7 +123,7 @@ describe Blueprints do 
     | 
|
| 
       123 
123 
     | 
    
         
             
                it "should raise error when not executed scenarios passed to :undo option" do
         
     | 
| 
       124 
124 
     | 
    
         
             
                  lambda {
         
     | 
| 
       125 
125 
     | 
    
         
             
                    demolish :undo => :orange
         
     | 
| 
       126 
     | 
    
         
            -
                  }.should raise_error( 
     | 
| 
      
 126 
     | 
    
         
            +
                  }.should raise_error(Blueprints::PlanNotFoundError, "Plan/namespace not found 'orange'")
         
     | 
| 
       127 
127 
     | 
    
         
             
                end
         
     | 
| 
       128 
128 
     | 
    
         
             
              end
         
     | 
| 
       129 
129 
     | 
    
         | 
| 
         @@ -242,7 +242,7 @@ describe Blueprints do 
     | 
|
| 
       242 
242 
     | 
    
         
             
                  build 'pitted.peach_tree'
         
     | 
| 
       243 
243 
     | 
    
         
             
                  @pitted_peach_tree.name.should == 'pitted peach tree'
         
     | 
| 
       244 
244 
     | 
    
         
             
                end
         
     | 
| 
       245 
     | 
    
         
            -
             
     | 
| 
      
 245 
     | 
    
         
            +
             
     | 
| 
       246 
246 
     | 
    
         
             
                it "should allow adding dependencies from same namespace" do
         
     | 
| 
       247 
247 
     | 
    
         
             
                  build 'pitted.peach'
         
     | 
| 
       248 
248 
     | 
    
         
             
                  @pitted_peach.species.should == 'pitted peach'
         
     | 
| 
         @@ -257,7 +257,6 @@ describe Blueprints do 
     | 
|
| 
       257 
257 
     | 
    
         | 
| 
       258 
258 
     | 
    
         
             
                it "should allow building whole namespace" do
         
     | 
| 
       259 
259 
     | 
    
         
             
                  build :pitted
         
     | 
| 
       260 
     | 
    
         
            -
                  p instance_variables
         
     | 
| 
       261 
260 
     | 
    
         
             
                  @pitted_peach_tree.should_not be_nil
         
     | 
| 
       262 
261 
     | 
    
         
             
                  @pitted_peach.should_not be_nil
         
     | 
| 
       263 
262 
     | 
    
         
             
                  @pitted_acorn.should_not be_nil
         
     | 
| 
         @@ -265,12 +264,19 @@ describe Blueprints do 
     | 
|
| 
       265 
264 
     | 
    
         
             
                  @pitted.should =~ [@pitted_peach_tree, @pitted_peach, @pitted_acorn, [@pitted_red_apple]]
         
     | 
| 
       266 
265 
     | 
    
         
             
                end
         
     | 
| 
       267 
266 
     | 
    
         | 
| 
       268 
     | 
    
         
            -
                it "should load dependencies when building namespaced blueprint if namespace has any" do
         
     | 
| 
       269 
     | 
    
         
            -
                  build 'pitted.peach'
         
     | 
| 
       270 
     | 
    
         
            -
                  @the_pine.should_not be_nil
         
     | 
| 
       271 
     | 
    
         
            -
                end
         
     | 
| 
       272 
     | 
    
         
            -
             
     | 
| 
       273 
267 
     | 
    
         
             
                describe "with red namespace" do
         
     | 
| 
      
 268 
     | 
    
         
            +
                  it "should allow building blueprint with same name in different namespaces" do
         
     | 
| 
      
 269 
     | 
    
         
            +
                    build :apple, 'pitted.red.apple'
         
     | 
| 
      
 270 
     | 
    
         
            +
                    @apple.species.should == 'apple'
         
     | 
| 
      
 271 
     | 
    
         
            +
                    @pitted_red_apple.species.should == 'pitted red apple'
         
     | 
| 
      
 272 
     | 
    
         
            +
                  end
         
     | 
| 
      
 273 
     | 
    
         
            +
             
     | 
| 
      
 274 
     | 
    
         
            +
                  it "should load dependencies when building namespaced blueprint if parent namespaces have any" do
         
     | 
| 
      
 275 
     | 
    
         
            +
                    build 'pitted.red.apple'
         
     | 
| 
      
 276 
     | 
    
         
            +
                    @the_pine.should_not be_nil
         
     | 
| 
      
 277 
     | 
    
         
            +
                    @orange.should_not be_nil
         
     | 
| 
      
 278 
     | 
    
         
            +
                  end
         
     | 
| 
      
 279 
     | 
    
         
            +
             
     | 
| 
       274 
280 
     | 
    
         
             
                  it "should allow building nested namespaces scenarios" do
         
     | 
| 
       275 
281 
     | 
    
         
             
                    build 'pitted.red.apple'
         
     | 
| 
       276 
282 
     | 
    
         
             
                    @pitted_red_apple.species.should == 'pitted red apple'
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: blueprints
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.3. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.3.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors: 
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Andrius Chamentauskas
         
     | 
| 
         @@ -9,7 +9,7 @@ autorequire: 
     | 
|
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
     | 
    
         
            -
            date: 2009-10- 
     | 
| 
      
 12 
     | 
    
         
            +
            date: 2009-10-20 00:00:00 +03:00
         
     | 
| 
       13 
13 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies: 
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency 
         
     | 
| 
         @@ -31,17 +31,17 @@ extensions: [] 
     | 
|
| 
       31 
31 
     | 
    
         
             
            extra_rdoc_files: []
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            files: 
         
     | 
| 
      
 34 
     | 
    
         
            +
            - lib/blueprints.rb
         
     | 
| 
       34 
35 
     | 
    
         
             
            - lib/blueprints/file_context.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/blueprints/ar_extensions.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - lib/blueprints/test_unit_extensions.rb
         
     | 
| 
       35 
38 
     | 
    
         
             
            - lib/blueprints/helper.rb
         
     | 
| 
       36 
39 
     | 
    
         
             
            - lib/blueprints/buildable.rb
         
     | 
| 
       37 
     | 
    
         
            -
            - lib/blueprints/root_namespace.rb
         
     | 
| 
       38 
40 
     | 
    
         
             
            - lib/blueprints/plan.rb
         
     | 
| 
       39 
41 
     | 
    
         
             
            - lib/blueprints/rspec_extensions.rb
         
     | 
| 
       40 
     | 
    
         
            -
            - lib/blueprints/ 
     | 
| 
       41 
     | 
    
         
            -
            - lib/blueprints/test_unit_extensions.rb
         
     | 
| 
      
 42 
     | 
    
         
            +
            - lib/blueprints/root_namespace.rb
         
     | 
| 
       42 
43 
     | 
    
         
             
            - lib/blueprints/namespace.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
            - lib/blueprints/errors.rb
         
     | 
| 
       44 
     | 
    
         
            -
            - lib/blueprints.rb
         
     | 
| 
       45 
45 
     | 
    
         
             
            - README.rdoc
         
     | 
| 
       46 
46 
     | 
    
         
             
            - LICENSE
         
     | 
| 
       47 
47 
     | 
    
         
             
            has_rdoc: true
         
     |