sniff 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,126 @@
1
+ require 'cucumber'
2
+ require 'cucumber/rake/task'
3
+ require 'rake'
4
+ require 'rake/clean'
5
+ require 'rake/rdoctask'
6
+ require 'rake/tasklib'
7
+ require 'rocco'
8
+ require 'rocco/tasks'
9
+
10
+
11
+ module Sniff
12
+ class RakeTasks
13
+ def self.define_tasks
14
+ new.define_tasks
15
+ end
16
+
17
+ attr_accessor :earth_domains
18
+
19
+ def initialize
20
+ yield self if block_given?
21
+
22
+ define_task
23
+ end
24
+
25
+ def earth_domains
26
+ @earth_domains ||= :all
27
+ end
28
+
29
+ def gemname
30
+ @gemname ||= Dir.glob(File.join(Dir.pwd, '*.gemspec')).first
31
+ end
32
+
33
+ def git(cmd, dir = nil, &blk)
34
+ full_cmd = ''
35
+ full_cmd << "cd #{dir} && " if dir
36
+ full_cmd << "unset GIT_DIR && unset GIT_INDEX_FILE && unset GIT_WORK_TREE && git #{cmd}"
37
+ sh full_cmd, &blk
38
+ end
39
+
40
+ private
41
+ def define_tasks
42
+ task :console do
43
+ require 'sniff'
44
+ cwd = Dir.pwd
45
+ Sniff.init cwd, :earth => earth_domains
46
+
47
+ require 'irb'
48
+ ARGV.clear
49
+ IRB.start
50
+ end
51
+
52
+ Rocco::make 'docs/', "lib/#{gemname}/carbon_model.rb"
53
+
54
+ desc 'Set up and build rocco docs'
55
+ task :docs_init => :rocco
56
+
57
+ desc 'Rebuild rocco docs'
58
+ task :docs => ['pages:sync', :rocco]
59
+ directory 'docs/'
60
+
61
+ desc 'Update gh-pages branch'
62
+ task :pages => :docs do
63
+ rev = `git rev-parse --short HEAD`.strip
64
+ git 'add *.html', 'docs'
65
+ git "commit -m 'rebuild pages from #{rev}'", 'docs' do |ok,res|
66
+ if ok
67
+ verbose { puts "gh-pages updated" }
68
+ git 'push -q o HEAD:gh-pages', 'docs' unless ENV['NO_PUSH']
69
+ end
70
+ end
71
+ end
72
+
73
+ # Update the pages/ directory clone
74
+ namespace :pages do
75
+ task 'sync' => ['.git/refs/heads/gh-pages', 'docs/.git/refs/remotes/o'] do |f|
76
+ git 'fetch -q o', 'docs'
77
+ git 'reset -q --hard o/gh-pages', 'docs'
78
+ sh 'touch docs'
79
+ end
80
+
81
+ file '.git/refs/heads/gh-pages' do |f|
82
+ unless File.exist? f.name
83
+ git 'branch gh-pages --track origin/gh-pages', 'docs'
84
+ end
85
+ end
86
+
87
+ file 'docs/.git/refs/remotes/o' do |f|
88
+ unless File.exist? f.name
89
+ git 'init -q docs'
90
+ git 'remote add o ../.git', 'docs'
91
+ end
92
+ end
93
+ end
94
+
95
+ CLOBBER.include 'docs/.git'
96
+
97
+ desc 'Run all cucumber tests'
98
+ Cucumber::Rake::Task.new(:features) do |t|
99
+ if ENV['CUCUMBER_FORMAT']
100
+ t.cucumber_opts = "features --format #{ENV['CUCUMBER_FORMAT']}"
101
+ else
102
+ t.cucumber_opts = 'features --format pretty'
103
+ end
104
+ end
105
+
106
+ desc "Run all tests with RCov"
107
+ Cucumber::Rake::Task.new(:features_with_coverage) do |t|
108
+ t.cucumber_opts = "features --format pretty"
109
+ t.rcov = true
110
+ t.rcov_opts = ['--exclude', 'features']
111
+ end
112
+
113
+ task :test => :features
114
+ task :default => :test
115
+
116
+ Rake::RDocTask.new do |rdoc|
117
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
118
+
119
+ rdoc.rdoc_dir = 'rdoc'
120
+ rdoc.title = "#{gemname} #{version}"
121
+ rdoc.rdoc_files.include('README*')
122
+ rdoc.rdoc_files.include('lib/**/*.rb')
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+ require 'sandbox'
3
+ require 'sniff/rake_tasks'
4
+
5
+ describe Sniff::RakeTasks do
6
+ def git(cmd, dir = nil, &blk)
7
+ full_cmd = ''
8
+ full_cmd << "cd #{dir} && " if dir
9
+ full_cmd << "unset GIT_DIR && unset GIT_INDEX_FILE && unset GIT_WORK_TREE && git #{cmd}"
10
+ `#{full_cmd}`
11
+ end
12
+
13
+ let(:tasks) { Sniff::RakeTask.new }
14
+ let(:emitter_path) { File.expand_path '../../../', File.dirname(__FILE__) }
15
+ let(:rakefile) do
16
+ rakefile = <<-RAKEFILE
17
+ require '#{emitter_path}/lib/sniff/rake_tasks'
18
+
19
+ Sniff::RakeTasks.define_tasks
20
+ RAKEFILE
21
+ end
22
+
23
+ describe '#define' do
24
+ describe 'docs task' do
25
+ it 'should generate docs' do
26
+ Sandbox.play do |path|
27
+ flight_path = File.join(path, 'flight')
28
+ git "clone git://github.com/brighterplanet/flight.git #{flight_path}"
29
+ File.open(File.join(flight_path, 'Rakefile'), 'w') do |f|
30
+ f.puts rakefile
31
+ end
32
+
33
+ `cd #{flight_path} && rake docs`
34
+ Dir.entries(File.join(flight_path, 'docs')).
35
+ count.should > 2
36
+ end
37
+ end
38
+ end
39
+
40
+ describe 'pages task' do
41
+ it 'should commit any changed doc files' do
42
+ Sandbox.play do |path|
43
+ flight_path = File.join(path, 'flight')
44
+ git "clone git://github.com/brighterplanet/flight.git #{flight_path}"
45
+ File.open(File.join(flight_path, 'Rakefile'), 'w') do |f|
46
+ f.puts rakefile
47
+ end
48
+
49
+ `cd #{flight_path} && mkdir docs && echo "<html>" > docs/foobar.html`
50
+ `cd #{flight_path} && NO_PUSH=true rake pages`
51
+
52
+ git('log -n 1', File.join(flight_path, 'docs')).
53
+ should =~ /rebuild pages/
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
59
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
8
- - 1
9
- version: 0.3.1
7
+ - 4
8
+ - 0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Derek Kastner
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-22 00:00:00 -05:00
17
+ date: 2010-11-23 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -78,7 +78,7 @@ dependencies:
78
78
  prerelease: false
79
79
  version_requirements: *id004
80
80
  - !ruby/object:Gem::Dependency
81
- name: earth
81
+ name: cucumber
82
82
  requirement: &id005 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
@@ -86,14 +86,14 @@ dependencies:
86
86
  - !ruby/object:Gem::Version
87
87
  segments:
88
88
  - 0
89
- - 3
90
- - 1
91
- version: 0.3.1
89
+ - 9
90
+ - 4
91
+ version: 0.9.4
92
92
  type: :runtime
93
93
  prerelease: false
94
94
  version_requirements: *id005
95
95
  - !ruby/object:Gem::Dependency
96
- name: fast_timestamp
96
+ name: earth
97
97
  requirement: &id006 !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
@@ -101,44 +101,44 @@ dependencies:
101
101
  - !ruby/object:Gem::Version
102
102
  segments:
103
103
  - 0
104
- - 0
105
- - 4
106
- version: 0.0.4
104
+ - 3
105
+ - 1
106
+ version: 0.3.1
107
107
  type: :runtime
108
108
  prerelease: false
109
109
  version_requirements: *id006
110
110
  - !ruby/object:Gem::Dependency
111
- name: sqlite3-ruby
111
+ name: fast_timestamp
112
112
  requirement: &id007 !ruby/object:Gem::Requirement
113
113
  none: false
114
114
  requirements:
115
115
  - - ~>
116
116
  - !ruby/object:Gem::Version
117
117
  segments:
118
- - 1
119
- - 3
120
118
  - 0
121
- version: 1.3.0
119
+ - 0
120
+ - 4
121
+ version: 0.0.4
122
122
  type: :runtime
123
123
  prerelease: false
124
124
  version_requirements: *id007
125
125
  - !ruby/object:Gem::Dependency
126
- name: timeframe
126
+ name: jeweler
127
127
  requirement: &id008 !ruby/object:Gem::Requirement
128
128
  none: false
129
129
  requirements:
130
130
  - - ~>
131
131
  - !ruby/object:Gem::Version
132
132
  segments:
133
+ - 1
134
+ - 4
133
135
  - 0
134
- - 0
135
- - 8
136
- version: 0.0.8
136
+ version: 1.4.0
137
137
  type: :runtime
138
138
  prerelease: false
139
139
  version_requirements: *id008
140
140
  - !ruby/object:Gem::Dependency
141
- name: bundler
141
+ name: rake
142
142
  requirement: &id009 !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,11 +147,11 @@ dependencies:
147
147
  segments:
148
148
  - 0
149
149
  version: "0"
150
- type: :development
150
+ type: :runtime
151
151
  prerelease: false
152
152
  version_requirements: *id009
153
153
  - !ruby/object:Gem::Dependency
154
- name: emitter
154
+ name: rcov
155
155
  requirement: &id010 !ruby/object:Gem::Requirement
156
156
  none: false
157
157
  requirements:
@@ -160,26 +160,24 @@ dependencies:
160
160
  segments:
161
161
  - 0
162
162
  version: "0"
163
- type: :development
163
+ type: :runtime
164
164
  prerelease: false
165
165
  version_requirements: *id010
166
166
  - !ruby/object:Gem::Dependency
167
- name: jeweler
167
+ name: rdoc
168
168
  requirement: &id011 !ruby/object:Gem::Requirement
169
169
  none: false
170
170
  requirements:
171
- - - ~>
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  segments:
174
- - 1
175
- - 4
176
174
  - 0
177
- version: 1.4.0
178
- type: :development
175
+ version: "0"
176
+ type: :runtime
179
177
  prerelease: false
180
178
  version_requirements: *id011
181
179
  - !ruby/object:Gem::Dependency
182
- name: rake
180
+ name: rocco
183
181
  requirement: &id012 !ruby/object:Gem::Requirement
184
182
  none: false
185
183
  requirements:
@@ -188,12 +186,42 @@ dependencies:
188
186
  segments:
189
187
  - 0
190
188
  version: "0"
191
- type: :development
189
+ type: :runtime
192
190
  prerelease: false
193
191
  version_requirements: *id012
194
192
  - !ruby/object:Gem::Dependency
195
- name: rcov
193
+ name: sqlite3-ruby
196
194
  requirement: &id013 !ruby/object:Gem::Requirement
195
+ none: false
196
+ requirements:
197
+ - - ~>
198
+ - !ruby/object:Gem::Version
199
+ segments:
200
+ - 1
201
+ - 3
202
+ - 0
203
+ version: 1.3.0
204
+ type: :runtime
205
+ prerelease: false
206
+ version_requirements: *id013
207
+ - !ruby/object:Gem::Dependency
208
+ name: timeframe
209
+ requirement: &id014 !ruby/object:Gem::Requirement
210
+ none: false
211
+ requirements:
212
+ - - ~>
213
+ - !ruby/object:Gem::Version
214
+ segments:
215
+ - 0
216
+ - 0
217
+ - 8
218
+ version: 0.0.8
219
+ type: :runtime
220
+ prerelease: false
221
+ version_requirements: *id014
222
+ - !ruby/object:Gem::Dependency
223
+ name: bundler
224
+ requirement: &id015 !ruby/object:Gem::Requirement
197
225
  none: false
198
226
  requirements:
199
227
  - - ">="
@@ -203,10 +231,10 @@ dependencies:
203
231
  version: "0"
204
232
  type: :development
205
233
  prerelease: false
206
- version_requirements: *id013
234
+ version_requirements: *id015
207
235
  - !ruby/object:Gem::Dependency
208
- name: rdoc
209
- requirement: &id014 !ruby/object:Gem::Requirement
236
+ name: emitter
237
+ requirement: &id016 !ruby/object:Gem::Requirement
210
238
  none: false
211
239
  requirements:
212
240
  - - ">="
@@ -216,10 +244,10 @@ dependencies:
216
244
  version: "0"
217
245
  type: :development
218
246
  prerelease: false
219
- version_requirements: *id014
247
+ version_requirements: *id016
220
248
  - !ruby/object:Gem::Dependency
221
249
  name: rspec
222
- requirement: &id015 !ruby/object:Gem::Requirement
250
+ requirement: &id017 !ruby/object:Gem::Requirement
223
251
  none: false
224
252
  requirements:
225
253
  - - ~>
@@ -233,8 +261,21 @@ dependencies:
233
261
  version: 2.0.0.beta.17
234
262
  type: :development
235
263
  prerelease: false
236
- version_requirements: *id015
237
- description: Provides data environment for emitter gems
264
+ version_requirements: *id017
265
+ - !ruby/object:Gem::Dependency
266
+ name: sandbox
267
+ requirement: &id018 !ruby/object:Gem::Requirement
268
+ none: false
269
+ requirements:
270
+ - - ">="
271
+ - !ruby/object:Gem::Version
272
+ segments:
273
+ - 0
274
+ version: "0"
275
+ type: :development
276
+ prerelease: false
277
+ version_requirements: *id018
278
+ description: Provides development and test environment for emitter gems
238
279
  email: derek.kastner@brighterplanet.com
239
280
  executables: []
240
281
 
@@ -246,7 +287,7 @@ files:
246
287
  - lib/sniff.rb
247
288
  - lib/sniff/database.rb
248
289
  - lib/sniff/emitter.rb
249
- - lib/sniff/rake_task.rb
290
+ - lib/sniff/rake_tasks.rb
250
291
  - lib/test_support/cucumber/step_definitions/carbon_steps.rb
251
292
  - lib/test_support/cucumber/step_definitions/committee_steps.rb
252
293
  - lib/test_support/cucumber/support/values.rb
@@ -270,6 +311,7 @@ files:
270
311
  - spec/fixtures/dirigible/lib/dirigible.rb
271
312
  - spec/lib/test_support/cucumber/support/values_spec.rb
272
313
  - spec/lib/sniff/database_spec.rb
314
+ - spec/lib/sniff/rake_tasks_spec.rb
273
315
  - spec/spec_helper.rb
274
316
  has_rdoc: true
275
317
  homepage: http://github.com/brighterplanet/sniff
@@ -285,7 +327,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
285
327
  requirements:
286
328
  - - ">="
287
329
  - !ruby/object:Gem::Version
288
- hash: -446310847
330
+ hash: 289042547
289
331
  segments:
290
332
  - 0
291
333
  version: "0"
@@ -313,6 +355,7 @@ test_files:
313
355
  - spec/fixtures/dirigible/lib/dirigible.rb
314
356
  - spec/lib/test_support/cucumber/support/values_spec.rb
315
357
  - spec/lib/sniff/database_spec.rb
358
+ - spec/lib/sniff/rake_tasks_spec.rb
316
359
  - spec/spec_helper.rb
317
360
  - lib/test_support/cucumber/support/values.rb
318
361
  - lib/test_support/cucumber/step_definitions/carbon_steps.rb
@@ -1,28 +0,0 @@
1
- module Sniff
2
- class RakeTask
3
- attr_accessor :earth_domains
4
-
5
- def initialize(name = 'console', desc = 'Load IRB console with Sniff environment')
6
- yield self if block_given?
7
-
8
- define_task
9
- end
10
-
11
- def earth_domains
12
- @earth_domains ||= :all
13
- end
14
-
15
- private
16
- def define_task
17
- task :console do
18
- require 'sniff'
19
- cwd = Dir.pwd
20
- Sniff.init cwd, :earth => earth_domains
21
-
22
- require 'irb'
23
- ARGV.clear
24
- IRB.start
25
- end
26
- end
27
- end
28
- end