rake-version 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -6
- data/LICENSE.txt +1 -1
- data/README.md +83 -9
- data/VERSION +1 -1
- data/lib/rake-version.rb +1 -4
- data/lib/rake-version/config.rb +1 -2
- data/lib/rake-version/context.rb +3 -14
- data/lib/rake-version/copier.rb +4 -18
- data/lib/rake-version/manager.rb +3 -3
- data/lib/rake-version/tasks.rb +36 -7
- data/lib/rake-version/version.rb +8 -9
- metadata +11 -39
- data/.document +0 -5
- data/.rspec +0 -2
- data/.rvmrc +0 -41
- data/.screenrc +0 -5
- data/.travis.yml +0 -5
- data/Gemfile.lock +0 -51
- data/Rakefile +0 -58
- data/rake-version.gemspec +0 -89
- data/spec/config_spec.rb +0 -68
- data/spec/context_spec.rb +0 -48
- data/spec/copier_spec.rb +0 -185
- data/spec/helper.rb +0 -21
- data/spec/manager_spec.rb +0 -117
- data/spec/tasks_spec.rb +0 -57
- data/spec/version_spec.rb +0 -73
data/.document
DELETED
data/.rspec
DELETED
data/.rvmrc
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
#!/usr/bin/env bash
|
2
|
-
|
3
|
-
# This is an RVM Project .rvmrc file, used to automatically load the ruby
|
4
|
-
# development environment upon cd'ing into the directory
|
5
|
-
|
6
|
-
# First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
|
7
|
-
environment_id="ruby-1.9.3@rake-version"
|
8
|
-
|
9
|
-
#
|
10
|
-
# First we attempt to load the desired environment directly from the environment
|
11
|
-
# file. This is very fast and efficicent compared to running through the entire
|
12
|
-
# CLI and selector. If you want feedback on which environment was used then
|
13
|
-
# insert the word 'use' after --create as this triggers verbose mode.
|
14
|
-
#
|
15
|
-
if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
|
16
|
-
&& -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
|
17
|
-
then
|
18
|
-
\. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
|
19
|
-
|
20
|
-
if [[ -s ".rvm/hooks/after_use" ]]
|
21
|
-
then
|
22
|
-
. ".rvm/hooks/after_use"
|
23
|
-
fi
|
24
|
-
else
|
25
|
-
# If the environment file has not yet been created, use the RVM CLI to select.
|
26
|
-
if ! rvm --create "$environment_id"
|
27
|
-
then
|
28
|
-
echo "Failed to create RVM environment ''."
|
29
|
-
fi
|
30
|
-
fi
|
31
|
-
|
32
|
-
#
|
33
|
-
# If you use an RVM gemset file to install a list of gems (*.gems), you can have
|
34
|
-
# it be automatically loaded. Uncomment the following and adjust the filename if
|
35
|
-
# necessary.
|
36
|
-
#
|
37
|
-
# filename=".gems"
|
38
|
-
# if [[ -s "$filename" ]] ; then
|
39
|
-
# rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
|
40
|
-
# fi
|
41
|
-
|
data/.screenrc
DELETED
data/.travis.yml
DELETED
data/Gemfile.lock
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
active_support (3.0.0)
|
5
|
-
activesupport (= 3.0.0)
|
6
|
-
activesupport (3.0.0)
|
7
|
-
diff-lcs (1.1.3)
|
8
|
-
gem-release (0.4.1)
|
9
|
-
git (1.2.5)
|
10
|
-
hashr (0.0.22)
|
11
|
-
jeweler (1.8.4)
|
12
|
-
bundler (~> 1.0)
|
13
|
-
git (>= 1.2.5)
|
14
|
-
rake
|
15
|
-
rdoc
|
16
|
-
json (1.7.6)
|
17
|
-
multi_json (1.5.0)
|
18
|
-
rake (10.0.3)
|
19
|
-
rdiscount (2.0.7)
|
20
|
-
rdoc (3.12)
|
21
|
-
json (~> 1.4)
|
22
|
-
rspec (2.12.0)
|
23
|
-
rspec-core (~> 2.12.0)
|
24
|
-
rspec-expectations (~> 2.12.0)
|
25
|
-
rspec-mocks (~> 2.12.0)
|
26
|
-
rspec-core (2.12.2)
|
27
|
-
rspec-expectations (2.12.1)
|
28
|
-
diff-lcs (~> 1.1.3)
|
29
|
-
rspec-mocks (2.12.2)
|
30
|
-
simplecov (0.7.1)
|
31
|
-
multi_json (~> 1.0)
|
32
|
-
simplecov-html (~> 0.7.1)
|
33
|
-
simplecov-html (0.7.1)
|
34
|
-
travis-lint (1.6.0)
|
35
|
-
hashr (~> 0.0.22)
|
36
|
-
yard (0.8.3)
|
37
|
-
|
38
|
-
PLATFORMS
|
39
|
-
ruby
|
40
|
-
|
41
|
-
DEPENDENCIES
|
42
|
-
active_support
|
43
|
-
bundler
|
44
|
-
gem-release
|
45
|
-
jeweler
|
46
|
-
rake (~> 10)
|
47
|
-
rdiscount
|
48
|
-
rspec
|
49
|
-
simplecov
|
50
|
-
travis-lint
|
51
|
-
yard
|
data/Rakefile
DELETED
@@ -1,58 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "rake-version"
|
18
|
-
gem.homepage = "http://github.com/AlphaHydrae/rake-version"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Rake tasks for version management.}
|
21
|
-
gem.description = %Q{Rake tasks for version management.}
|
22
|
-
gem.email = "hydrae.alpha@gmail.com"
|
23
|
-
gem.authors = ["AlphaHydrae"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rspec/core/rake_task'
|
29
|
-
desc "Run specs"
|
30
|
-
RSpec::Core::RakeTask.new do |t|
|
31
|
-
#t.pattern = "./spec/**/*_spec.rb" # don't need this, it's default.
|
32
|
-
# Put spec opts in a file named .rspec in root
|
33
|
-
end
|
34
|
-
|
35
|
-
task :default => :spec
|
36
|
-
|
37
|
-
desc "Generate documentation"
|
38
|
-
task :doc => ['doc:generate']
|
39
|
-
namespace :doc do
|
40
|
-
project_root = File.dirname __FILE__
|
41
|
-
doc_destination = File.join project_root, 'doc'
|
42
|
-
|
43
|
-
begin
|
44
|
-
require 'yard'
|
45
|
-
require 'yard/rake/yardoc_task'
|
46
|
-
|
47
|
-
YARD::Rake::YardocTask.new(:generate) do |yt|
|
48
|
-
yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
|
49
|
-
[ File.join(project_root, 'README.md') ]
|
50
|
-
yt.options = ['--output-dir', doc_destination, '--readme', 'README.md', '--private', '--protected']
|
51
|
-
end
|
52
|
-
rescue LoadError
|
53
|
-
desc "Generate YARD Documentation"
|
54
|
-
task :generate do
|
55
|
-
abort "Please install the YARD gem to generate rdoc."
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
data/rake-version.gemspec
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = "rake-version"
|
8
|
-
s.version = "0.3.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["AlphaHydrae"]
|
12
|
-
s.date = "2013-02-04"
|
13
|
-
s.description = "Rake tasks for version management."
|
14
|
-
s.email = "hydrae.alpha@gmail.com"
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE.txt",
|
17
|
-
"README.md"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".document",
|
21
|
-
".rspec",
|
22
|
-
".rvmrc",
|
23
|
-
".screenrc",
|
24
|
-
".travis.yml",
|
25
|
-
"Gemfile",
|
26
|
-
"Gemfile.lock",
|
27
|
-
"LICENSE.txt",
|
28
|
-
"README.md",
|
29
|
-
"Rakefile",
|
30
|
-
"VERSION",
|
31
|
-
"lib/rake-version.rb",
|
32
|
-
"lib/rake-version/config.rb",
|
33
|
-
"lib/rake-version/context.rb",
|
34
|
-
"lib/rake-version/copier.rb",
|
35
|
-
"lib/rake-version/manager.rb",
|
36
|
-
"lib/rake-version/tasks.rb",
|
37
|
-
"lib/rake-version/version.rb",
|
38
|
-
"rake-version.gemspec",
|
39
|
-
"spec/config_spec.rb",
|
40
|
-
"spec/context_spec.rb",
|
41
|
-
"spec/copier_spec.rb",
|
42
|
-
"spec/helper.rb",
|
43
|
-
"spec/manager_spec.rb",
|
44
|
-
"spec/tasks_spec.rb",
|
45
|
-
"spec/version_spec.rb"
|
46
|
-
]
|
47
|
-
s.homepage = "http://github.com/AlphaHydrae/rake-version"
|
48
|
-
s.licenses = ["MIT"]
|
49
|
-
s.require_paths = ["lib"]
|
50
|
-
s.rubygems_version = "1.8.25"
|
51
|
-
s.summary = "Rake tasks for version management."
|
52
|
-
|
53
|
-
if s.respond_to? :specification_version then
|
54
|
-
s.specification_version = 3
|
55
|
-
|
56
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
57
|
-
s.add_runtime_dependency(%q<rake>, ["~> 10"])
|
58
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
60
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
61
|
-
s.add_development_dependency(%q<gem-release>, [">= 0"])
|
62
|
-
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
63
|
-
s.add_development_dependency(%q<yard>, [">= 0"])
|
64
|
-
s.add_development_dependency(%q<rdiscount>, [">= 0"])
|
65
|
-
s.add_development_dependency(%q<travis-lint>, [">= 0"])
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<rake>, ["~> 10"])
|
68
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
69
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
70
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
71
|
-
s.add_dependency(%q<gem-release>, [">= 0"])
|
72
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
74
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
75
|
-
s.add_dependency(%q<travis-lint>, [">= 0"])
|
76
|
-
end
|
77
|
-
else
|
78
|
-
s.add_dependency(%q<rake>, ["~> 10"])
|
79
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
80
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
81
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
82
|
-
s.add_dependency(%q<gem-release>, [">= 0"])
|
83
|
-
s.add_dependency(%q<simplecov>, [">= 0"])
|
84
|
-
s.add_dependency(%q<yard>, [">= 0"])
|
85
|
-
s.add_dependency(%q<rdiscount>, [">= 0"])
|
86
|
-
s.add_dependency(%q<travis-lint>, [">= 0"])
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
data/spec/config_spec.rb
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe RakeVersion::Config do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
@config = RakeVersion::Config.new
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should be an open structure" do
|
10
|
-
lambda{ @config.fubar = true }.should_not raise_error
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'Copiers' do
|
14
|
-
|
15
|
-
it "should not have any copiers by default" do
|
16
|
-
@config.copiers.should be_empty
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should correctly create copiers" do
|
20
|
-
copiers = [
|
21
|
-
[],
|
22
|
-
[ 'src/**/*.js' ],
|
23
|
-
[ /src\/.*\.sh/ ],
|
24
|
-
[ 'src/example.js', 'src/example.rb' ],
|
25
|
-
[ 'src/**/*.rb', { :all => true } ]
|
26
|
-
]
|
27
|
-
copiers.each do |args|
|
28
|
-
lambda{ @config.copy *args }.should_not raise_error
|
29
|
-
end
|
30
|
-
@config.copiers.length.should == copiers.length
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should create copiers with a ruby extension glob by default" do
|
34
|
-
RakeVersion::Copier.should_receive(:new).with('src/**/*.rb')
|
35
|
-
@config.copy
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should return itself when creating a copier" do
|
39
|
-
@config.copy.should === @config
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return a copy of its copiers array" do
|
43
|
-
@config.copy
|
44
|
-
@config.copiers.clear
|
45
|
-
@config.copiers.length.should == 1
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe 'Extension' do
|
50
|
-
|
51
|
-
it "should have the ruby extension by default" do
|
52
|
-
@config.extension.should == 'rb'
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should accept alphanumerical extensions" do
|
56
|
-
[ :rb, 'js', :sh, 'py', double('extension', :to_s => 'java') ].each do |ext|
|
57
|
-
lambda{ @config.extension = ext }.should_not raise_error
|
58
|
-
@config.extension.should == ext.to_s
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should not accept non-alphanumerical extensions" do
|
63
|
-
[ nil, '.', :_, [], {}, double('fubar') ].each do |invalid|
|
64
|
-
lambda{ @config.extension = invalid }.should raise_error(StandardError)
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
data/spec/context_spec.rb
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe RakeVersion::Context do
|
4
|
-
CONTEXT_SAMPLE_ROOT = '/tmp'
|
5
|
-
|
6
|
-
before :each do
|
7
|
-
|
8
|
-
@application = double('application')
|
9
|
-
@application.stub(:original_dir){ CONTEXT_SAMPLE_ROOT }
|
10
|
-
|
11
|
-
@task = double('task')
|
12
|
-
@task.stub(:application){ @application }
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should return the application directory for the given rake task" do
|
16
|
-
RakeVersion::Context.new(@task).root.should == CONTEXT_SAMPLE_ROOT
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should successfully read file contents" do
|
20
|
-
|
21
|
-
filename = 'foo'
|
22
|
-
contents = 'bar'
|
23
|
-
|
24
|
-
File.stub(:open) do |file,mode|
|
25
|
-
if mode == 'r' and file == filename
|
26
|
-
double('file').tap{ |f| f.stub(:read){ contents } }
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
RakeVersion::Context.new(@task).read(filename).should == contents
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should ask File to write file contents" do
|
34
|
-
|
35
|
-
filename = 'foo'
|
36
|
-
contents = 'bar'
|
37
|
-
|
38
|
-
file = double('file')
|
39
|
-
file.stub(:write)
|
40
|
-
|
41
|
-
File.stub(:open) do |f,mode|
|
42
|
-
raise 'bug' unless f == filename and mode == 'w'
|
43
|
-
end.and_yield file
|
44
|
-
|
45
|
-
file.should_receive(:write).with(contents)
|
46
|
-
RakeVersion::Context.new(@task).write(filename, contents)
|
47
|
-
end
|
48
|
-
end
|
data/spec/copier_spec.rb
DELETED
@@ -1,185 +0,0 @@
|
|
1
|
-
require 'helper'
|
2
|
-
|
3
|
-
describe RakeVersion::Copier do
|
4
|
-
|
5
|
-
it "should require no arguments" do
|
6
|
-
lambda{ RakeVersion::Copier.new }.should_not raise_error
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should accept glob strings and regexps as arguments" do
|
10
|
-
[
|
11
|
-
[ 'src/**/*.js' ],
|
12
|
-
[ /src\/.*\.sh/ ],
|
13
|
-
[ 'src/example.js', 'src/example.rb' ],
|
14
|
-
[ 'src/example.sh', /src\/.*\.java/, 'src/**/*.py' ]
|
15
|
-
].each do |args|
|
16
|
-
lambda{ RakeVersion::Copier.new *args }.should_not raise_error
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should only accept glob strings and regexps as arguments" do
|
21
|
-
# we do not test a hash, as it is valid to pass an options hash
|
22
|
-
[ nil, true, false, [], Object.new, :symbol ].each do |invalid|
|
23
|
-
lambda{ RakeVersion::Copier.new invalid }.should raise_error(RakeVersion::BadFilePattern)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should take options" do
|
28
|
-
lambda{ RakeVersion::Copier.new :option1 => true, :option2 => false }.should_not raise_error
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should accept a regexp as the version option" do
|
32
|
-
lambda{ RakeVersion::Copier.new :version => /version/ }.should_not raise_error
|
33
|
-
lambda{ RakeVersion::Copier.new 'version' => /version/ }.should_not raise_error
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should only accept a regexp as the version option" do
|
37
|
-
[ true, false, [], {}, Object.new, :symbol ].each do |invalid|
|
38
|
-
lambda{ RakeVersion::Copier.new :version => invalid }.should raise_error(RakeVersion::BadVersionPattern)
|
39
|
-
lambda{ RakeVersion::Copier.new 'version' => invalid }.should raise_error(RakeVersion::BadVersionPattern)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe 'Copying' do
|
44
|
-
COPIER_SAMPLE_ROOT = '/tmp'
|
45
|
-
COPIER_SAMPLE_VERSION = '7.8.9'
|
46
|
-
COPIER_SAMPLE_FILES = {
|
47
|
-
'/tmp/src/example.rb' => "#\n# example v1.2.3\n#\n\nputs 'Hello World!'",
|
48
|
-
'/tmp/src/example.js' => "/*\n * example v2.3.4\n */\n\nconsole.log('Hello World!');\n// This is example v2.3.4",
|
49
|
-
'/tmp/src/script/sub-example.sh' => "#\n# example v3.4.5\n#\n\necho 'Hello World!'",
|
50
|
-
'/tmp/src/script/sub-example.rb' => "#\n# example v4.5.6\n#\n\nputs 'Hello World!'\n# This is example v4.5.6",
|
51
|
-
'/tmp/lib/example.java' => "/**\n * example v5.6.7\n */\n\n// not yet implemented",
|
52
|
-
'/tmp/README' => "not\na\nsource\nfile"
|
53
|
-
}
|
54
|
-
|
55
|
-
before :each do
|
56
|
-
|
57
|
-
@version = double('version', :to_s => COPIER_SAMPLE_VERSION)
|
58
|
-
@context = double('context', :root => COPIER_SAMPLE_ROOT)
|
59
|
-
|
60
|
-
File.stub(:file?) do |file|
|
61
|
-
!!COPIER_SAMPLE_FILES[file]
|
62
|
-
end
|
63
|
-
|
64
|
-
stub = Find.stub(:find)
|
65
|
-
COPIER_SAMPLE_FILES.keys.each do |k|
|
66
|
-
stub.and_yield k
|
67
|
-
end
|
68
|
-
|
69
|
-
Dir.stub(:chdir)
|
70
|
-
Dir.stub(:glob) do |pattern|
|
71
|
-
COPIER_SAMPLE_FILES.keys.select do |k|
|
72
|
-
m = pattern.match /^\*\*\/\*\.([a-z]+)$/
|
73
|
-
m and k.match(Regexp.new("\\.#{m[1]}$"))
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def mock_file file
|
79
|
-
contents = COPIER_SAMPLE_FILES[file] ? COPIER_SAMPLE_FILES[file].dup : nil
|
80
|
-
double("file #{file}", :read => contents, :rewind => nil, :write => nil)
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should copy the version to ruby files with a glob string" do
|
84
|
-
|
85
|
-
filename1, filename2 = '/tmp/src/example.rb', '/tmp/src/script/sub-example.rb'
|
86
|
-
file1, file2 = mock_file(filename1), mock_file(filename2)
|
87
|
-
File.stub(:open).and_yield(file1).and_yield(file2)
|
88
|
-
|
89
|
-
copier = RakeVersion::Copier.new '**/*.rb'
|
90
|
-
|
91
|
-
@version.should_receive(:to_s)
|
92
|
-
@context.should_receive(:root)
|
93
|
-
File.should_receive(:open).with(filename1, 'r+')
|
94
|
-
File.should_receive(:open).with(filename2, 'r+')
|
95
|
-
file1.should_receive(:write).with(COPIER_SAMPLE_FILES[filename1].sub(/1\.2\.3/, '7.8.9'))
|
96
|
-
file2.should_receive(:write).with(COPIER_SAMPLE_FILES[filename2].sub(/4\.5\.6/, '7.8.9'))
|
97
|
-
|
98
|
-
copier.copy @version, @context
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should copy the version to javascript files with a regexp" do
|
102
|
-
|
103
|
-
filename = '/tmp/src/example.js'
|
104
|
-
file = mock_file filename
|
105
|
-
File.stub(:open).and_yield(file)
|
106
|
-
|
107
|
-
copier = RakeVersion::Copier.new /\.js$/
|
108
|
-
|
109
|
-
@version.should_receive(:to_s)
|
110
|
-
@context.should_receive(:root)
|
111
|
-
File.should_receive(:open).with(filename, 'r+')
|
112
|
-
file.should_receive(:write).with(COPIER_SAMPLE_FILES[filename].sub(/2\.3\.4/, '7.8.9'))
|
113
|
-
|
114
|
-
copier.copy @version, @context
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should copy the version to files identified by several glob strings and regexps" do
|
118
|
-
|
119
|
-
filename1, filename2 = '/tmp/src/script/sub-example.sh', '/tmp/lib/example.java'
|
120
|
-
file1, file2 = mock_file(filename1), mock_file(filename2)
|
121
|
-
File.stub(:open).and_yield(file1).and_yield(file2)
|
122
|
-
|
123
|
-
copier = RakeVersion::Copier.new '**/*.sh', /lib/
|
124
|
-
|
125
|
-
@version.should_receive(:to_s)
|
126
|
-
@context.should_receive(:root)
|
127
|
-
File.should_receive(:open).with(filename1, 'r+')
|
128
|
-
File.should_receive(:open).with(filename2, 'r+')
|
129
|
-
file1.should_receive(:write).with(COPIER_SAMPLE_FILES[filename1].sub(/3\.4\.5/, '7.8.9'))
|
130
|
-
file2.should_receive(:write).with(COPIER_SAMPLE_FILES[filename2].sub(/5\.6\.7/, '7.8.9'))
|
131
|
-
|
132
|
-
copier.copy @version, @context
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should not modify files that do not match the version pattern" do
|
136
|
-
|
137
|
-
filename = '/tmp/README'
|
138
|
-
file = mock_file filename
|
139
|
-
File.stub(:open).and_yield(file)
|
140
|
-
|
141
|
-
copier = RakeVersion::Copier.new /README/
|
142
|
-
|
143
|
-
@version.should_not_receive(:to_s)
|
144
|
-
@context.should_receive(:root)
|
145
|
-
File.should_receive(:open).with(filename, 'r+')
|
146
|
-
file.should_not_receive(:write)
|
147
|
-
|
148
|
-
copier.copy @version, @context
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should replace all occurences of the version pattern if specified" do
|
152
|
-
|
153
|
-
filename1, filename2 = '/tmp/src/example.js', '/tmp/src/script/sub-example.rb'
|
154
|
-
file1, file2 = mock_file(filename1), mock_file(filename2)
|
155
|
-
File.stub(:open).and_yield(file1).and_yield(file2)
|
156
|
-
|
157
|
-
copier = RakeVersion::Copier.new /\.js$/, /sub.*\.rb$/, :all => true
|
158
|
-
|
159
|
-
@version.should_receive(:to_s)
|
160
|
-
@context.should_receive(:root)
|
161
|
-
File.should_receive(:open).with(filename1, 'r+')
|
162
|
-
File.should_receive(:open).with(filename2, 'r+')
|
163
|
-
file1.should_receive(:write).with(COPIER_SAMPLE_FILES[filename1].gsub(/2\.3\.4/, '7.8.9'))
|
164
|
-
file2.should_receive(:write).with(COPIER_SAMPLE_FILES[filename2].gsub(/4\.5\.6/, '7.8.9'))
|
165
|
-
|
166
|
-
copier.copy @version, @context
|
167
|
-
end
|
168
|
-
|
169
|
-
it "should replace the given version pattern" do
|
170
|
-
|
171
|
-
filename = '/tmp/src/example.js'
|
172
|
-
file = mock_file filename
|
173
|
-
File.stub(:open).and_yield(file)
|
174
|
-
|
175
|
-
copier = RakeVersion::Copier.new '**/*.js', :version => /v\d+\.\d+\.\d+/
|
176
|
-
|
177
|
-
@version.should_receive(:to_s)
|
178
|
-
@context.should_receive(:root)
|
179
|
-
File.should_receive(:open).with(filename, 'r+')
|
180
|
-
file.should_receive(:write).with(COPIER_SAMPLE_FILES[filename].sub(/v2\.3\.4/, '7.8.9'))
|
181
|
-
|
182
|
-
copier.copy @version, @context
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|