capsulecd 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/capsulecd/base/configuration.rb +3 -0
- data/lib/capsulecd/base/source/github.rb +3 -2
- data/lib/capsulecd/python/python_engine.rb +1 -1
- data/lib/capsulecd/ruby/ruby_engine.rb +8 -16
- data/lib/capsulecd/ruby/ruby_helper.rb +53 -14
- data/lib/capsulecd/version.rb +1 -1
- data/spec/fixtures/ruby/capsulecd/Gemfile +4 -0
- data/spec/fixtures/ruby/capsulecd/LICENSE.txt +21 -0
- data/spec/fixtures/ruby/capsulecd/README.md +41 -0
- data/spec/fixtures/ruby/capsulecd/Rakefile +6 -0
- data/spec/fixtures/ruby/capsulecd/capsulecd.gemspec +25 -0
- data/spec/fixtures/ruby/capsulecd/lib/capsulecd/version.rb +3 -0
- data/spec/fixtures/ruby/capsulecd/lib/capsulecd.rb +5 -0
- data/spec/fixtures/ruby/capsulecd/spec/capsulecd_spec.rb +7 -0
- data/spec/fixtures/ruby/capsulecd/spec/spec_helper.rb +2 -0
- data/spec/lib/capsulecd/ruby/ruby_engine_spec.rb +36 -0
- data/spec/lib/capsulecd/ruby/ruby_helper_spec.rb +61 -41
- metadata +20 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e25f1e755126cbc4e3c5265ae683b7f2ce8e5081
|
4
|
+
data.tar.gz: 4f6881632615810fe5258f8402d4c60e8ffd9b83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 49d0c2780b99b08144a22ffed6dbf13c89cc0091c7bea7f6e358aaabb231e235a9203d6e486858f0bc5f1ac83e61a672996b11c62ea1c6d04bfbcb121307a57a
|
7
|
+
data.tar.gz: 218d8e2e1eacdb8a179d05c20d4f386f23143c8a4250c0aee35b6ec776b1811511557409e40c02aa5b61f4694e2637ffd82d75379837512376bd59f41dae26e9
|
data/README.md
CHANGED
@@ -151,6 +151,7 @@ engine_cmd_test | Yes | Yes | Specifies the test command to before releasing pac
|
|
151
151
|
engine_cmd_minification | Yes | Yes | Specifies the minification command to before releasing package
|
152
152
|
engine_cmd_lint | Yes | Yes | Specifies the lint command to before releasing package
|
153
153
|
engine_version_bump_type | Yes | Yes | Specifies the Semvar segment (`major`, `minor`, `patch`) to bump before releasing package
|
154
|
+
engine_disable_cleanup | Yes | Yes | Specifies if the engine should cleanup the working directory on exit
|
154
155
|
|
155
156
|
TODO: specify the missing `BRANCH` release style settings.
|
156
157
|
|
@@ -253,3 +254,4 @@ Jason Kulatunga - Initial Development - [@AnalogJ](https://github.com/AnalogJ)
|
|
253
254
|
# License
|
254
255
|
|
255
256
|
CapsuleCD is licensed under the MIT License - see the [LICENSE.md](https://github.com/AnalogJ/capsulecd/blob/master/LICENSE.md) file for details
|
257
|
+
|
@@ -63,6 +63,8 @@ module CapsuleCD
|
|
63
63
|
attr_reader :engine_cmd_lint
|
64
64
|
attr_reader :engine_cmd_coverage
|
65
65
|
attr_reader :engine_version_bump_type
|
66
|
+
attr_reader :engine_disable_cleanup
|
67
|
+
|
66
68
|
|
67
69
|
def populate_repo_config_file(repo_local_path)
|
68
70
|
repo_config_file_path = repo_local_path + '/capsule.yml'
|
@@ -83,6 +85,7 @@ module CapsuleCD
|
|
83
85
|
def populate_defaults
|
84
86
|
@engine_version_bump_type = :patch # can be :major, :minor, :patch
|
85
87
|
@chef_supermarket_type = 'Other'
|
88
|
+
@engine_disable_cleanup = false
|
86
89
|
end
|
87
90
|
|
88
91
|
def load_config_file(path)
|
@@ -159,6 +159,7 @@ module CapsuleCD
|
|
159
159
|
# requires @source_git_parent_path
|
160
160
|
# requires @source_git_base_info
|
161
161
|
# requires @source_git_head_info
|
162
|
+
# requires @config.engine_disable_cleanup
|
162
163
|
def source_notify(step, status='pending')
|
163
164
|
|
164
165
|
@source_client.create_status(@source_git_base_info['repo']['full_name'], @source_git_head_info['sha'], status,
|
@@ -170,11 +171,11 @@ module CapsuleCD
|
|
170
171
|
|
171
172
|
rescue => ex
|
172
173
|
puts 'github source_process_failure'
|
173
|
-
FileUtils.remove_entry_secure @source_git_parent_path if Dir.exists?(@source_git_parent_path)
|
174
|
+
FileUtils.remove_entry_secure @source_git_parent_path if (Dir.exists?(@source_git_parent_path) && !@config.engine_disable_cleanup)
|
174
175
|
@source_client.create_status(@source_git_base_info['repo']['full_name'], @source_git_head_info['sha'], 'failure',
|
175
176
|
context: 'CapsuleCD',
|
176
177
|
target_url: 'http://www.github.com/AnalogJ/capsulecd',
|
177
|
-
description: ex.message.slice
|
178
|
+
description: ex.message.slice(0..135))
|
178
179
|
raise
|
179
180
|
end
|
180
181
|
|
@@ -135,7 +135,7 @@ TOX
|
|
135
135
|
end
|
136
136
|
|
137
137
|
# run python setup.py sdist
|
138
|
-
Open3.popen3('python setup.py sdist
|
138
|
+
Open3.popen3('python setup.py sdist', chdir: @source_git_local_path) do |_stdin, stdout, stderr, external|
|
139
139
|
{ stdout: stdout, stderr: stderr }. each do |name, stream_buffer|
|
140
140
|
Thread.new do
|
141
141
|
until (line = stream_buffer.gets).nil?
|
@@ -10,13 +10,7 @@ module CapsuleCD
|
|
10
10
|
def build_step
|
11
11
|
super
|
12
12
|
gemspec_path = CapsuleCD::Ruby::RubyHelper.get_gemspec_path(@source_git_local_path)
|
13
|
-
|
14
|
-
# check for required VERSION file
|
15
|
-
gemspec_data = CapsuleCD::Ruby::RubyHelper.get_gemspec_data(@source_git_local_path)
|
16
|
-
|
17
|
-
if !File.exist?(CapsuleCD::Ruby::RubyHelper.version_filepath(@source_git_local_path, gemspec_data.name))
|
18
|
-
fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is required to process Ruby gem'
|
19
|
-
end
|
13
|
+
gem_name = CapsuleCD::Ruby::RubyHelper.get_gem_name(@source_git_local_path)
|
20
14
|
|
21
15
|
# bump up the version here.
|
22
16
|
# since there's no standardized way to bump up the version in the *.gemspec file, we're going to assume that the version
|
@@ -31,11 +25,9 @@ module CapsuleCD
|
|
31
25
|
# http://timelessrepo.com/making-ruby-gems
|
32
26
|
# http://guides.rubygems.org/make-your-own-gem/
|
33
27
|
|
34
|
-
|
35
|
-
next_version = bump_version(SemVer.parse(
|
36
|
-
|
37
|
-
new_version_str = version_str.gsub(/(VERSION\s*=\s*['"])[0-9\.]+(['"])/, "\\1#{next_version.to_s}\\2")
|
38
|
-
CapsuleCD::Ruby::RubyHelper.write_version_file(@source_git_local_path, gemspec_data.name, new_version_str)
|
28
|
+
gem_version = CapsuleCD::Ruby::RubyHelper.get_version(@source_git_local_path)
|
29
|
+
next_version = bump_version(SemVer.parse(gem_version))
|
30
|
+
CapsuleCD::Ruby::RubyHelper.set_version(@source_git_local_path, next_version.to_s)
|
39
31
|
|
40
32
|
# check for/create any required missing folders/files
|
41
33
|
unless File.exist?(@source_git_local_path + '/Gemfile')
|
@@ -69,8 +61,8 @@ module CapsuleCD
|
|
69
61
|
unless external.value.success?
|
70
62
|
fail CapsuleCD::Error::BuildPackageFailed, 'gem build failed. Check gemspec file and dependencies'
|
71
63
|
end
|
72
|
-
unless File.exist?(@source_git_local_path + "/#{
|
73
|
-
fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{
|
64
|
+
unless File.exist?(@source_git_local_path + "/#{gem_name}-#{next_version.to_s}.gem")
|
65
|
+
fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gem_name}-#{next_version.to_s}.gem not found"
|
74
66
|
end
|
75
67
|
end
|
76
68
|
end
|
@@ -143,8 +135,8 @@ module CapsuleCD
|
|
143
135
|
|
144
136
|
# commit changes to the cookbook. (test run occurs before this, and it should clean up any instrumentation files, created,
|
145
137
|
# as they will be included in the commmit and any release artifacts)
|
146
|
-
|
147
|
-
next_version = SemVer.parse(
|
138
|
+
gem_version = CapsuleCD::Ruby::RubyHelper.get_version(@source_git_local_path)
|
139
|
+
next_version = SemVer.parse(gem_version)
|
148
140
|
CapsuleCD::GitUtils.commit(@source_git_local_path, "(v#{next_version}) Automated packaging of release by CapsuleCD")
|
149
141
|
@source_release_commit = CapsuleCD::GitUtils.tag(@source_git_local_path, "v#{next_version}")
|
150
142
|
end
|
@@ -4,18 +4,11 @@ require 'bundler'
|
|
4
4
|
module CapsuleCD
|
5
5
|
module Ruby
|
6
6
|
class RubyHelper
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
def self.read_version_file(repo_path, gem_name, version_filename = 'version.rb')
|
12
|
-
File.read(self.version_filepath(repo_path, gem_name, version_filename))
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.write_version_file(repo_path, gem_name, metadata_str, version_filename = 'version.rb')
|
16
|
-
File.open(self.version_filepath(repo_path, gem_name, version_filename), 'w') { |file| file.write(metadata_str) }
|
17
|
-
end
|
7
|
+
PRERELEASE = ["alpha","beta","rc",nil]
|
8
|
+
VERSION_REGEX = /(\d+\.\d+\.\d+(?:-(?:#{PRERELEASE.compact.join('|')}))?)/
|
9
|
+
REPLACE_VERSION_REGEX =
|
18
10
|
|
11
|
+
# get gemspec file path (used for `gem build ..` command)
|
19
12
|
def self.get_gemspec_path(repo_path)
|
20
13
|
gemspecs = Dir.glob(repo_path + '/*.gemspec')
|
21
14
|
if gemspecs.empty?
|
@@ -24,12 +17,55 @@ module CapsuleCD
|
|
24
17
|
gemspecs.first
|
25
18
|
end
|
26
19
|
|
27
|
-
|
28
|
-
|
20
|
+
# get gem name
|
21
|
+
def self.get_gem_name(repo_path)
|
22
|
+
self.load_gemspec_data(self.get_gemspec_path(repo_path)).name
|
23
|
+
end
|
24
|
+
|
25
|
+
# get gem version
|
26
|
+
def self.get_version(repo_path)
|
27
|
+
gem_version_file = self.find_version_file(repo_path)
|
28
|
+
gem_version = File.read(gem_version_file)[VERSION_REGEX]
|
29
|
+
if !gem_version
|
30
|
+
fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is invalid'
|
31
|
+
end
|
32
|
+
return gem_version
|
33
|
+
end
|
34
|
+
|
35
|
+
# set gem version
|
36
|
+
def self.set_version(repo_path, next_version)
|
37
|
+
gem_version_file = self.find_version_file(repo_path)
|
38
|
+
gem_version_file_content = File.read(gem_version_file)
|
39
|
+
|
40
|
+
next_gem_version_file_content = gem_version_file_content.gsub(/(VERSION\s*=\s*['"])[0-9\.]+(['"])/, "\\1#{next_version.to_s}\\2")
|
41
|
+
|
42
|
+
File.open(gem_version_file, 'w') { |file| file.write(next_gem_version_file_content) }
|
29
43
|
end
|
30
44
|
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
private
|
31
49
|
##################################################################################################################
|
32
|
-
# protected/private methods.
|
50
|
+
# NEW protected/private methods.
|
51
|
+
# based on bump gem methods: https://github.com/gregorym/bump/blob/master/lib/bump.rb
|
52
|
+
|
53
|
+
def self.find_version_file(repo_path)
|
54
|
+
files = Dir.glob("#{repo_path}/lib/**/version.rb")
|
55
|
+
if files.size == 0
|
56
|
+
fail CapsuleCD::Error::BuildPackageInvalid, 'version.rb file is required to process Ruby gem'
|
57
|
+
elsif files.size == 1
|
58
|
+
return files.first
|
59
|
+
else
|
60
|
+
# too many version.rb files found, lets try to find the correct version.rb file using gem name in gemspec
|
61
|
+
return self.version_filepath(repo_path, self.get_gem_name(repo_path))
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def self.version_filepath(repo_path, gem_name, version_filename = 'version.rb')
|
66
|
+
"#{repo_path}/lib/#{gem_name}/#{version_filename}"
|
67
|
+
end
|
68
|
+
|
33
69
|
|
34
70
|
# since the Gem::Specification class is basically eval'ing the gemspec file, and the gemspec file is doing a require
|
35
71
|
# to load the version.rb file, the version.rb file is cached in memory. We're going to try to get around that issue
|
@@ -56,6 +92,9 @@ module CapsuleCD
|
|
56
92
|
gemspec_data = nil
|
57
93
|
Bundler.with_clean_env do
|
58
94
|
gemspec_data = self.execute_in_child do
|
95
|
+
# reload the version.rb file if found (fixes dogfooding issue)
|
96
|
+
# Dir["#{File.dirname(gemspec_path)}/**/version.rb"].each { |f| load(f) }
|
97
|
+
|
59
98
|
Gem::Specification::load(gemspec_path)
|
60
99
|
end
|
61
100
|
end
|
data/lib/capsulecd/version.rb
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jason Kulatunga
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# GemTest
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/gem_test`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'gem_test'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install gem_test
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/gem_test.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'capsulecd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "capsulecd"
|
8
|
+
spec.version = CapsuleCD::VERSION
|
9
|
+
spec.authors = ["Jason Kulatunga"]
|
10
|
+
spec.email = ["jk17@ualberta.ca"]
|
11
|
+
|
12
|
+
spec.summary = 'this is my test summary'
|
13
|
+
spec.description = 'this is my test description'
|
14
|
+
spec.homepage = "http://www.github.com/Analogj/capsulecd"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
25
|
+
end
|
@@ -48,6 +48,42 @@ describe 'CapsuleCD::Ruby::RubyEngine', :ruby do
|
|
48
48
|
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
|
53
|
+
describe 'when building and dogfooding capsulecd package ' do
|
54
|
+
let(:engine) do
|
55
|
+
require 'capsulecd/ruby/ruby_engine'
|
56
|
+
CapsuleCD::Ruby::RubyEngine.new(source: :github,
|
57
|
+
package_type: :ruby)
|
58
|
+
end
|
59
|
+
it 'should create a Gemfile, Rakefile, .gitignore file and spec folder' do
|
60
|
+
FileUtils.copy_entry('spec/fixtures/ruby/capsulecd', test_directory)
|
61
|
+
FileUtils.rm(test_directory + '/Gemfile')
|
62
|
+
FileUtils.rm(test_directory + '/Rakefile')
|
63
|
+
|
64
|
+
engine.instance_variable_set(:@source_git_local_path, test_directory)
|
65
|
+
|
66
|
+
VCR.use_cassette('gem_build_step',:tag => :ruby) do
|
67
|
+
engine.build_step
|
68
|
+
end
|
69
|
+
|
70
|
+
expect(File.exist?(test_directory+'/.gitignore')).to eql(true)
|
71
|
+
expect(File.exist?(test_directory+'/Gemfile')).to eql(true)
|
72
|
+
expect(File.exist?(test_directory+'/Rakefile')).to eql(true)
|
73
|
+
expect(File.exist?(test_directory+'/capsulecd-1.0.2.gem')).to eql(true)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'should raise an error if version.rb is missing' do
|
77
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
78
|
+
FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
|
79
|
+
engine.instance_variable_set(:@source_git_local_path, test_directory)
|
80
|
+
|
81
|
+
VCR.use_cassette('gem_build_step_without_version.rb',:tag => :ruby) do
|
82
|
+
expect{engine.build_step}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
86
|
+
end
|
51
87
|
end
|
52
88
|
|
53
89
|
describe '#test_step' do
|
@@ -4,14 +4,6 @@ describe 'CapsuleCD::Ruby::RubyHelper', :ruby do
|
|
4
4
|
subject{
|
5
5
|
CapsuleCD::Ruby::RubyHelper
|
6
6
|
}
|
7
|
-
describe '#version_filepath' do
|
8
|
-
it 'default should generate the correct path to version.rb' do
|
9
|
-
expect(subject.version_filepath('/tmp','capsulecd')).to eql('/tmp/lib/capsulecd/version.rb')
|
10
|
-
end
|
11
|
-
it 'with custom version filename should generate the correct path' do
|
12
|
-
expect(subject.version_filepath('/tmp','capsulecd', 'VERSION.rb')).to eql('/tmp/lib/capsulecd/VERSION.rb')
|
13
|
-
end
|
14
|
-
end
|
15
7
|
|
16
8
|
describe '#get_gemspec_path' do
|
17
9
|
describe 'without a gemspec file' do
|
@@ -29,12 +21,11 @@ describe 'CapsuleCD::Ruby::RubyHelper', :ruby do
|
|
29
21
|
end
|
30
22
|
end
|
31
23
|
|
32
|
-
describe '#
|
24
|
+
describe '#get_gem_name' do
|
33
25
|
it 'should parse gemspec data' do
|
34
26
|
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
35
|
-
|
36
|
-
expect(
|
37
|
-
expect(gemspec_data.version.to_s).to eql('0.1.3')
|
27
|
+
gem_name = subject.get_gem_name(test_directory)
|
28
|
+
expect(gem_name).to eql('gem_analogj_test')
|
38
29
|
end
|
39
30
|
|
40
31
|
describe 'with an invalid gemspec file' do
|
@@ -42,48 +33,77 @@ describe 'CapsuleCD::Ruby::RubyHelper', :ruby do
|
|
42
33
|
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
43
34
|
FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
|
44
35
|
|
45
|
-
expect{subject.
|
36
|
+
expect{subject.get_gem_name(test_directory)}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
|
46
37
|
end
|
47
38
|
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#get_version' do
|
42
|
+
|
43
|
+
it 'should parse version.rb file' do
|
44
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
45
|
+
gem_version = subject.get_version(test_directory)
|
46
|
+
expect(gem_version).to eql('0.1.3')
|
47
|
+
end
|
48
48
|
|
49
|
-
describe '
|
50
|
-
it 'should
|
49
|
+
describe 'without a version.rb file' do
|
50
|
+
it 'should raise an error' do
|
51
51
|
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
52
|
+
FileUtils.rm(test_directory + '/lib/gem_analogj_test/version.rb')
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
expect{subject.get_gem_name(test_directory)}.to raise_error(CapsuleCD::Error::BuildPackageInvalid)
|
55
|
+
end
|
56
|
+
end
|
55
57
|
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
describe 'with too many version.rb files' do
|
59
|
+
it 'should fallback to using version_filepath & gem name' do
|
60
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
61
|
+
FileUtils.mkdir_p(test_directory + '/lib/gem_analogj_test/test/')
|
62
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test/lib/gem_analogj_test/version.rb',
|
63
|
+
test_directory + '/lib/gem_analogj_test/test/version.rb')
|
59
64
|
|
60
|
-
|
61
|
-
|
65
|
+
gem_version = subject.get_version(test_directory)
|
66
|
+
expect(gem_version).to eql('0.1.3')
|
62
67
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
external.join
|
73
|
-
unless external.value.success?
|
74
|
-
fail CapsuleCD::Error::BuildPackageFailed, 'gem build failed. Check gemspec file and dependencies'
|
75
|
-
end
|
76
|
-
unless File.exist?(test_directory + "/#{gemspec_data.name}-#{next_version.to_s}.gem")
|
77
|
-
fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gemspec_data.name}-#{next_version.to_s}.gem not found"
|
78
|
-
end
|
79
|
-
end
|
68
|
+
#TODO: cant figure out how to verify that a class method was called.
|
69
|
+
# expect(CapsuleCD::Ruby::RubyHelper).to receive(:version_filepath).with(test_directory, 'gem_analogj_test')
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '#set_version' do
|
75
|
+
it 'should correctly update version in version.rb file' do
|
76
|
+
FileUtils.copy_entry('spec/fixtures/ruby/gem_analogj_test', test_directory)
|
80
77
|
|
81
|
-
|
82
|
-
|
78
|
+
gem_name = CapsuleCD::Ruby::RubyHelper.get_gem_name(test_directory)
|
79
|
+
gem_version = CapsuleCD::Ruby::RubyHelper.get_version(test_directory)
|
80
|
+
expect(gem_version).to eql('0.1.3')
|
83
81
|
|
82
|
+
next_version = CapsuleCD::Engine.new(:source => :github).send(:bump_version, SemVer.parse(gem_version))
|
83
|
+
expect(next_version.to_s).to eql('0.1.4')
|
84
84
|
|
85
|
+
CapsuleCD::Ruby::RubyHelper.set_version(test_directory, next_version.to_s)
|
85
86
|
|
87
|
+
Open3.popen3('gem build gem_analogj_test.gemspec', chdir: test_directory) do |_stdin, stdout, stderr, external|
|
88
|
+
{ stdout: stdout, stderr: stderr }. each do |name, stream_buffer|
|
89
|
+
Thread.new do
|
90
|
+
until (line = stream_buffer.gets).nil?
|
91
|
+
puts "#{name} -> #{line}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
# wait for process
|
96
|
+
external.join
|
97
|
+
unless external.value.success?
|
98
|
+
fail CapsuleCD::Error::BuildPackageFailed, 'gem build failed. Check gemspec file and dependencies'
|
99
|
+
end
|
100
|
+
unless File.exist?(test_directory + "/#{gem_name}-#{next_version.to_s}.gem")
|
101
|
+
fail CapsuleCD::Error::BuildPackageFailed, "gem build failed. #{gem_name}-#{next_version.to_s}.gem not found"
|
102
|
+
end
|
86
103
|
end
|
104
|
+
|
105
|
+
updated_gem_version = CapsuleCD::Ruby::RubyHelper.get_version(test_directory)
|
106
|
+
expect(updated_gem_version).to eql('0.1.4')
|
87
107
|
end
|
88
108
|
|
89
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capsulecd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Kulatunga (AnalogJ)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -145,6 +145,15 @@ files:
|
|
145
145
|
- spec/fixtures/python/pip_analogj_test/setup.cfg
|
146
146
|
- spec/fixtures/python/pip_analogj_test/setup.py
|
147
147
|
- spec/fixtures/python/pip_analogj_test/tox.ini
|
148
|
+
- spec/fixtures/ruby/capsulecd/Gemfile
|
149
|
+
- spec/fixtures/ruby/capsulecd/LICENSE.txt
|
150
|
+
- spec/fixtures/ruby/capsulecd/README.md
|
151
|
+
- spec/fixtures/ruby/capsulecd/Rakefile
|
152
|
+
- spec/fixtures/ruby/capsulecd/capsulecd.gemspec
|
153
|
+
- spec/fixtures/ruby/capsulecd/lib/capsulecd.rb
|
154
|
+
- spec/fixtures/ruby/capsulecd/lib/capsulecd/version.rb
|
155
|
+
- spec/fixtures/ruby/capsulecd/spec/capsulecd_spec.rb
|
156
|
+
- spec/fixtures/ruby/capsulecd/spec/spec_helper.rb
|
148
157
|
- spec/fixtures/ruby/gem_analogj_test-0.1.4.gem
|
149
158
|
- spec/fixtures/ruby/gem_analogj_test/Gemfile
|
150
159
|
- spec/fixtures/ruby/gem_analogj_test/LICENSE.txt
|
@@ -237,6 +246,15 @@ test_files:
|
|
237
246
|
- spec/fixtures/python/pip_analogj_test/setup.cfg
|
238
247
|
- spec/fixtures/python/pip_analogj_test/setup.py
|
239
248
|
- spec/fixtures/python/pip_analogj_test/tox.ini
|
249
|
+
- spec/fixtures/ruby/capsulecd/Gemfile
|
250
|
+
- spec/fixtures/ruby/capsulecd/LICENSE.txt
|
251
|
+
- spec/fixtures/ruby/capsulecd/README.md
|
252
|
+
- spec/fixtures/ruby/capsulecd/Rakefile
|
253
|
+
- spec/fixtures/ruby/capsulecd/capsulecd.gemspec
|
254
|
+
- spec/fixtures/ruby/capsulecd/lib/capsulecd.rb
|
255
|
+
- spec/fixtures/ruby/capsulecd/lib/capsulecd/version.rb
|
256
|
+
- spec/fixtures/ruby/capsulecd/spec/capsulecd_spec.rb
|
257
|
+
- spec/fixtures/ruby/capsulecd/spec/spec_helper.rb
|
240
258
|
- spec/fixtures/ruby/gem_analogj_test-0.1.4.gem
|
241
259
|
- spec/fixtures/ruby/gem_analogj_test/Gemfile
|
242
260
|
- spec/fixtures/ruby/gem_analogj_test/LICENSE.txt
|