gem_toys 0.8.0 → 0.11.3

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
  SHA256:
3
- metadata.gz: 9c89427d93a3acd0536e28862539e50772f24059fec9253777560e9eba89cf03
4
- data.tar.gz: 88dffcbdad90618b055900461bb2b37b946acf518570e584126bfb6ce2619b49
3
+ metadata.gz: 8965f382c94df6d80fe518d8f793caddcc03c9cde2f44ecb2839ec793891b34c
4
+ data.tar.gz: 9a086af4b57fa16f76b087517be7d1d3424e0bd6375497cd540d31e17e6f22be
5
5
  SHA512:
6
- metadata.gz: bba6338814ad5bb019833a4c1acb9441a6307e555edbe73f96326bcf3f0d156ead648bdd5eef444fedad74cecc15a6e940b60fc98ee7326de8b0c04d145751b0
7
- data.tar.gz: 18d291e6dd2cd6dd3b94b4cd05295274d88accf9698d5b2827d369c08e49552f82275ca27d2f2d36b6c544c4a2882ac3e37d5c42b3e4c20b17f04ba4b1a4713f
6
+ metadata.gz: b2c1cf7cde1630c2ac291b938896044abe8641b212bbd4ade5ee618787af8da12673ecb7e7831c755876db9de2bc9d112beeec815978f554b9b118da04f3b338
7
+ data.tar.gz: 216931acc276ab4e9ddaf88345d98d63e08fa8281b663996bc6aba0d5d2312caf2c2d096f6761e0929677eebab1ecf4da460d0356425d4c723f71259f7f7370f
data/CHANGELOG.md CHANGED
@@ -1,6 +1,38 @@
1
1
  # Changelog
2
2
 
3
- ## master (unreleased)
3
+ ## Unreleased
4
+
5
+ ## 0.11.3 (2021-11-10)
6
+
7
+ * Resolve RuboCop offense, take out manual check menu choices.
8
+
9
+ ## 0.11.2 (2021-11-07)
10
+
11
+ * Fix version for gem staff after manual refresh too.
12
+
13
+ ## 0.11.1 (2021-11-07)
14
+
15
+ * Fix new version for git staff after manual refresh.
16
+
17
+ ## 0.11.0 (2021-10-29)
18
+
19
+ * Revert version and changelog files changes at rejection.
20
+ * Revert version file changes at changelog fails.
21
+ * Update development dependencies.
22
+
23
+ ## 0.10.0 (2021-10-15)
24
+
25
+ * Process cases with non-JSON String from RubyGems.org.
26
+ * Update development dependencies.
27
+ * Resolve new offenses from RuboCop.
28
+ * Change default for unreleased in Changelog.
29
+
30
+ ## 0.9.0 (2021-08-26)
31
+
32
+ * Fix built gem version after `refresh` answer.
33
+ * Update development dependencies.
34
+ * Lock RuboCop version better.
35
+ * Resolve new RuboCop offenses.
4
36
 
5
37
  ## 0.8.0 (2021-04-16)
6
38
 
data/README.md CHANGED
@@ -38,8 +38,8 @@ require 'gem_toys'
38
38
  expand GemToys::Template,
39
39
  ## default is `CHANGELOG.md`
40
40
  changelog_file_name: 'ChangeLog.md',
41
- ## default is `## master (unreleased)`
42
- unreleased_title: '## Unreleased',
41
+ ## default is `## Unreleased`
42
+ unreleased_title: '## main (unreleased)',
43
43
  ## default is `"lib/#{project_name_with_slashes_instead_dashes}/version.rb"`
44
44
  version_file_path: 'lib/my-awesome_gem.rb',
45
45
  ## default is `v`, so tags are like `v4.1.0`
@@ -63,7 +63,7 @@ alias_tool :g, :gem
63
63
 
64
64
  1. Update `lib/*gem_name*/version.rb` file.
65
65
  Can be refined with `:version_file_path` option on `expand`.
66
- 2. Insert Markdown title with changes from `## master (unreleased)` in a `CHANGELOG.md` file.
66
+ 2. Insert Markdown title with changes from `## Unreleased` in a `CHANGELOG.md` file.
67
67
  Can be refined with `:unreleased_title` option on `expand`.
68
68
  3. [Builds](#build) a gem.
69
69
  4. Ask you for manual check, if you want (print anything of OK).
@@ -28,6 +28,10 @@ module GemToys
28
28
  end
29
29
 
30
30
  memoize def current_version
31
+ parse_version_from_file
32
+ end
33
+
34
+ def parse_version_from_file
31
35
  version_file_content.match(/VERSION = '(.+)'/)[1]
32
36
  end
33
37
 
@@ -51,13 +55,21 @@ module GemToys
51
55
  require 'faraday'
52
56
  require 'faraday_middleware'
53
57
 
54
- Faraday.new 'https://rubygems.org/api/v1' do |conn|
55
- conn.response :json, parser_options: { symbolize_names: true }
58
+ Faraday.new 'https://rubygems.org/api/v1' do |connection|
59
+ connection.response :json,
60
+ content_type: /\bjson$/,
61
+ parser_options: { symbolize_names: true }
56
62
  end
57
63
  end
58
64
 
59
65
  memoize def rubygems_versions
60
- rubygems_connection.get("versions/#{project_name}.json").body
66
+ response = rubygems_connection.get("versions/#{project_name}.json").body
67
+
68
+ return response if response.is_a?(Array)
69
+
70
+ return [] if response == 'This rubygem could not be found.'
71
+
72
+ raise "Unexpected response from RubyGems.org: #{response.inspect}"
61
73
  end
62
74
 
63
75
  def current_version_hash
@@ -28,11 +28,14 @@ module GemToys
28
28
 
29
29
  unreleased_title_index = @changelog_lines.index("#{unreleased_title}\n")
30
30
 
31
- abort_without_unreleased_title unless unreleased_title_index
31
+ unless unreleased_title_index
32
+ sh "git restore --worktree #{version_file_path}"
33
+ abort_without_unreleased_title
34
+ end
32
35
 
33
36
  @changelog_lines.insert(
34
37
  unreleased_title_index + 2,
35
- '#' * unreleased_title.scan(/^#+/).first.size + " #{@new_version} (#{@today})\n\n"
38
+ ('#' * unreleased_title.scan(/^#+/).first.size) + " #{@new_version} (#{@today})\n\n"
36
39
  ).join
37
40
  end
38
41
 
@@ -8,16 +8,17 @@ module GemToys
8
8
  private
9
9
 
10
10
  def process_git
11
- new_version_git_tag = "#{@template.version_tag_prefix}#{@new_version}"
11
+ ## `current_version` should be refreshed before this method invocation
12
+ version_git_tag = "#{@template.version_tag_prefix}#{current_version}"
12
13
 
13
14
  ## Checkout to a new git branch, required for protected `master` with CI
14
- # sh "git switch -c #{new_version_git_tag}"
15
+ # sh "git switch -c #{version_git_tag}"
15
16
 
16
17
  commit_changes
17
18
 
18
19
  ## Tag commit
19
20
  puts 'Tagging the commit...'
20
- sh "git tag -a #{new_version_git_tag} -m 'Version #{@new_version}'"
21
+ sh "git tag -a #{version_git_tag} -m 'Version #{current_version}'"
21
22
 
22
23
  ## Push commit
23
24
  puts 'Pushing commit...'
@@ -33,7 +34,7 @@ module GemToys
33
34
 
34
35
  sh "git add #{version_file_path} #{changelog_file_path}"
35
36
 
36
- sh "git commit -m 'Update version to #{@new_version}'"
37
+ sh "git commit -m 'Update version to #{current_version}'"
37
38
  end
38
39
  end
39
40
  end
@@ -46,11 +46,11 @@ module GemToys
46
46
  ## Update CHANGELOG
47
47
  update_changelog_file
48
48
 
49
+ wait_for_manual_check
50
+
49
51
  ## Build new gem file
50
52
  exec_tool 'gem build'
51
53
 
52
- wait_for_manual_check
53
-
54
54
  ## Commit, tag, push
55
55
  process_git
56
56
 
@@ -76,8 +76,6 @@ module GemToys
76
76
  else
77
77
  new_version
78
78
  end
79
-
80
- clear_memery_cache! :current_version
81
79
  end
82
80
 
83
81
  def handle_keyword_in_new_version(current_version_parts, version_index)
@@ -102,19 +100,47 @@ module GemToys
102
100
  end
103
101
 
104
102
  def wait_for_manual_check
103
+ print_files_diff
104
+
105
+ manual_check_menu
106
+ end
107
+
108
+ def print_files_diff
105
109
  $stdout.puts
106
110
  sh "git diff #{version_file_path} #{changelog_file_path}"
107
111
  $stdout.puts
112
+ end
108
113
 
114
+ self::MANUAL_CHECK_MENU = {
115
+ yes: (proc do
116
+ ## `current_version` is using in `git` and `gem` commands
117
+ clear_memery_cache! :current_version
118
+ end),
119
+ no: (proc do
120
+ handle_refusing_to_continue
121
+ end),
122
+ refresh: (proc do
123
+ wait_for_manual_check
124
+ end)
125
+ }.freeze
126
+
127
+ def manual_check_menu
109
128
  HighLine.new.choose do |menu|
110
129
  menu.layout = :one_line
111
130
 
112
131
  menu.prompt = 'Are these changes correct? '
113
132
 
114
- menu.choice(:yes)
115
- menu.choice(:no) { abort }
116
- menu.choice(:refresh) { send(__method__) }
133
+ self.class::MANUAL_CHECK_MENU.each do |choice, block|
134
+ menu.choice(choice) { instance_exec(&block) }
135
+ end
136
+ end
137
+ end
138
+
139
+ def handle_refusing_to_continue
140
+ [version_file_path, changelog_file_path].each do |file_path|
141
+ sh "git restore --worktree #{file_path}"
117
142
  end
143
+ abort
118
144
  end
119
145
  end
120
146
  end
@@ -19,7 +19,9 @@ module GemToys
19
19
 
20
20
  versions = rubygems_versions
21
21
 
22
- versions.unshift current_version_hash if current_version != versions.first[:number]
22
+ if versions.empty? || current_version != versions.first[:number]
23
+ versions.unshift current_version_hash
24
+ end
23
25
 
24
26
  puts_versions versions
25
27
  end
@@ -15,7 +15,7 @@ module GemToys
15
15
  changelog_file_name: 'CHANGELOG.md',
16
16
  version_file_path: nil,
17
17
  version_tag_prefix: 'v',
18
- unreleased_title: '## master (unreleased)'
18
+ unreleased_title: '## Unreleased'
19
19
  )
20
20
  @changelog_file_name = changelog_file_name
21
21
  @version_file_path = version_file_path
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module GemToys
4
- VERSION = '0.8.0'
4
+ VERSION = '0.11.3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gem_toys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.11.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Popov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alt_memery
@@ -100,28 +100,28 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.11.0
103
+ version: 0.12.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.11.0
110
+ version: 0.12.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: codecov
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 0.5.0
117
+ version: 0.6.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 0.5.0
124
+ version: 0.6.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - "~>"
158
158
  - !ruby/object:Gem::Version
159
- version: '1.2'
159
+ version: 1.22.2
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
- version: '1.2'
166
+ version: 1.22.2
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rubocop-performance
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubygems_version: 3.2.15
240
+ rubygems_version: 3.2.22
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: Toys template for gems