bake-modernize 0.13.1 → 0.13.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/bake/modernize/frozen_string_literal.rb +50 -0
- data/bake/modernize.rb +1 -1
- data/lib/bake/modernize/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +2 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf86cb6271ebbf9ed15d1909a86717bbbf62e8841c418a6f969899bece3ca76
|
4
|
+
data.tar.gz: 84836cfd97548092a8fe01144b94f7ffaff0c8aec0b81ecee02a8e23602c4d0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1eb461c262b102a09ef679c786d2eb4aa219d4a1fd02f8c5c62ad6e28b405a8732322f08ee9276a95ec794a7afbba1ec48965d7407e93199385bfdee7664348c
|
7
|
+
data.tar.gz: 17fcdc0fb3d60ab8c71858c8f9b98732562bcb18842495426304f4a31fd6b518db86c0d98a8fa221ac35224f20442afae5b412392d2af81c9d5ef214c08b0350
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
def frozen_string_literal
|
4
|
+
update(root: Dir.pwd)
|
5
|
+
end
|
6
|
+
|
7
|
+
def update(root:)
|
8
|
+
Dir.glob("**/*.rb", base: root).each do |path|
|
9
|
+
case path
|
10
|
+
when /\.rb$/
|
11
|
+
update_source_file(path)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def update_source_file(path)
|
19
|
+
input = File.readlines(path)
|
20
|
+
output = []
|
21
|
+
|
22
|
+
# Skip the hash-bang line:
|
23
|
+
if input.first =~ /^\#!/
|
24
|
+
output.push input.shift
|
25
|
+
end
|
26
|
+
|
27
|
+
options = {}
|
28
|
+
|
29
|
+
while input.first =~ /^\#\s*(.*?):(.*)$/
|
30
|
+
options[$1.strip] = $2.strip
|
31
|
+
input.shift
|
32
|
+
end
|
33
|
+
|
34
|
+
options['frozen_string_literal'] ||= 'true'
|
35
|
+
|
36
|
+
options.each do |key, value|
|
37
|
+
output.push "# #{key}: #{value}"
|
38
|
+
end
|
39
|
+
|
40
|
+
unless input.first.chomp.empty?
|
41
|
+
output.push "\n"
|
42
|
+
end
|
43
|
+
|
44
|
+
# Add the rest of the file:
|
45
|
+
output.push(*input)
|
46
|
+
|
47
|
+
File.open(path, "w") do |file|
|
48
|
+
file.puts(output)
|
49
|
+
end
|
50
|
+
end
|
data/bake/modernize.rb
CHANGED
@@ -4,5 +4,5 @@
|
|
4
4
|
# Copyright, 2020-2022, by Samuel Williams.
|
5
5
|
|
6
6
|
def modernize
|
7
|
-
call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license')
|
7
|
+
call('modernize:git', 'modernize:readme', 'modernize:actions', 'modernize:editorconfig', 'modernize:gemfile', 'modernize:signing', 'modernize:gemspec', 'modernize:license', 'modernize:frozen_string_literal')
|
8
8
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bake-modernize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.13.
|
4
|
+
version: 0.13.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
@@ -133,6 +133,7 @@ files:
|
|
133
133
|
- bake/modernize.rb
|
134
134
|
- bake/modernize/actions.rb
|
135
135
|
- bake/modernize/editorconfig.rb
|
136
|
+
- bake/modernize/frozen_string_literal.rb
|
136
137
|
- bake/modernize/gemfile.rb
|
137
138
|
- bake/modernize/gemspec.rb
|
138
139
|
- bake/modernize/git.rb
|
metadata.gz.sig
CHANGED
Binary file
|