fudge 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YjM3NjNkZTE2YjE3ZjcxZjg0OTFlZTNiMzg4NTA1MTI4MjJjMTYyZg==
5
- data.tar.gz: !binary |-
6
- MDBkMDczNmI3ZGFhZGM1YjM4YTM0ZjNhNTViNTFlYzE1YWY5MTE3Mg==
2
+ SHA1:
3
+ metadata.gz: 71397d8944c4873910bdeaf7a2bde5306c83c48a
4
+ data.tar.gz: da1fbf7b677ee5674eaea1d7fee50a200dc5ba58
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- MjNjMWZlNGRmMjgwMGNhNGRiMDYyMDc5NzIyZTYwYzZkMTAxNzc3Njk2MjZj
10
- MmQ1YmYyNzc3NTJhNzRhYjkwZmQ0OWJmY2QwNzUwMDIyM2EyYmI3NTA3ZTYx
11
- MGIwZTQ3MDEwM2ZhYmZlYTZkNGNiZTIwMTE0ZmZkYjViMWNhMTM=
12
- data.tar.gz: !binary |-
13
- ZWEwZGUxN2YxMDhkMzNkM2VkNjYzY2FjNDIwOWM4OTlmY2Y5NTBmN2U0MjFh
14
- MmVkMjA3OWQ4Nzk1ZjJlNWZhNDk0OGExOTg5ZDVkNjk3NGZlYTVlZDdmMmMz
15
- NTc4OWQ2MDgxYjgwNzAzNDcwY2FiMjUzZDJjNmQxNWNkMmJhOTc=
6
+ metadata.gz: 39bfead33b001ff814a94b78c4a9a67fdbbc37dd16fe1e84edcd620869bfaf982baf7117812b1d03a5d0eeece96dbb58bfae0fe6eb8979101e4d4b95db8cfb79
7
+ data.tar.gz: e971f34d8b60543e9c6e30bb765991ade37368378f7f56e9c2a7b5be6db7fbf5f16aca469b0fb87c6630243bf45d6699fe5ceb3be2910d68ecff5427f7986e9e
@@ -2,8 +2,13 @@ module Fudge
2
2
  # Represents a build defined in the FudgeFile
3
3
  #
4
4
  class Build < Tasks::CompositeTask
5
+ # @!attribute about
6
+ # @return [String] a brief description of the build; this is
7
+ # output by the 'list' command
8
+ attr_accessor :about
5
9
  attr_accessor :callbacks
6
10
  attr_reader :success_hooks, :failure_hooks
11
+ attr_reader :description
7
12
 
8
13
  def initialize(*args)
9
14
  @success_hooks = []
@@ -7,7 +7,8 @@ module Fudge
7
7
  # Initalizes the blank Fudgefile
8
8
  def init
9
9
  generator = Fudge::Generator.new(Dir.pwd)
10
- generator.write_fudgefile
10
+ msg = generator.write_fudgefile
11
+ shell.say msg
11
12
  end
12
13
 
13
14
  desc "build [BUILD_NAME]",
@@ -19,5 +20,24 @@ module Fudge
19
20
  description = Fudge::Parser.new.parse('Fudgefile')
20
21
  Fudge::Runner.new(description).run_build(build_name, options)
21
22
  end
23
+
24
+ desc "list [FILTER]",
25
+ "List all builds defined in the Fudgefile that match FILTER (default: list all)"
26
+ # Lists builds defined in Fudgefile, with optional filtering.
27
+ #
28
+ # If given no filter, all builds are listed. If given a filter,
29
+ # lists builds whose names match the filter. Matching is based on
30
+ # sub-string matching and is case insensitive.
31
+ #
32
+ # The listing includes the build name, followed by the about
33
+ # string if one was specified in the Fudgefile.
34
+ #
35
+ # @param [String] filter a string by which to filter the builds listed
36
+ def list(filter="")
37
+ description = Fudge::Parser.new.parse('Fudgefile')
38
+ builds = description.builds.map { |name, build| ["#{name}", build.about] }
39
+ matches = builds.select { |name, _| name =~ /#{filter}/i }
40
+ shell.print_table(matches, :indent => 2, :truncate => true)
41
+ end
22
42
  end
23
43
  end
@@ -15,8 +15,8 @@ module Fudge
15
15
  end
16
16
 
17
17
  # Adds a build to the current description
18
- def build(name)
19
- @builds[name] = build = Build.new
18
+ def build(name, options={})
19
+ @builds[name] = build = Build.new(options)
20
20
  with_scope(build) { yield }
21
21
  end
22
22
 
@@ -10,10 +10,10 @@ module Fudge
10
10
  #Writes the fudgefile to initialized directory unless on present
11
11
  def write_fudgefile
12
12
  if exists?
13
- puts "Fudgefile already exists."
13
+ "Fudgefile already exists."
14
14
  else
15
15
  writer { |file| file << build_templated }
16
- puts "Fudgefile created."
16
+ "Fudgefile created."
17
17
  end
18
18
  end
19
19
 
@@ -1,4 +1,4 @@
1
1
  module Fudge
2
2
  # Define gem version
3
- VERSION = '0.4.1'
3
+ VERSION = '0.5.0'
4
4
  end
@@ -20,8 +20,7 @@ describe Fudge::Cli do
20
20
 
21
21
  describe :build do
22
22
  before :each do
23
- File.open('Fudgefile', 'w') do |f|
24
- contents = <<-RUBY
23
+ contents = <<-RUBY
25
24
  build :default do
26
25
  dummy
27
26
  end
@@ -30,47 +29,140 @@ describe Fudge::Cli do
30
29
  another_dummy
31
30
  end
32
31
  RUBY
33
- f.write(contents)
34
- end
32
+ file = double(File, read: contents, path: 'here')
33
+ File.stub(:open) { |&block| block.yield file }
35
34
  end
36
35
 
37
- it "should run the default build" do
38
- subject.build 'default'
39
- DummyTask.ran.should be_true
36
+ context "when not given a build name" do
37
+ it "runs the default build" do
38
+ subject.build 'default'
39
+ expect(DummyTask.ran).to be_true
40
+ end
40
41
  end
41
42
 
42
- it "should accept a build name to run" do
43
- subject.build 'other'
44
- DummyTask.ran.should be_false
45
- AnotherDummyTask.ran.should be_true
43
+ context "when given a build name" do
44
+ it "runs the only the named build" do
45
+ subject.build 'other'
46
+ expect(DummyTask.ran).to be_false
47
+ expect(AnotherDummyTask.ran).to be_true
48
+ end
46
49
  end
47
50
  end
48
51
 
49
52
  describe :init do
50
- it "should create a new FudgeFile in the current directory" do
51
- File.should_not be_exists('Fudgefile')
53
+ let (:file_state) { { exists: false, content: '' } }
54
+ let (:override_file_state) do
55
+ ->(exists, content) {
56
+ file_state[:exists] = exists
57
+ file_state[:content] = content
58
+ }
59
+ end
52
60
 
53
- subject.init
61
+ before :each do
62
+ file = double(File)
63
+ file.stub(:<<) { |str| file_state[:content] = str }
64
+ file.stub(:read) { file_state[:content] }
65
+ File.stub(:open) do |&block|
66
+ file_state[:exists] = true
67
+ block.yield file
68
+ end
69
+ File.stub(:exists?) { |_| file_state[:exists] }
54
70
 
55
- File.should be_exists('Fudgefile')
71
+ @output = ''
72
+ shell = double('Thor::Shell')
73
+ shell.stub(:say) { |what| @output = what }
74
+ subject.stub(:shell).and_return(shell)
56
75
  end
57
76
 
58
- it "should contain a default build" do
59
- subject.init
77
+ context "when a Fudgefile does not exist in the current directory" do
78
+ it "creates a new FudgeFile" do
79
+ expect(File).not_to be_exists('Fudgefile')
80
+
81
+ subject.init
82
+
83
+ expect(File).to be_exists('Fudgefile')
84
+ end
85
+
86
+ it "writes a default build into the new Fudgefile" do
87
+ subject.init
60
88
 
61
- File.open('Fudgefile', 'r') do |f|
62
- f.read.should eql "build :default do\n task :rspec\nend"
89
+ File.open('Fudgefile', 'r') do |f|
90
+ expect(f.read).to eql "build :default do\n task :rspec\nend"
91
+ end
92
+ end
93
+
94
+ it "outputs a success message" do
95
+ subject.init
96
+ expect(@output).to eq 'Fudgefile created.'
63
97
  end
64
98
  end
65
99
 
66
- it "should not modify the Fudgefile if one exists" do
67
- File.open('Fudgefile', 'w') do |f|
68
- f.write('foo')
100
+ context "when a Fudgefile already exists in the current directory" do
101
+ before :each do
102
+ override_file_state.(true, 'foo')
69
103
  end
70
104
 
71
- subject.init
105
+ it "does not modify the existing Fudgefile" do
106
+ expect(File).to be_exists('Fudgefile')
107
+
108
+ subject.init
109
+
110
+ expect(File.open('Fudgefile') { |f| f.read }).to eql 'foo'
111
+ end
72
112
 
73
- File.open('Fudgefile') { |f| f.read }.should == 'foo'
113
+ it "outputs a failure message" do
114
+ subject.init
115
+ expect(@output).to eq 'Fudgefile already exists.'
116
+ end
74
117
  end
75
118
  end
119
+
120
+ describe :list do
121
+ before :each do
122
+ contents = <<-RUBY
123
+ build :default do
124
+ dummy
125
+ end
126
+
127
+ build :other, :about => 'not the default' do
128
+ another_dummy
129
+ end
130
+ RUBY
131
+ file = double(File, read: contents, path: 'here')
132
+ File.stub(:open) { |&block| block.yield file }
133
+
134
+ @output = ''
135
+ shell = double('Thor::Shell')
136
+ shell.stub(:print_table) { |tab| @output = tab.map { |build, desc| "#{build}\t#{desc}" }.join("\n") }
137
+ subject.stub(:shell).and_return(shell)
138
+ end
139
+
140
+ context "when not given a filter string" do
141
+ it "lists all the defined builds" do
142
+ subject.list
143
+ expect(@output).to eql "default\t\nother\tnot the default"
144
+ end
145
+ end
146
+
147
+ context "when given a filter string" do
148
+ context "that matches one or builds" do
149
+ it "lists only the builds that match the filter" do
150
+ subject.list 'oth'
151
+ expect(@output).to eql "other\tnot the default"
152
+ end
153
+
154
+ it "ignores the case of the filter" do
155
+ subject.list 'OTH'
156
+ expect(@output).to eql "other\tnot the default"
157
+ end
158
+ end
159
+
160
+ context "that matches no builds" do
161
+ it "outputs nothing" do
162
+ expect(@output).to eql ''
163
+ end
164
+ end
165
+ end
166
+ end
167
+
76
168
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fudge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sage One team
@@ -14,252 +14,252 @@ dependencies:
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activesupport
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: json
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: redcarpet
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 2.8.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 2.8.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: guard-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rb-fsevent
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: yard
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: cane
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: flog
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: flay
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: ruby2ruby
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ! '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ! '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: RedCloth
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ! '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: simplecov
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ! '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '0'
202
202
  type: :development
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ! '>='
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  - !ruby/object:Gem::Dependency
210
210
  name: rb-inotify
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - ! '>='
213
+ - - ">="
214
214
  - !ruby/object:Gem::Version
215
215
  version: '0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - ! '>='
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
222
  version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: libnotify
225
225
  requirement: !ruby/object:Gem::Requirement
226
226
  requirements:
227
- - - ! '>='
227
+ - - ">="
228
228
  - !ruby/object:Gem::Version
229
229
  version: '0'
230
230
  type: :development
231
231
  prerelease: false
232
232
  version_requirements: !ruby/object:Gem::Requirement
233
233
  requirements:
234
- - - ! '>='
234
+ - - ">="
235
235
  - !ruby/object:Gem::Version
236
236
  version: '0'
237
237
  - !ruby/object:Gem::Dependency
238
238
  name: pry
239
239
  requirement: !ruby/object:Gem::Requirement
240
240
  requirements:
241
- - - ! '>='
241
+ - - ">="
242
242
  - !ruby/object:Gem::Version
243
243
  version: '0'
244
244
  type: :development
245
245
  prerelease: false
246
246
  version_requirements: !ruby/object:Gem::Requirement
247
247
  requirements:
248
- - - ! '>='
248
+ - - ">="
249
249
  - !ruby/object:Gem::Version
250
250
  version: '0'
251
251
  - !ruby/object:Gem::Dependency
252
252
  name: rake
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
- - - ! '>='
255
+ - - ">="
256
256
  - !ruby/object:Gem::Version
257
257
  version: '0'
258
258
  type: :development
259
259
  prerelease: false
260
260
  version_requirements: !ruby/object:Gem::Requirement
261
261
  requirements:
262
- - - ! '>='
262
+ - - ">="
263
263
  - !ruby/object:Gem::Version
264
264
  version: '0'
265
265
  description: Fudge Continuous Integration Server
@@ -341,12 +341,12 @@ require_paths:
341
341
  - lib
342
342
  required_ruby_version: !ruby/object:Gem::Requirement
343
343
  requirements:
344
- - - ! '>='
344
+ - - ">="
345
345
  - !ruby/object:Gem::Version
346
346
  version: '0'
347
347
  required_rubygems_version: !ruby/object:Gem::Requirement
348
348
  requirements:
349
- - - ! '>='
349
+ - - ">="
350
350
  - !ruby/object:Gem::Version
351
351
  version: '0'
352
352
  requirements: []