sniff 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sniff/rake_tasks.rb +81 -51
- metadata +3 -3
data/lib/sniff/rake_tasks.rb
CHANGED
@@ -11,21 +11,22 @@ require 'rocco/tasks'
|
|
11
11
|
module Sniff
|
12
12
|
class RakeTasks
|
13
13
|
def self.define_tasks(&blk)
|
14
|
-
new
|
14
|
+
new(&blk).define_tasks
|
15
15
|
end
|
16
16
|
|
17
|
-
attr_accessor :earth_domains
|
17
|
+
attr_accessor :earth_domains, :cucumber, :rspec, :rcov, :rocco
|
18
18
|
|
19
19
|
def initialize
|
20
|
+
self.earth_domains = :all
|
21
|
+
self.cucumber = true
|
22
|
+
self.rspec = false
|
23
|
+
self.rcov = true
|
24
|
+
self.rocco = true
|
20
25
|
yield self if block_given?
|
21
26
|
end
|
22
27
|
|
23
|
-
def earth_domains
|
24
|
-
@earth_domains ||= :all
|
25
|
-
end
|
26
|
-
|
27
28
|
def gemname
|
28
|
-
@gemname ||= Dir.glob(File.join(Dir.pwd, '*.gemspec')).first
|
29
|
+
@gemname ||= File.basename(Dir.glob(File.join(Dir.pwd, '*.gemspec')).first, '.gemspec')
|
29
30
|
end
|
30
31
|
|
31
32
|
def git(cmd, dir = nil, &blk)
|
@@ -46,69 +47,98 @@ module Sniff
|
|
46
47
|
IRB.start
|
47
48
|
end
|
48
49
|
|
49
|
-
|
50
|
+
if rocco
|
51
|
+
Rocco::make 'docs/', "lib/#{gemname}/carbon_model.rb"
|
52
|
+
|
53
|
+
desc 'Set up and build rocco docs'
|
54
|
+
task :docs_init => :rocco
|
55
|
+
|
56
|
+
desc 'Rebuild rocco docs'
|
57
|
+
task :docs => ['pages:sync', :rocco]
|
58
|
+
directory 'docs/'
|
59
|
+
|
60
|
+
desc 'Update gh-pages branch'
|
61
|
+
task :pages => :docs do
|
62
|
+
rev = `git rev-parse --short HEAD`.strip
|
63
|
+
git 'add *.html', 'docs'
|
64
|
+
git "commit -m 'rebuild pages from #{rev}'", 'docs' do |ok,res|
|
65
|
+
if ok
|
66
|
+
verbose { puts "gh-pages updated" }
|
67
|
+
git 'push -q o HEAD:gh-pages', 'docs' unless ENV['NO_PUSH']
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
50
71
|
|
51
|
-
|
52
|
-
|
72
|
+
# Update the pages/ directory clone
|
73
|
+
namespace :pages do
|
74
|
+
task 'sync' => ['.git/refs/heads/gh-pages', 'docs/.git/refs/remotes/o'] do |f|
|
75
|
+
git 'fetch -q o', 'docs'
|
76
|
+
git 'reset -q --hard o/gh-pages', 'docs'
|
77
|
+
sh 'touch docs'
|
78
|
+
end
|
53
79
|
|
54
|
-
|
55
|
-
|
56
|
-
|
80
|
+
file '.git/refs/heads/gh-pages' => 'docs/' do |f|
|
81
|
+
unless File.exist? f.name
|
82
|
+
git 'branch gh-pages --track origin/gh-pages', 'docs'
|
83
|
+
end
|
84
|
+
end
|
57
85
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
if ok
|
64
|
-
verbose { puts "gh-pages updated" }
|
65
|
-
git 'push -q o HEAD:gh-pages', 'docs' unless ENV['NO_PUSH']
|
86
|
+
file 'docs/.git/refs/remotes/o' => 'docs/' do |f|
|
87
|
+
unless File.exist? f.name
|
88
|
+
git 'init -q docs'
|
89
|
+
git 'remote add o ../.git', 'docs'
|
90
|
+
end
|
66
91
|
end
|
67
92
|
end
|
68
|
-
end
|
69
93
|
|
70
|
-
|
71
|
-
|
72
|
-
task 'sync' => ['.git/refs/heads/gh-pages', 'docs/.git/refs/remotes/o'] do |f|
|
73
|
-
git 'fetch -q o', 'docs'
|
74
|
-
git 'reset -q --hard o/gh-pages', 'docs'
|
75
|
-
sh 'touch docs'
|
76
|
-
end
|
94
|
+
CLOBBER.include 'docs/.git'
|
95
|
+
end
|
77
96
|
|
78
|
-
|
79
|
-
|
80
|
-
|
97
|
+
if cucumber
|
98
|
+
desc 'Run all cucumber tests'
|
99
|
+
Cucumber::Rake::Task.new(:features) do |t|
|
100
|
+
if ENV['CUCUMBER_FORMAT']
|
101
|
+
t.cucumber_opts = "features --format #{ENV['CUCUMBER_FORMAT']}"
|
102
|
+
else
|
103
|
+
t.cucumber_opts = 'features --format pretty'
|
81
104
|
end
|
82
105
|
end
|
83
106
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
107
|
+
if rcov
|
108
|
+
desc "Run cucumber tests with RCov"
|
109
|
+
Cucumber::Rake::Task.new(:features_with_coverage) do |t|
|
110
|
+
t.cucumber_opts = "features --format pretty"
|
111
|
+
t.rcov = true
|
112
|
+
t.rcov_opts = ['--exclude', 'features']
|
88
113
|
end
|
89
114
|
end
|
90
115
|
end
|
91
116
|
|
92
|
-
|
117
|
+
if rspec
|
118
|
+
require 'rspec/core/rake_task'
|
93
119
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
t.cucumber_opts = "features --format #{ENV['CUCUMBER_FORMAT']}"
|
98
|
-
else
|
99
|
-
t.cucumber_opts = 'features --format pretty'
|
120
|
+
desc "Run all examples"
|
121
|
+
RSpec::Core::RakeTask.new('examples') do |c|
|
122
|
+
c.rspec_opts = '-Ispec'
|
100
123
|
end
|
101
|
-
end
|
102
124
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
125
|
+
if rcov
|
126
|
+
desc "Run specs with RCov"
|
127
|
+
RSpec::Core::RakeTask.new(:examples_with_coverage) do |t|
|
128
|
+
t.rcov = true
|
129
|
+
t.rcov_opts = ['--exclude', 'spec']
|
130
|
+
t.rspec_opts = '-Ispec'
|
131
|
+
end
|
132
|
+
end
|
108
133
|
end
|
109
134
|
|
110
|
-
|
111
|
-
|
135
|
+
test_tasks = []
|
136
|
+
test_tasks << :examples if rspec
|
137
|
+
test_tasks << :features if cucumber
|
138
|
+
unless test_tasks.empty?
|
139
|
+
task :default => test_tasks.first
|
140
|
+
task :test => test_tasks
|
141
|
+
end
|
112
142
|
|
113
143
|
Rake::RDocTask.new do |rdoc|
|
114
144
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 4
|
8
|
-
-
|
9
|
-
version: 0.4.
|
8
|
+
- 2
|
9
|
+
version: 0.4.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Derek Kastner
|
@@ -327,7 +327,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
327
327
|
requirements:
|
328
328
|
- - ">="
|
329
329
|
- !ruby/object:Gem::Version
|
330
|
-
hash:
|
330
|
+
hash: -803188975
|
331
331
|
segments:
|
332
332
|
- 0
|
333
333
|
version: "0"
|