gem_toys 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +14 -0
- data/lib/gem_toys/template.rb +38 -46
- data/lib/gem_toys/template/common_code.rb +48 -0
- data/lib/gem_toys/version.rb +1 -1
- metadata +11 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f12dea34e3f97cd2d22bbe74577876988d63b14135f3881688adffb0aa1fe27
|
4
|
+
data.tar.gz: 3e7133b5a0c2b082d8108b63fcc403b86c52360c32faf4764eb569ae07052aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 846247b5a5f1b69e4fde49feda00a66494a3ee4f6ca867dfd564723772749bcf25184560ae07e86c58f78a1b6beb07eb15562abfd925e8d58d5397a58c6916c5
|
7
|
+
data.tar.gz: 2587c1b34d42976accf1ef5b63b53b35ca068f4d26a89620d9ed349f215e01630d072fc520ac484b199cb264045dfc067e3ec89d644c32bcb3adda6ed1d057bf
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.2.0 (2020-07-09)
|
6
|
+
|
7
|
+
* Add `:version_file_path` and `:unreleased_title` options
|
8
|
+
* Change the order of tasks: check (manually) before committing.
|
9
|
+
* Include `:exec` only unless already included.
|
10
|
+
* Improve usage documentation.
|
11
|
+
* Add output of process steps.
|
12
|
+
|
5
13
|
## 0.1.0 (2020-07-08)
|
6
14
|
|
7
15
|
* Initial commit
|
data/README.md
CHANGED
@@ -41,6 +41,20 @@ expand GemToys::Template
|
|
41
41
|
alias_tool :g, :gem
|
42
42
|
```
|
43
43
|
|
44
|
+
At invocation it will:
|
45
|
+
|
46
|
+
1. Update `lib/*gem_name*/version.rb` file.
|
47
|
+
Can be refined with `:version_file_path` option on `expand`.
|
48
|
+
2. Insert Markdown title with changes from `## master (unreleased)` in a `CHANGELOG.md` file.
|
49
|
+
Can be refined with `:unreleased_title` option on `expand`.
|
50
|
+
3. Execute `gem build`.
|
51
|
+
4. Ask you for manual check, if you want (print anything of OK).
|
52
|
+
You also can change manually a content of `CHANGELOG.md`, for example, before committing.
|
53
|
+
5. Commit these files.
|
54
|
+
6. Tag this commit with `vX.Y.Z`.
|
55
|
+
7. Push git commit and tag.
|
56
|
+
8. Push the new gem.
|
57
|
+
|
44
58
|
## Development
|
45
59
|
|
46
60
|
After checking out the repo, run `bundle install` to install dependencies.
|
data/lib/gem_toys/template.rb
CHANGED
@@ -3,58 +3,34 @@
|
|
3
3
|
require 'date'
|
4
4
|
require 'toys-core'
|
5
5
|
|
6
|
+
require_relative 'template/common_code'
|
7
|
+
|
6
8
|
module GemToys
|
7
9
|
## Template with gem tools, should be expanded in toys file
|
8
10
|
class Template
|
9
11
|
include Toys::Template
|
10
12
|
|
11
|
-
|
12
|
-
module CommonCode
|
13
|
-
private
|
14
|
-
|
15
|
-
def project_name
|
16
|
-
@project_name ||= File.basename context_directory
|
17
|
-
end
|
18
|
-
|
19
|
-
def version_file_path
|
20
|
-
project_path = project_name.tr '-', '/'
|
21
|
-
@version_file_path ||= File.join context_directory, 'lib', project_path, 'version.rb'
|
22
|
-
end
|
23
|
-
|
24
|
-
def version_file_content
|
25
|
-
File.read version_file_path
|
26
|
-
end
|
27
|
-
|
28
|
-
def current_version
|
29
|
-
@current_version ||= version_file_content.match(/VERSION = '(.+)'/)[1]
|
30
|
-
end
|
13
|
+
attr_reader :version_file_path, :unreleased_title
|
31
14
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def gem_file_name
|
37
|
-
@gem_file_name ||= "#{project_name}-#{current_version}.gem"
|
38
|
-
end
|
39
|
-
|
40
|
-
def pkg_directory
|
41
|
-
@pkg_directory ||= "#{context_directory}/pkg"
|
42
|
-
end
|
43
|
-
|
44
|
-
def current_gem_file
|
45
|
-
"#{pkg_directory}/#{gem_file_name}"
|
46
|
-
end
|
15
|
+
def initialize(version_file_path: nil, unreleased_title: '## master (unreleased)')
|
16
|
+
@version_file_path = version_file_path
|
17
|
+
@unreleased_title = unreleased_title
|
47
18
|
end
|
48
19
|
|
49
|
-
on_expand do
|
20
|
+
on_expand do |template|
|
50
21
|
tool :gem do
|
51
22
|
subtool_apply do
|
52
|
-
include :exec
|
23
|
+
unless include? :exec
|
24
|
+
include :exec, exit_on_nonzero_status: true, log_level: Logger::UNKNOWN
|
25
|
+
end
|
26
|
+
|
53
27
|
include CommonCode
|
54
28
|
end
|
55
29
|
|
56
30
|
tool :build do
|
57
|
-
|
31
|
+
to_run do
|
32
|
+
@template = template
|
33
|
+
|
58
34
|
sh 'gem build'
|
59
35
|
FileUtils.mkdir_p pkg_directory
|
60
36
|
FileUtils.mv "#{context_directory}/#{gem_file_name}", current_gem_file
|
@@ -62,7 +38,9 @@ module GemToys
|
|
62
38
|
end
|
63
39
|
|
64
40
|
tool :install do
|
65
|
-
|
41
|
+
to_run do
|
42
|
+
@template = template
|
43
|
+
|
66
44
|
exec_tool 'gem build'
|
67
45
|
sh "gem install #{current_gem_file}"
|
68
46
|
end
|
@@ -71,43 +49,53 @@ module GemToys
|
|
71
49
|
tool :release do
|
72
50
|
required_arg :version
|
73
51
|
|
74
|
-
|
52
|
+
to_run do
|
53
|
+
@template = template
|
54
|
+
|
75
55
|
update_version_file
|
76
56
|
|
77
57
|
## Update CHANGELOG
|
78
58
|
update_changelog_file
|
79
59
|
|
60
|
+
## Build new gem file
|
61
|
+
exec_tool 'gem build'
|
62
|
+
|
63
|
+
wait_for_manual_check
|
64
|
+
|
80
65
|
## Checkout to a new git branch, required for protected `master` with CI
|
81
66
|
# sh "git switch -c v#{version}"
|
82
67
|
|
83
68
|
commit_changes
|
84
69
|
|
85
70
|
## Tag commit
|
71
|
+
puts 'Tagging the commit...'
|
86
72
|
sh "git tag -a v#{version} -m 'Version #{version}'"
|
87
73
|
|
88
|
-
## Build new gem file
|
89
|
-
exec_tool 'gem build'
|
90
|
-
|
91
|
-
wait_for_manual_check
|
92
|
-
|
93
74
|
## Push commit
|
75
|
+
puts 'Pushing commit...'
|
94
76
|
sh 'git push'
|
95
77
|
|
96
78
|
## Push tags
|
79
|
+
puts 'Pushing tags...'
|
97
80
|
sh 'git push --tags'
|
98
81
|
|
82
|
+
puts 'Pushing gem...'
|
99
83
|
sh "gem push #{current_gem_file}"
|
100
84
|
end
|
101
85
|
|
102
86
|
private
|
103
87
|
|
104
88
|
def update_version_file
|
89
|
+
puts 'Updating version file...'
|
90
|
+
|
105
91
|
File.write version_file_path, version_file_content.sub(/'.+'/, "'#{version}'")
|
106
92
|
end
|
107
93
|
|
108
94
|
TODAY = Date.today.to_s
|
109
95
|
|
110
96
|
def update_changelog_file
|
97
|
+
puts 'Updating changelog file...'
|
98
|
+
|
111
99
|
@changelog_lines = File.readlines(changelog_file_path)
|
112
100
|
|
113
101
|
existing_line = find_version_line_in_changelog_file
|
@@ -126,12 +114,16 @@ module GemToys
|
|
126
114
|
end
|
127
115
|
|
128
116
|
def new_changelog_content
|
117
|
+
unreleased_title = @template.unreleased_title
|
129
118
|
@changelog_lines.insert(
|
130
|
-
@changelog_lines.index("
|
119
|
+
@changelog_lines.index("#{unreleased_title}\n") + 2,
|
120
|
+
'#' * unreleased_title.scan(/^#+/).first.size + " #{version} (#{TODAY})\n\n"
|
131
121
|
).join
|
132
122
|
end
|
133
123
|
|
134
124
|
def commit_changes
|
125
|
+
puts 'Committing changes...'
|
126
|
+
|
135
127
|
sh "git add #{version_file_path} #{changelog_file_path}"
|
136
128
|
|
137
129
|
sh "git commit -m 'Update version to #{version}'"
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GemToys
|
4
|
+
## Template with gem tools, should be expanded in toys file
|
5
|
+
class Template
|
6
|
+
## Module for common code between nested tools
|
7
|
+
module CommonCode
|
8
|
+
private
|
9
|
+
|
10
|
+
def project_name
|
11
|
+
@project_name ||= File.basename context_directory
|
12
|
+
end
|
13
|
+
|
14
|
+
def version_file_path
|
15
|
+
@version_file_path ||=
|
16
|
+
@template.version_file_path ||
|
17
|
+
begin
|
18
|
+
project_path = project_name.tr '-', '/'
|
19
|
+
File.join context_directory, 'lib', project_path, 'version.rb'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def version_file_content
|
24
|
+
File.read version_file_path
|
25
|
+
end
|
26
|
+
|
27
|
+
def current_version
|
28
|
+
@current_version ||= version_file_content.match(/VERSION = '(.+)'/)[1]
|
29
|
+
end
|
30
|
+
|
31
|
+
def changelog_file_path
|
32
|
+
@changelog_file_path ||= File.join context_directory, 'CHANGELOG.md'
|
33
|
+
end
|
34
|
+
|
35
|
+
def gem_file_name
|
36
|
+
@gem_file_name ||= "#{project_name}-#{current_version}.gem"
|
37
|
+
end
|
38
|
+
|
39
|
+
def pkg_directory
|
40
|
+
@pkg_directory ||= "#{context_directory}/pkg"
|
41
|
+
end
|
42
|
+
|
43
|
+
def current_gem_file
|
44
|
+
"#{pkg_directory}/#{gem_file_name}"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/gem_toys/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Popov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -59,6 +59,9 @@ dependencies:
|
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 0.1.0
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 0.1.18
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -66,6 +69,9 @@ dependencies:
|
|
66
69
|
- - "~>"
|
67
70
|
- !ruby/object:Gem::Version
|
68
71
|
version: 0.1.0
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: 0.1.18
|
69
75
|
- !ruby/object:Gem::Dependency
|
70
76
|
name: rspec
|
71
77
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +106,14 @@ dependencies:
|
|
100
106
|
requirements:
|
101
107
|
- - "~>"
|
102
108
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.
|
109
|
+
version: 0.87.0
|
104
110
|
type: :development
|
105
111
|
prerelease: false
|
106
112
|
version_requirements: !ruby/object:Gem::Requirement
|
107
113
|
requirements:
|
108
114
|
- - "~>"
|
109
115
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.
|
116
|
+
version: 0.87.0
|
111
117
|
- !ruby/object:Gem::Dependency
|
112
118
|
name: rubocop-performance
|
113
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -150,6 +156,7 @@ files:
|
|
150
156
|
- README.md
|
151
157
|
- lib/gem_toys.rb
|
152
158
|
- lib/gem_toys/template.rb
|
159
|
+
- lib/gem_toys/template/common_code.rb
|
153
160
|
- lib/gem_toys/version.rb
|
154
161
|
homepage: https://github.com/AlexWayfer/gem_toys
|
155
162
|
licenses:
|