rake_shared_context 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +5 -0
- data/README.md +4 -1
- data/Rakefile +5 -0
- data/lib/rake_shared_context/version.rb +2 -2
- data/lib/rake_shared_context.rb +38 -3
- data/rake_shared_context.gemspec +3 -1
- data/spec/lib/report_generator.rb +5 -0
- data/spec/lib/tasks/reports.rake +11 -0
- data/spec/paths_spec.rb +40 -0
- data/spec/rake_spec.rb +18 -0
- data/spec/spec_helper.rb +2 -0
- metadata +45 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ee7b1d5e1b0c45048706fe8296c9c6d29f13d16
|
4
|
+
data.tar.gz: e7eaf7bc32c862e1ba8dc7eba1689094a3766820
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 76b730d776b8cb5f069f9c36ff01d6cc0d288663e93a26ec8b4129729377fd868d0a9e5a8bacfd40e704aa33cc38029a47ee61d3ccc09a2f76e3d1912f68fa8d
|
7
|
+
data.tar.gz: 7e93a4c7555070524e924a3d310ad5dc33175fe8e6853742a23eb02816b550d3977034c78624205345096626baeaceda5b101f91ed77227c5afd534229a312ca
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# RakeSharedContext
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/willnet/gimei.png)](https://travis-ci.org/willnet/rake_shared_context)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rake_shared_context.png)](http://badge.fury.io/rb/rake_shared_context)
|
5
|
+
|
3
6
|
shared_context for rake tasks.
|
4
7
|
|
5
8
|
This gem is inspired by [this post](http://robots.thoughtbot.com/post/11957424161/test-rake-tasks-like-a-boss).
|
@@ -39,7 +42,7 @@ Then you can write following.
|
|
39
42
|
# spec/lib/tasks/reports_rake_spec.rb
|
40
43
|
|
41
44
|
require 'spec_helper'
|
42
|
-
describe "reports:
|
45
|
+
describe "reports:generate" do
|
43
46
|
include_context "rake"
|
44
47
|
|
45
48
|
its(:prerequisites) { should include("environment") }
|
data/Rakefile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0
|
1
|
+
class RakeSharedContext
|
2
|
+
VERSION = "0.1.0"
|
3
3
|
end
|
data/lib/rake_shared_context.rb
CHANGED
@@ -1,5 +1,37 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
1
2
|
require "rake_shared_context/version"
|
2
3
|
require "rake"
|
4
|
+
require "pathname"
|
5
|
+
|
6
|
+
class RakeSharedContext
|
7
|
+
class << self
|
8
|
+
def root_dir
|
9
|
+
return @root_dir if @root_dir
|
10
|
+
|
11
|
+
if defined? Rails
|
12
|
+
Rails.root
|
13
|
+
elsif defined? Padrino
|
14
|
+
Pathname.new(Padrino.root)
|
15
|
+
else
|
16
|
+
Pathname.pwd
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def root_dir=(dir)
|
21
|
+
@root_dir = Pathname.new(dir)
|
22
|
+
end
|
23
|
+
|
24
|
+
def rake_dir
|
25
|
+
return @rake_dir if @rake_dir
|
26
|
+
|
27
|
+
root_dir.join('lib', 'tasks')
|
28
|
+
end
|
29
|
+
|
30
|
+
def rake_dir=(dir)
|
31
|
+
@rake_dir = Pathname.new(dir)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
3
35
|
|
4
36
|
begin
|
5
37
|
require "rspec/core"
|
@@ -11,10 +43,13 @@ begin
|
|
11
43
|
before do
|
12
44
|
loaded_files = []
|
13
45
|
Rake.application = rake
|
14
|
-
|
15
|
-
|
46
|
+
rake_dir = RakeSharedContext.rake_dir
|
47
|
+
|
48
|
+
Dir.glob(rake_dir.join("*.rake")).each do |task|
|
49
|
+
filename_without_ext = File.basename(task.sub(/.rake$/, ''))
|
50
|
+
Rake.application.rake_require(filename_without_ext, [rake_dir.to_s], loaded_files)
|
16
51
|
end
|
17
|
-
|
52
|
+
|
18
53
|
Rake::Task.define_task(:environment)
|
19
54
|
end
|
20
55
|
end
|
data/rake_shared_context.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["netwillnet@gmail.com"]
|
7
7
|
gem.description = %q{shared_context for rake task}
|
8
8
|
gem.summary = %q{shared_context for rake task}
|
9
|
-
gem.homepage = ""
|
9
|
+
gem.homepage = "https://github.com/willnet/rake_shared_context"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -14,5 +14,7 @@ Gem::Specification.new do |gem|
|
|
14
14
|
gem.name = "rake_shared_context"
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = RakeSharedContext::VERSION
|
17
|
+
gem.add_development_dependency "rake"
|
17
18
|
gem.add_development_dependency "rspec"
|
19
|
+
gem.add_development_dependency "pry"
|
18
20
|
end
|
data/spec/paths_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
describe RakeSharedContext do
|
2
|
+
describe '.root_dir' do
|
3
|
+
after do
|
4
|
+
RakeSharedContext.instance_variable_set(:@root_dir, nil)
|
5
|
+
end
|
6
|
+
|
7
|
+
context '`.root_dir=` was executed before' do
|
8
|
+
it 'should return the root_dir' do
|
9
|
+
RakeSharedContext.root_dir = 'foo'
|
10
|
+
expect(RakeSharedContext.root_dir).to eq Pathname.new('foo')
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
context '`.root_dir=` was not executed before' do
|
15
|
+
context 'Rails.root is defined' do
|
16
|
+
before { Rails = double('Rails', root: 'rails') }
|
17
|
+
after { Object.send(:remove_const, :Rails) }
|
18
|
+
|
19
|
+
it 'should return `Rails.root`' do
|
20
|
+
expect(RakeSharedContext.root_dir).to eq 'rails'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'Padrino.root is defined' do
|
25
|
+
before { Padrino = double('Padrino', root: 'padrino') }
|
26
|
+
after { Object.send(:remove_const, :Padrino) }
|
27
|
+
|
28
|
+
it 'should return `Padrino.root`' do
|
29
|
+
expect(RakeSharedContext.root_dir).to eq Pathname.new('padrino')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'nothing is defined' do
|
34
|
+
it 'should return current directory' do
|
35
|
+
expect(RakeSharedContext.root_dir).to eq Pathname.pwd
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/spec/rake_spec.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'lib/report_generator'
|
3
|
+
|
4
|
+
describe "reports:generate" do
|
5
|
+
before do
|
6
|
+
RakeSharedContext.root_dir = File.expand_path('..', __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
include_context "rake"
|
10
|
+
|
11
|
+
its(:prerequisites) { should include("environment") }
|
12
|
+
|
13
|
+
it "generates the report" do
|
14
|
+
ReportGenerator.should_receive(:generate)
|
15
|
+
subject.invoke
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rake_shared_context
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- willnet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: rspec
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -24,6 +38,20 @@ dependencies:
|
|
24
38
|
- - '>='
|
25
39
|
- !ruby/object:Gem::Version
|
26
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
27
55
|
description: shared_context for rake task
|
28
56
|
email:
|
29
57
|
- netwillnet@gmail.com
|
@@ -32,6 +60,7 @@ extensions: []
|
|
32
60
|
extra_rdoc_files: []
|
33
61
|
files:
|
34
62
|
- .gitignore
|
63
|
+
- .travis.yml
|
35
64
|
- CHANGELOG.md
|
36
65
|
- Gemfile
|
37
66
|
- LICENSE
|
@@ -40,7 +69,12 @@ files:
|
|
40
69
|
- lib/rake_shared_context.rb
|
41
70
|
- lib/rake_shared_context/version.rb
|
42
71
|
- rake_shared_context.gemspec
|
43
|
-
|
72
|
+
- spec/lib/report_generator.rb
|
73
|
+
- spec/lib/tasks/reports.rake
|
74
|
+
- spec/paths_spec.rb
|
75
|
+
- spec/rake_spec.rb
|
76
|
+
- spec/spec_helper.rb
|
77
|
+
homepage: https://github.com/willnet/rake_shared_context
|
44
78
|
licenses: []
|
45
79
|
metadata: {}
|
46
80
|
post_install_message:
|
@@ -59,8 +93,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
93
|
version: '0'
|
60
94
|
requirements: []
|
61
95
|
rubyforge_project:
|
62
|
-
rubygems_version: 2.0.
|
96
|
+
rubygems_version: 2.0.3
|
63
97
|
signing_key:
|
64
98
|
specification_version: 4
|
65
99
|
summary: shared_context for rake task
|
66
|
-
test_files:
|
100
|
+
test_files:
|
101
|
+
- spec/lib/report_generator.rb
|
102
|
+
- spec/lib/tasks/reports.rake
|
103
|
+
- spec/paths_spec.rb
|
104
|
+
- spec/rake_spec.rb
|
105
|
+
- spec/spec_helper.rb
|
106
|
+
has_rdoc:
|