bake-modernize 0.13.0 → 0.13.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: 507d880a18b755b2e592bc82796792b377f68bd30d4484642649be42c35d8d78
4
- data.tar.gz: 15ce7824eba5fe510de11b18debe80ebc216d5c3a744629345c799725768f3cd
3
+ metadata.gz: 43ccc35944a73c49b82c67b6dfe17a0010f7653da8f3cf1c861915a4be1a5017
4
+ data.tar.gz: 885e420146d6319d69949d12da0ef15d6af06001e42b3cbfa8dcd5bdb038ee1e
5
5
  SHA512:
6
- metadata.gz: 77db80d99def59dd5b9c84232a466bc22f44b2c150df7817258bfa1c7304fb44e92678fe7079dddef6a17b276873bc41cdb7fd341d0641149c65182ef541c79c
7
- data.tar.gz: 8396c9466c40041b44b71f1a00da695c006084fd5b86d75ccd1491872dd7160a2e34c6b36da9d62d2339397f7632fbe47f639306d60a8cdbbff97802cd62b6ca
6
+ metadata.gz: 5835b74331b32293a53b771ebc0c92caa9e823b8fe90156aebaca98d10c876f060d3f60f82904256a0d11e2662c4cdfa791dffde13b845cced6e4ca3adbfc721
7
+ data.tar.gz: 432d156c7e168cf87a0038e7f2cb4e0d28a668414438d5a4ab1a14109294048a5e9e44ee31e90a7b9f5c8746bdfd7986ff6ab6d2e4f9ed02e1545cb667d0ce14
checksums.yaml.gz.sig CHANGED
Binary file
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2020-2022, by Samuel Williams.
3
5
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2022, by Samuel Williams.
3
5
 
4
6
  require 'bake/modernize'
5
7
 
@@ -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
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2022, by Samuel Williams.
3
5
 
4
6
  require 'bake/modernize'
5
7
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2020-2022, by Samuel Williams.
3
5
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
- # Copyright, 2021, by Samuel Williams.
4
+ # Copyright, 2021-2022, by Samuel Williams.
3
5
 
4
6
  require 'bake/modernize'
5
7
 
@@ -13,6 +15,9 @@ def update(root:)
13
15
  system("git", "branch", "-M", "main")
14
16
  system("git", "push", "-u", "origin", "main")
15
17
  end
18
+
19
+ template_root = Bake::Modernize.template_path_for('git')
20
+ Bake::Modernize.copy_template(template_root, root)
16
21
  end
17
22
 
18
23
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2022, by Samuel Williams.
3
5
 
@@ -49,6 +51,8 @@ def update(root:)
49
51
  end
50
52
 
51
53
  paths.each do |path, authors|
54
+ next unless File.exist?(path)
55
+
52
56
  case path
53
57
  when /\.rb$/
54
58
  self.update_source_file_authors(path, authors)
@@ -62,8 +66,16 @@ def update_source_file_authors(path, authors)
62
66
  input = File.readlines(path)
63
67
  output = []
64
68
 
65
- if input =~ /^\#!/
69
+ if input.first =~ /^\#!/
70
+ output.push input.shift
71
+ end
72
+
73
+ if input.first =~ /^\#.*?\:/
66
74
  output.push input.shift
75
+ if input.first.chomp.empty?
76
+ input.shift
77
+ end
78
+ output << "\n"
67
79
  end
68
80
 
69
81
  # Remove any existing license:
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2022, by Samuel Williams.
3
5
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
- # Copyright, 2021, by Samuel Williams.
4
+ # Copyright, 2021-2022, by Samuel Williams.
3
5
 
4
6
  require 'bake/modernize'
5
7
 
data/bake/modernize.rb CHANGED
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2020-2022, by Samuel Williams.
3
5
 
4
6
  def modernize
5
- 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')
6
8
  end
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
4
  # Copyright, 2020-2022, by Samuel Williams.
3
5
 
4
6
  module Bake
5
7
  module Modernize
6
- VERSION = "0.13.0"
8
+ VERSION = "0.13.3"
7
9
  end
8
10
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Released under the MIT License.
2
- # Copyright, 2020, by Samuel Williams.
4
+ # Copyright, 2020-2022, by Samuel Williams.
3
5
 
4
6
  require "bake/modernize/version"
5
7
  require 'build/files/glob'
@@ -0,0 +1,5 @@
1
+ /.bundle/
2
+ /pkg/
3
+ /gems.locked
4
+ /.covered.db
5
+ /external
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.0
4
+ version: 0.13.3
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
@@ -148,6 +149,7 @@ files:
148
149
  - template/actions/.github/workflows/test-external.yaml
149
150
  - template/actions/.github/workflows/test.yaml
150
151
  - template/editorconfig/.editorconfig
152
+ - template/git/.gitignore
151
153
  - template/readme/README.md
152
154
  homepage: https://github.com/ioquatix/bake-modernize
153
155
  licenses:
metadata.gz.sig CHANGED
Binary file