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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a5383d60aadbc5f2385c81dd7a03fba4f571baee7f4286d9dfedca1eee1497a9
4
- data.tar.gz: cc5e62ac4f60879e04d4f73530ca47cac892fd7baa05f31e4d8783ee5df6d0e0
3
+ metadata.gz: bbf86cb6271ebbf9ed15d1909a86717bbbf62e8841c418a6f969899bece3ca76
4
+ data.tar.gz: 84836cfd97548092a8fe01144b94f7ffaff0c8aec0b81ecee02a8e23602c4d0c
5
5
  SHA512:
6
- metadata.gz: 76f7fec9e1bae6e30ece5a08fbb88dc10904f8507d81eb86a45ff8b32d755b9ac6f44b3076662f450cfc724351b0146255648e68df7107fce560e3a284c88835
7
- data.tar.gz: 869556c76b862400d67420e808b2ba94a85a78b3caf0924e6eb79bb883ecefb6e57ca2ce6f7ee8a79b1c9807107aaff059a9d70f8fb7430e19bb89da09f6dde3
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
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Bake
7
7
  module Modernize
8
- VERSION = "0.13.1"
8
+ VERSION = "0.13.2"
9
9
  end
10
10
  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.1
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