gem_release_helper 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ff13664fd883a8f84e71ec0735526b42b793bcf4
4
- data.tar.gz: eb4114d0735073d28de2438235da86066904e7a6
3
+ metadata.gz: 8d119030846dc267a66ee8153fd37e9a18938737
4
+ data.tar.gz: dfbe0a6a700237dd2ad36a4aec54ea10c5a2893e
5
5
  SHA512:
6
- metadata.gz: 71d66bda16d7bd8be453add1f839d43c1ca558b8cfdd4ec6aa503f10963f75e23a4d5cb328aecd97292149e9844f7c4108d530cc7055cd02e65a11855d394d83
7
- data.tar.gz: 96f1b74f48d782753241667cf6ccadbbd4c935e76a7d6b0644d905b1ff3d1ab632440f38d8473aced2570360a2e4064a9453d84b49c0605151074412a206627f
6
+ metadata.gz: b7745d262ae469d4ad66e9edabe4f4e00e72016ec6059e92313cd2704d3b9393798b64caee4fd7c2b887bd2e2d029e574989d6deb10465f37fa9065398c02ed1
7
+ data.tar.gz: 13747b0e86029980968bd3a2ff49ea8a2ac523ff172640695f43c9ba4d35a05647a6e2ba71e669f03ce5299a188c88bb800cb42c7639112f9ebe953fa467a1d6
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ /pkg/
2
+ /Gemfile.lock
data/.travis.yml CHANGED
@@ -1,14 +1,16 @@
1
1
  language: ruby
2
2
  rvm:
3
- - jruby-19mode
4
- - jruby-9.0.0.0 # NOTE: rvm 1.26.10 recognize as jruby-9.0.0pre1
3
+ - jruby-9.0.5.0 # NOTE: rvm 1.26.10 recognize as jruby-9.0.0pre1
4
+ - 2.3.1
5
+ - ruby-head
6
+ - jruby-head
5
7
  env: 'JRUBY_OPTS="-Xcli.debug=true --debug"' # for test coverage
8
+
6
9
  addons:
7
10
  code_climate:
8
- repo_token:
9
- secure: "Ael9qV6oxuruF2I4l5GVm85EXmsTFJB2AxcwT3Ni2fALj+/xUdR5n9FwPxLwTqS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aa/2zg+TgKHvZ2E89YmMO57k/pac/Bn1BiAkActKu/gZdun6l4PC7/0qUbEI/ndnNMbpKx5gOgmpiIWkTAMo6oDbigygUwduonsoKx0oT9rm8q1AQA6PrxORj7+5cd6kmEaPvSvZS4oiSVwJvgs4RLp65grG6TxmHDzBizbJlEveDvZ9sgG9wgH7/ihtqKVG1KxXycierEJUoYvN0IUDKYQWMzzNKl5rSw58lHDEu606U15gUk5mXY=
11
+ repo_token: 089cf6093822f5c0502918a9590ce8284f352501199ae0261c7cef4357a418c8
13
12
  jdk:
14
- - oraclejdk8
13
+ - oraclejdk8
14
+
15
+ before_install:
16
+ - gem i bundler
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 1.0.1 - 2016-07-22
2
+ * [improve] Enable to detect/bump version using external file [#2](https://github.com/uu59/gem_release_helper/pull/2)
3
+ * [improve] Enable to access private repo [#1](https://github.com/uu59/gem_release_helper/pull/1)
4
+
1
5
  ## 1.0.0 - 2016-07-13
2
6
 
3
7
  Forked and renamed as "gem_release_helper".
data/README.md CHANGED
@@ -27,6 +27,11 @@ Load rake tasks at your Rakefile:
27
27
 
28
28
  require "bundler/gem_tasks"
29
29
  require "gem_release_helper/tasks"
30
+ GemReleaseHelper::Tasks.install({
31
+ gemspec: "./your_gem.gemspec",
32
+ github_name: "user/repo", # if this repo is private, you can access it by set GITHUB_OAUTH_TOKEN to environment variable
33
+ })
34
+
30
35
 
31
36
  ## Usage
32
37
 
@@ -34,6 +39,7 @@ Load rake tasks at your Rakefile:
34
39
  rake build # Build embulk-input-your-plugin-0.1.0.gem into the pkg directory
35
40
  rake generate:bump_version # Bump version
36
41
  rake generate:changelog # Generate CHANGELOG.md from previous release
42
+ rake generate:gemfiles # Generate gemfiles to test this plugin with released Embulk versions (since MIN_VERSION)
37
43
  rake generate:prepare_release # Generate chengelog then bump version
38
44
  rake install # Build and install embulk-input-your-plugin-0.1.0.gem into system gems
39
45
  rake release # Create tag v0.1.0 and build and push embulk-input-your-plugin-0.1.0.gem to Rubygems
@@ -1,4 +1,5 @@
1
1
  require "gem_release_helper/tasks/common"
2
+ require "open3"
2
3
 
3
4
  module GemReleaseHelper
4
5
  module Tasks
@@ -34,7 +35,18 @@ module GemReleaseHelper
34
35
  end
35
36
 
36
37
  def bump_version
37
- logger.info "Version bump '#{current_version}' to '#{next_version}'"
38
+ logger.info "Bump version from '#{current_version}' to '#{next_version}'"
39
+ case where_written_version
40
+ when :gemspec
41
+ write_new_version_to_gemspec
42
+ when :version_file
43
+ write_new_version_to_version_file
44
+ end
45
+ end
46
+
47
+ private
48
+
49
+ def write_new_version_to_gemspec
38
50
  old_content = gemspec_path.read
39
51
  new_content = old_content.gsub(/(spec\.version += *)".*?"/, %Q!\\1"#{next_version}"!)
40
52
  File.open(gemspec_path, "w") do |f|
@@ -42,14 +54,47 @@ module GemReleaseHelper
42
54
  end
43
55
  end
44
56
 
45
- private
57
+ def write_new_version_to_version_file
58
+ version_file = version_files.first
59
+ new_content = File.read(version_file).gsub(current_version.to_s, next_version.to_s)
60
+ File.open(version_file, "w") {|f| f.write new_content }
61
+ end
62
+
63
+ def where_written_version
64
+ if gemspec_path.read.include?(current_version.to_s)
65
+ :gemspec
66
+ else
67
+ version_file = version_files.first
68
+ if version_file && File.read(version_file).include?(current_version.to_s)
69
+ return :version_file
70
+ end
71
+ raise "Couldn't find where is version written"
72
+ end
73
+ end
74
+
75
+ def version_files
76
+ Dir["#{gemspec_path.dirname}/**/version**"]
77
+ end
46
78
 
47
79
  def required_options
48
80
  %w(github_name)
49
81
  end
50
82
 
51
83
  def current_version
52
- ENV["CURRENT_VER"] || Gem::Version.new(gemspec_path.read[/spec\.version += *"([0-9]+\.[0-9]+\.[0-9]+)"/, 1])
84
+ return ENV["CURRENT_VER"] if ENV["CURRENT_VER"]
85
+ ver = gemspec_path.read[/spec\.version += *"([0-9]+\.[0-9]+\.[0-9]+)"/, 1] ||
86
+ begin
87
+ # from rake
88
+ # https://github.com/ruby/rake/blob/1b27eb2f8234190bba0e973194d38bcf09443ec0/lib/rake/file_utils.rb
89
+ ruby = File.join(
90
+ RbConfig::CONFIG['bindir'],
91
+ RbConfig::CONFIG['ruby_install_name'] + RbConfig::CONFIG['EXEEXT']
92
+ ).sub(/.*\s.*/m, '"\&"')
93
+ script = %Q!print eval(File.read('#{gemspec_path}')).version.to_s!
94
+ o, _, _ = Open3.capture3(ruby, "-e", script)
95
+ o.strip
96
+ end
97
+ Gem::Version.new(ver)
53
98
  end
54
99
 
55
100
  def next_version
@@ -87,7 +132,9 @@ module GemReleaseHelper
87
132
  end
88
133
 
89
134
  def pull_request_info(number)
90
- body = open("https://api.github.com/repos/#{github_name}/issues/#{number}").read
135
+ body = open("https://api.github.com/repos/#{github_name}/issues/#{number}", {
136
+ "Authentication" => "token #{ENV["GITHUB_OAUTH_TOKEN"]}"
137
+ }).read
91
138
  JSON.parse(body)
92
139
  end
93
140
 
@@ -1,3 +1,3 @@
1
1
  module GemReleaseHelper
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -73,61 +73,110 @@ Merry Xmas!
73
73
  end
74
74
 
75
75
  class TestBumpVersion < self
76
- def test_bump_version_task
77
- any_instance_of(Changelog) do |klass|
78
- mock(klass).bump_version
79
- mock(klass).update_gemfile_lock
76
+ class TestVersionDynamic < self
77
+ def setup
78
+ @version = "1.0.0"
79
+ @dir = Pathname.new(Dir.tmpdir).join(Time.now.to_f.to_s)
80
+ @dir.mkdir
81
+ @version_file = @dir.join("lib/foo/version.rb")
82
+ FileUtils.mkdir_p @version_file.dirname
83
+ @version_file.write <<RUBY
84
+ class Foo
85
+ VERSION = "#{@version}"
86
+ end
87
+ RUBY
88
+ @dir.join("foo.gemspec").write <<-SPEC
89
+ # coding: utf-8
90
+ require '#{@dir.join("lib/foo/version.rb").to_s}'
91
+
92
+ Gem::Specification.new do |spec|
93
+ spec.name = "foo"
94
+ spec.version = Foo::VERSION
95
+ end
96
+ SPEC
97
+ end
98
+
99
+ def teardown
100
+ FileUtils.rm_rf @dir
101
+ end
102
+
103
+ def test_bump_version_on_file
104
+ @task = Changelog.new(options)
105
+ mute_logger(@task)
106
+
107
+ @task.bump_version
108
+ assert @version_file.read.include?("1.0.1")
109
+ assert_equal "1.0.1", @task.send(:current_version).to_s
110
+ end
111
+
112
+ private
113
+
114
+ def options
115
+ {
116
+ gemspec: @dir.join("foo.gemspec").to_s,
117
+ github_name: "foo/foo",
118
+ }
80
119
  end
81
- Tasks.install(options)
82
- task = Rake::Task.tasks.find {|task| task.name == "generate:bump_version"}
83
- task.execute
84
- ensure
85
- Rake::Task.clear
86
120
  end
87
121
 
88
- def test_without_option
89
- @task = Changelog.new(options)
90
- mute_logger(@task)
122
+ class TestVersionStatic < self
123
+ def test_bump_version_task
124
+ any_instance_of(Changelog) do |klass|
125
+ mock(klass).bump_version
126
+ mock(klass).update_gemfile_lock
127
+ end
128
+ Tasks.install(options)
129
+ task = Rake::Task.tasks.find {|t| t.name == "generate:bump_version"}
130
+ task.execute
131
+ ensure
132
+ Rake::Task.clear
133
+ end
91
134
 
92
- @task.bump_version
135
+ def test_without_option
136
+ @task = Changelog.new(options)
137
+ mute_logger(@task)
93
138
 
94
- assert_equal(<<-SPEC, gemspec_path.read)
139
+ @task.bump_version
140
+
141
+ assert_equal(<<-SPEC, gemspec_path.read)
95
142
  spec.version = "0.1.3"
96
- SPEC
97
- end
143
+ SPEC
144
+ end
98
145
 
99
- def test_with_patch
100
- @task = Changelog.new(options.merge(version_target: "patch"))
101
- mute_logger(@task)
146
+ def test_with_patch
147
+ @task = Changelog.new(options.merge(version_target: "patch"))
148
+ mute_logger(@task)
102
149
 
103
- @task.bump_version
150
+ @task.bump_version
104
151
 
105
- assert_equal(<<-SPEC, gemspec_path.read)
152
+ assert_equal(<<-SPEC, gemspec_path.read)
106
153
  spec.version = "0.1.3"
107
- SPEC
108
- end
154
+ SPEC
155
+ end
109
156
 
110
- def test_with_minor
111
- @task = Changelog.new(options.merge(version_target: "minor"))
112
- mute_logger(@task)
157
+ def test_with_minor
158
+ @task = Changelog.new(options.merge(version_target: "minor"))
159
+ mute_logger(@task)
113
160
 
114
- @task.bump_version
161
+ @task.bump_version
115
162
 
116
- assert_equal(<<-SPEC, gemspec_path.read)
163
+ assert_equal(<<-SPEC, gemspec_path.read)
117
164
  spec.version = "0.2.0"
118
- SPEC
119
- end
165
+ SPEC
166
+ end
120
167
 
121
- def test_with_major
122
- @task = Changelog.new(options.merge(version_target: "major"))
123
- mute_logger(@task)
168
+ def test_with_major
169
+ @task = Changelog.new(options.merge(version_target: "major"))
170
+ mute_logger(@task)
124
171
 
125
- @task.bump_version
172
+ @task.bump_version
126
173
 
127
- assert_equal(<<-SPEC, gemspec_path.read)
174
+ assert_equal(<<-SPEC, gemspec_path.read)
128
175
  spec.version = "1.0.0"
129
- SPEC
176
+ SPEC
177
+ end
130
178
  end
179
+
131
180
  end
132
181
 
133
182
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_release_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - yoshihara
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-07-13 00:00:00.000000000 Z
12
+ date: 2016-07-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -103,10 +103,10 @@ executables: []
103
103
  extensions: []
104
104
  extra_rdoc_files: []
105
105
  files:
106
+ - ".gitignore"
106
107
  - ".travis.yml"
107
108
  - CHANGELOG.md
108
109
  - Gemfile
109
- - Gemfile.lock
110
110
  - LICENSE.txt
111
111
  - README.md
112
112
  - Rakefile
data/Gemfile.lock DELETED
@@ -1,57 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- gem_release_helper (1.0.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- codeclimate-test-reporter (0.4.7)
10
- simplecov (>= 0.7.1, < 1.0.0)
11
- coderay (1.1.0)
12
- docile (1.1.5)
13
- ffi (1.9.10-java)
14
- json (1.8.3)
15
- json (1.8.3-java)
16
- method_source (0.8.2)
17
- power_assert (0.2.3)
18
- pry (0.10.1)
19
- coderay (~> 1.1.0)
20
- method_source (~> 0.8.1)
21
- slop (~> 3.4)
22
- pry (0.10.1-java)
23
- coderay (~> 1.1.0)
24
- method_source (~> 0.8.1)
25
- slop (~> 3.4)
26
- spoon (~> 0.0)
27
- rake (10.4.2)
28
- rr (1.1.2)
29
- simplecov (0.10.0)
30
- docile (~> 1.1.0)
31
- json (~> 1.8)
32
- simplecov-html (~> 0.10.0)
33
- simplecov-html (0.10.0)
34
- slop (3.6.0)
35
- spoon (0.0.4)
36
- ffi
37
- test-unit (3.1.2)
38
- power_assert
39
- test-unit-rr (1.0.3)
40
- rr (>= 1.1.1)
41
- test-unit (>= 2.5.2)
42
-
43
- PLATFORMS
44
- java
45
- ruby
46
-
47
- DEPENDENCIES
48
- bundler (~> 1.7)
49
- codeclimate-test-reporter
50
- gem_release_helper!
51
- pry
52
- rake (~> 10.0)
53
- test-unit
54
- test-unit-rr
55
-
56
- BUNDLED WITH
57
- 1.12.5