sashimi_tanpopo 0.3.4 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/Dockerfile +1 -1
- data/docs/RECIPE.md +6 -0
- data/lib/sashimi_tanpopo/dsl.rb +59 -2
- data/lib/sashimi_tanpopo/version.rb +1 -1
- data/rbs_collection.lock.yaml +16 -20
- data/sig/sashimi_tanpopo/dsl.rbs +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 46221b29210109fddc0ba6ab25f4f22223996df144ba244836c8d327cfc2df60
|
|
4
|
+
data.tar.gz: 7f25ee609285783d8a06bf5d2b399b1bc4378530fece6e94fa4b930a823e527a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 809ade0b7206286166287964dc0bb4b8ebf2f4f559fe556bb9eaf7c7a0536f9714f03055dde888bd4f92561e90fb507910351a9b6e2dc7e656caf28051a67235
|
|
7
|
+
data.tar.gz: decfb336b8a602063f136b05c4f9db60a96f990819c722ef44e108659e897513ed3422b8716a61ebccf9582be46d30a9bc8768e55fdcb802d6fea17c6a4aae66
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
## [Unreleased]
|
|
2
|
-
[full changelog](http://github.com/sue445/sashimi_tanpopo/compare/v0.
|
|
2
|
+
[full changelog](http://github.com/sue445/sashimi_tanpopo/compare/v0.4.0...main)
|
|
3
|
+
|
|
4
|
+
## [v0.3.4](https://github.com/sue445/sashimi_tanpopo/releases/tag/v0.4.0) - 2025-12-03
|
|
5
|
+
[full changelog](http://github.com/sue445/sashimi_tanpopo/compare/v0.3.4...v0.4.0)
|
|
6
|
+
|
|
7
|
+
* Add `create` arg to `update_file`
|
|
8
|
+
* https://github.com/sue445/sashimi_tanpopo/pull/80
|
|
3
9
|
|
|
4
10
|
## [v0.3.4](https://github.com/sue445/sashimi_tanpopo/releases/tag/v0.3.4) - 2025-11-30
|
|
5
11
|
[full changelog](http://github.com/sue445/sashimi_tanpopo/compare/v0.3.3...v0.3.4)
|
data/Dockerfile
CHANGED
data/docs/RECIPE.md
CHANGED
|
@@ -53,11 +53,17 @@ end
|
|
|
53
53
|
update_file ".github/workflows/*.yml" do |content|
|
|
54
54
|
content.gsub!(/ruby-version: "(.+)"/, %Q{ruby-version: "#{params[:ruby_version]}"})
|
|
55
55
|
end
|
|
56
|
+
|
|
57
|
+
# Create new file if file doesn’t exist
|
|
58
|
+
update_file "new_file.txt", create: true do |content|
|
|
59
|
+
content.replace("My name is " + params[:name])
|
|
60
|
+
end
|
|
56
61
|
```
|
|
57
62
|
|
|
58
63
|
Parameters:
|
|
59
64
|
|
|
60
65
|
* `pattern`: Path to target file (relative path from `--target-dir`). This supports [`Dir.glob`](https://ruby-doc.org/current/Dir.html#method-c-glob) pattern. (e.g. `.github/workflows/*.yml`)
|
|
66
|
+
* `create` (defaults to `false`): Whether create new file if file doesn’t exist
|
|
61
67
|
|
|
62
68
|
Yield Parameters:
|
|
63
69
|
|
data/lib/sashimi_tanpopo/dsl.rb
CHANGED
|
@@ -116,6 +116,7 @@ module SashimiTanpopo
|
|
|
116
116
|
# Update files if exists
|
|
117
117
|
#
|
|
118
118
|
# @param pattern [String] Path to target file (relative path from `--target-dir`). This supports [`Dir.glob`](https://ruby-doc.org/current/Dir.html#method-c-glob) pattern. (e.g. `.github/workflows/*.yml`)
|
|
119
|
+
# @param create [Boolean] Whether create new file if file doesn't exist
|
|
119
120
|
#
|
|
120
121
|
# @yieldparam content [String] Content of file. If `content` is changed in block, file will be changed.
|
|
121
122
|
#
|
|
@@ -128,7 +129,21 @@ module SashimiTanpopo
|
|
|
128
129
|
# update_file ".github/workflows/*.yml" do |content|
|
|
129
130
|
# content.gsub!(/ruby-version: "(.+)"/, %Q{ruby-version: "#{params[:ruby_version]}"})
|
|
130
131
|
# end
|
|
131
|
-
|
|
132
|
+
#
|
|
133
|
+
# @example Create new file if file doesn't exist
|
|
134
|
+
# update_file "new_file.txt", create: true do |content|
|
|
135
|
+
# content.replace("My name is " + params[:name])
|
|
136
|
+
# end
|
|
137
|
+
def update_file(pattern, create: false, &block)
|
|
138
|
+
update_file_with_glob(pattern, &block)
|
|
139
|
+
create_new_file(pattern, &block) if create
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
private
|
|
143
|
+
|
|
144
|
+
# @param pattern [String]
|
|
145
|
+
# @yieldparam content [String] Content of file. If `content` is changed in block, file will be changed.
|
|
146
|
+
def update_file_with_glob(pattern, &block)
|
|
132
147
|
Dir.glob(pattern).each do |path|
|
|
133
148
|
full_file_path = File.join(@__target_dir__, path)
|
|
134
149
|
|
|
@@ -170,7 +185,49 @@ module SashimiTanpopo
|
|
|
170
185
|
end
|
|
171
186
|
end
|
|
172
187
|
|
|
173
|
-
|
|
188
|
+
# @param path [String]
|
|
189
|
+
# @yieldparam content [String] Content of file. If `content` is changed in block, file will be changed.
|
|
190
|
+
def create_new_file(path, &block)
|
|
191
|
+
return if glob_pattern?(path)
|
|
192
|
+
|
|
193
|
+
full_file_path = File.join(@__target_dir__, path)
|
|
194
|
+
|
|
195
|
+
return if File.exist?(full_file_path)
|
|
196
|
+
|
|
197
|
+
SashimiTanpopo.logger.info "Checking #{full_file_path}"
|
|
198
|
+
|
|
199
|
+
before_content = ""
|
|
200
|
+
after_content = update_single_file(before_content, &block)
|
|
201
|
+
|
|
202
|
+
unless after_content
|
|
203
|
+
SashimiTanpopo.logger.info "#{full_file_path} isn't created"
|
|
204
|
+
return
|
|
205
|
+
end
|
|
206
|
+
|
|
207
|
+
File.write(full_file_path, after_content) if !dry_run? && @__is_update_local__
|
|
208
|
+
|
|
209
|
+
if changed_files[path]
|
|
210
|
+
changed_files[path][:after_content] = after_content
|
|
211
|
+
else
|
|
212
|
+
changed_files[path] = {
|
|
213
|
+
before_content: before_content,
|
|
214
|
+
after_content: after_content,
|
|
215
|
+
mode: File.stat(full_file_path).mode.to_s(8)
|
|
216
|
+
}
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
if dry_run?
|
|
220
|
+
SashimiTanpopo.logger.info "#{full_file_path} will be created (dryrun)"
|
|
221
|
+
else
|
|
222
|
+
SashimiTanpopo.logger.info "#{full_file_path} is created"
|
|
223
|
+
end
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
# @param pattern [String]
|
|
227
|
+
# @return [Boolean]
|
|
228
|
+
def glob_pattern?(pattern)
|
|
229
|
+
["*", "?", "[", "]", "{", "}", "**/"].any? { |str| pattern.include?(str) }
|
|
230
|
+
end
|
|
174
231
|
|
|
175
232
|
# @param content [String]
|
|
176
233
|
#
|
data/rbs_collection.lock.yaml
CHANGED
|
@@ -6,7 +6,7 @@ gems:
|
|
|
6
6
|
source:
|
|
7
7
|
type: git
|
|
8
8
|
name: ruby/gem_rbs_collection
|
|
9
|
-
revision:
|
|
9
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
10
10
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
11
11
|
repo_dir: gems
|
|
12
12
|
- name: base64
|
|
@@ -14,7 +14,7 @@ gems:
|
|
|
14
14
|
source:
|
|
15
15
|
type: git
|
|
16
16
|
name: ruby/gem_rbs_collection
|
|
17
|
-
revision:
|
|
17
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
18
18
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
19
19
|
repo_dir: gems
|
|
20
20
|
- name: bigdecimal
|
|
@@ -22,7 +22,7 @@ gems:
|
|
|
22
22
|
source:
|
|
23
23
|
type: git
|
|
24
24
|
name: ruby/gem_rbs_collection
|
|
25
|
-
revision:
|
|
25
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
26
26
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
27
27
|
repo_dir: gems
|
|
28
28
|
- name: csv
|
|
@@ -30,13 +30,9 @@ gems:
|
|
|
30
30
|
source:
|
|
31
31
|
type: git
|
|
32
32
|
name: ruby/gem_rbs_collection
|
|
33
|
-
revision:
|
|
33
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
34
34
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
35
35
|
repo_dir: gems
|
|
36
|
-
- name: date
|
|
37
|
-
version: '0'
|
|
38
|
-
source:
|
|
39
|
-
type: stdlib
|
|
40
36
|
- name: dbm
|
|
41
37
|
version: '0'
|
|
42
38
|
source:
|
|
@@ -46,7 +42,7 @@ gems:
|
|
|
46
42
|
source:
|
|
47
43
|
type: git
|
|
48
44
|
name: ruby/gem_rbs_collection
|
|
49
|
-
revision:
|
|
45
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
50
46
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
51
47
|
repo_dir: gems
|
|
52
48
|
- name: diffy
|
|
@@ -54,7 +50,7 @@ gems:
|
|
|
54
50
|
source:
|
|
55
51
|
type: git
|
|
56
52
|
name: ruby/gem_rbs_collection
|
|
57
|
-
revision:
|
|
53
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
58
54
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
59
55
|
repo_dir: gems
|
|
60
56
|
- name: erb
|
|
@@ -66,7 +62,7 @@ gems:
|
|
|
66
62
|
source:
|
|
67
63
|
type: git
|
|
68
64
|
name: ruby/gem_rbs_collection
|
|
69
|
-
revision:
|
|
65
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
70
66
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
71
67
|
repo_dir: gems
|
|
72
68
|
- name: fileutils
|
|
@@ -82,7 +78,7 @@ gems:
|
|
|
82
78
|
source:
|
|
83
79
|
type: git
|
|
84
80
|
name: ruby/gem_rbs_collection
|
|
85
|
-
revision:
|
|
81
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
86
82
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
87
83
|
repo_dir: gems
|
|
88
84
|
- name: hashdiff
|
|
@@ -90,7 +86,7 @@ gems:
|
|
|
90
86
|
source:
|
|
91
87
|
type: git
|
|
92
88
|
name: ruby/gem_rbs_collection
|
|
93
|
-
revision:
|
|
89
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
94
90
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
95
91
|
repo_dir: gems
|
|
96
92
|
- name: httparty
|
|
@@ -98,7 +94,7 @@ gems:
|
|
|
98
94
|
source:
|
|
99
95
|
type: git
|
|
100
96
|
name: ruby/gem_rbs_collection
|
|
101
|
-
revision:
|
|
97
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
102
98
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
103
99
|
repo_dir: gems
|
|
104
100
|
- name: io-console
|
|
@@ -118,7 +114,7 @@ gems:
|
|
|
118
114
|
source:
|
|
119
115
|
type: git
|
|
120
116
|
name: ruby/gem_rbs_collection
|
|
121
|
-
revision:
|
|
117
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
122
118
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
123
119
|
repo_dir: gems
|
|
124
120
|
- name: monitor
|
|
@@ -138,7 +134,7 @@ gems:
|
|
|
138
134
|
source:
|
|
139
135
|
type: git
|
|
140
136
|
name: ruby/gem_rbs_collection
|
|
141
|
-
revision:
|
|
137
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
142
138
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
143
139
|
repo_dir: gems
|
|
144
140
|
- name: parallel
|
|
@@ -146,7 +142,7 @@ gems:
|
|
|
146
142
|
source:
|
|
147
143
|
type: git
|
|
148
144
|
name: ruby/gem_rbs_collection
|
|
149
|
-
revision:
|
|
145
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
150
146
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
151
147
|
repo_dir: gems
|
|
152
148
|
- name: pp
|
|
@@ -170,7 +166,7 @@ gems:
|
|
|
170
166
|
source:
|
|
171
167
|
type: git
|
|
172
168
|
name: ruby/gem_rbs_collection
|
|
173
|
-
revision:
|
|
169
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
174
170
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
175
171
|
repo_dir: gems
|
|
176
172
|
- name: rdoc
|
|
@@ -186,7 +182,7 @@ gems:
|
|
|
186
182
|
source:
|
|
187
183
|
type: git
|
|
188
184
|
name: ruby/gem_rbs_collection
|
|
189
|
-
revision:
|
|
185
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
190
186
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
191
187
|
repo_dir: gems
|
|
192
188
|
- name: timeout
|
|
@@ -206,7 +202,7 @@ gems:
|
|
|
206
202
|
source:
|
|
207
203
|
type: git
|
|
208
204
|
name: ruby/gem_rbs_collection
|
|
209
|
-
revision:
|
|
205
|
+
revision: f1d2dae32fe8d46683fbc79bbd0f1ca391d5e11a
|
|
210
206
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
|
211
207
|
repo_dir: gems
|
|
212
208
|
gemfile_lock_path: Gemfile.lock
|
data/sig/sashimi_tanpopo/dsl.rbs
CHANGED
|
@@ -41,10 +41,16 @@ module SashimiTanpopo
|
|
|
41
41
|
|
|
42
42
|
def dry_run?: () -> bool
|
|
43
43
|
|
|
44
|
-
def update_file: (String pattern) { (String) -> void } -> void
|
|
44
|
+
def update_file: (String pattern, ?create: bool) { (String) -> void } -> void
|
|
45
45
|
|
|
46
46
|
private
|
|
47
47
|
|
|
48
|
+
def update_file_with_glob: (String pattern) { (String) -> void } -> void
|
|
49
|
+
|
|
50
|
+
def create_new_file: (String path) { (String) -> void } -> void
|
|
51
|
+
|
|
52
|
+
def glob_pattern?: (String pattern) -> bool
|
|
53
|
+
|
|
48
54
|
def update_single_file: (String content) { (String) -> void } -> String?
|
|
49
55
|
|
|
50
56
|
def show_diff: (String str1, String str2) -> void
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: sashimi_tanpopo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- sue445
|
|
@@ -304,7 +304,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
304
304
|
- !ruby/object:Gem::Version
|
|
305
305
|
version: '0'
|
|
306
306
|
requirements: []
|
|
307
|
-
rubygems_version: 3.6.
|
|
307
|
+
rubygems_version: 3.6.9
|
|
308
308
|
specification_version: 4
|
|
309
309
|
summary: Change files and create patches
|
|
310
310
|
test_files: []
|