developwithpassion_expander 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
@@ -1,11 +1,13 @@
|
|
1
1
|
module DevelopWithPassion
|
2
2
|
module Expander
|
3
3
|
class Expansion
|
4
|
-
attr_accessor :copies,:files_to_merge
|
4
|
+
attr_accessor :copies,:files_to_merge,:globber
|
5
5
|
|
6
6
|
def initialize
|
7
7
|
initialize_hashes :files_to_merge,:copies
|
8
8
|
|
9
|
+
@globber = lambda{|path| return glob(path)}
|
10
|
+
|
9
11
|
array :cleanup_items do|a|
|
10
12
|
a.readable
|
11
13
|
a.process_using :run_cleanup,:call
|
@@ -21,13 +23,6 @@ module DevelopWithPassion
|
|
21
23
|
a.process_using :mark_files_executable,ShellActionAgainstFile.new("chmod +x")
|
22
24
|
end
|
23
25
|
|
24
|
-
array :templates do|a|
|
25
|
-
a.mutator :look_for_templates_in do|path|
|
26
|
-
@templates.concat(glob(path))
|
27
|
-
end
|
28
|
-
a.process_using :expand_templates,TemplateVisitor.instance
|
29
|
-
end
|
30
|
-
|
31
26
|
array :files_with_line_endings_to_fix do|a|
|
32
27
|
a.mutator :fix_line_endings_for
|
33
28
|
a.process_using :fix_line_endings,ShellActionAgainstFile.new("d2u")
|
@@ -47,6 +42,9 @@ module DevelopWithPassion
|
|
47
42
|
hash_process(target,@files_to_merge,lambda{|key| return FileMerge.new(key)},&block)
|
48
43
|
end
|
49
44
|
|
45
|
+
def look_for_templates_in(path)
|
46
|
+
@globber.call(path).process_all_items_using(TemplateVisitor.instance)
|
47
|
+
end
|
50
48
|
|
51
49
|
def cleanup(&block)
|
52
50
|
@cleanup_items << block
|
@@ -59,7 +57,6 @@ module DevelopWithPassion
|
|
59
57
|
def run
|
60
58
|
run_setup_items
|
61
59
|
purge_targets
|
62
|
-
expand_templates
|
63
60
|
expand_items
|
64
61
|
merge_items
|
65
62
|
fix_line_endings
|
data/spec/specs/copy_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
module DevelopWithPassion
|
4
4
|
module Expander
|
5
|
-
class
|
5
|
+
class AFakeVisitor
|
6
6
|
def initialize
|
7
7
|
array :sources do|a|
|
8
8
|
a.readable
|
@@ -13,7 +13,7 @@ module DevelopWithPassion
|
|
13
13
|
end
|
14
14
|
describe Copy do
|
15
15
|
let(:sources){[]}
|
16
|
-
let(:copy_visitor){
|
16
|
+
let(:copy_visitor){AFakeVisitor.new}
|
17
17
|
|
18
18
|
before (:each) do
|
19
19
|
@sut = Copy.new(copy_visitor)
|
@@ -4,7 +4,6 @@ module DevelopWithPassion
|
|
4
4
|
module Expander
|
5
5
|
describe Expansion do
|
6
6
|
let(:sources){[]}
|
7
|
-
let(:template_visitor){fake}
|
8
7
|
let(:builders){{
|
9
8
|
:cleanup_items => fake,
|
10
9
|
:setup_items => fake,
|
@@ -20,7 +19,6 @@ module DevelopWithPassion
|
|
20
19
|
|
21
20
|
context "when created" do
|
22
21
|
before (:each) do
|
23
|
-
TemplateVisitor.stub(:instance).and_return(template_visitor)
|
24
22
|
the_module = Module.new do
|
25
23
|
end
|
26
24
|
ArrayDSLModuleFactory.stub(:new).and_return(module_factory)
|
@@ -66,16 +64,10 @@ module DevelopWithPassion
|
|
66
64
|
folders_to_purge_builder_builder.should have_received(:process_using,:purge_targets,rm_rf_visitor)
|
67
65
|
end
|
68
66
|
|
69
|
-
it "should scaffold the templates list" do
|
70
|
-
templates_builder_builder = builders[:templates]
|
71
|
-
templates_builder_builder.should have_received(:mutator,:look_for_templates_in)
|
72
|
-
templates_builder_builder.should have_received(:process_using,:expand_templates,template_visitor)
|
73
|
-
end
|
74
67
|
end
|
75
68
|
|
76
69
|
context "when specifying a copy" do
|
77
70
|
before (:each) do
|
78
|
-
TemplateVisitor.stub(:instance).and_return(template_visitor)
|
79
71
|
@sut = Expansion.new
|
80
72
|
end
|
81
73
|
|
@@ -96,7 +88,6 @@ module DevelopWithPassion
|
|
96
88
|
|
97
89
|
context "when specifying a merge" do
|
98
90
|
before (:each) do
|
99
|
-
TemplateVisitor.stub(:instance).and_return(template_visitor)
|
100
91
|
@sut = Expansion.new
|
101
92
|
end
|
102
93
|
before (:each) do
|
@@ -116,7 +107,6 @@ module DevelopWithPassion
|
|
116
107
|
|
117
108
|
context "when a cleanup is specified" do
|
118
109
|
before (:each) do
|
119
|
-
TemplateVisitor.stub(:instance).and_return(template_visitor)
|
120
110
|
@sut = Expansion.new
|
121
111
|
end
|
122
112
|
before (:each) do
|
@@ -128,9 +118,39 @@ module DevelopWithPassion
|
|
128
118
|
end
|
129
119
|
end
|
130
120
|
|
131
|
-
|
121
|
+
class FakeVisitor
|
122
|
+
attr_accessor :items
|
123
|
+
def initialize
|
124
|
+
@items = 0
|
125
|
+
end
|
126
|
+
def run_using(file)
|
127
|
+
@items+=1
|
128
|
+
end
|
129
|
+
end
|
130
|
+
context "when a set of templates is specified" do
|
131
|
+
let(:path){"**/*"}
|
132
|
+
let(:template_visitor){FakeVisitor.new}
|
132
133
|
before (:each) do
|
133
134
|
TemplateVisitor.stub(:instance).and_return(template_visitor)
|
135
|
+
@files = %w[1 2 3 4]
|
136
|
+
Kernel.stub(:glob).with(path).and_return(@files)
|
137
|
+
@sut = Expansion.new
|
138
|
+
@sut.globber = lambda{|the_path|
|
139
|
+
the_path.should == path
|
140
|
+
return @files
|
141
|
+
}
|
142
|
+
end
|
143
|
+
before (:each) do
|
144
|
+
@sut.look_for_templates_in(path)
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should process each of the loaded templates using the template visitor" do
|
148
|
+
template_visitor.items.should == 4
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
context "when a before is specified" do
|
153
|
+
before (:each) do
|
134
154
|
@sut = Expansion.new
|
135
155
|
end
|
136
156
|
before (:each) do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: developwithpassion_expander
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-21 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &70364281720580 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70364281720580
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard
|
27
|
-
requirement: &
|
27
|
+
requirement: &70364281720080 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70364281720080
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard-rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70364281719500 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70364281719500
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: developwithpassion_fakes
|
49
|
-
requirement: &
|
49
|
+
requirement: &70364281718820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70364281718820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rb-notifu
|
60
|
-
requirement: &
|
60
|
+
requirement: &70364281718100 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70364281718100
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: configatron
|
71
|
-
requirement: &
|
71
|
+
requirement: &70364281717520 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70364281717520
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: mustache
|
82
|
-
requirement: &
|
82
|
+
requirement: &70364281716940 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,7 +87,7 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :runtime
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70364281716940
|
91
91
|
description: Automation utitlity that I use to support cross platform file maintenance
|
92
92
|
email:
|
93
93
|
- open_source@developwithpassion.com
|
@@ -173,7 +173,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
175
|
rubyforge_project: developwithpassion_expander
|
176
|
-
rubygems_version: 1.8.
|
176
|
+
rubygems_version: 1.8.15
|
177
177
|
signing_key:
|
178
178
|
specification_version: 3
|
179
179
|
summary: Simple Expansion Automation Utility
|