magic_frozen_string_literal 1.0.1 → 1.0.2
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/README.rdoc +3 -3
- data/lib/add_magic_comment.rb +9 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7849ddcf3260bb9df23f55fc85805523b9af2a4f
|
4
|
+
data.tar.gz: b078cd7183943c59dfd81a88b654af38c26f4945
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4823bafa10df1f709b03049aee37fdc34779c46c35eecbf47f2659782c938a5e91799cdc94c3dd17306aab142c7257b8274a95d0293f8bdd484eacdbd83a646d
|
7
|
+
data.tar.gz: 8d0ee00883154cac47817fc8344b3866db5865271557719c14fbeef2e47b89fb2d2fc550e8e543fe1a4f91e9389cb624b0ff742188d24490c9ddc559f1a7c35c
|
data/README.rdoc
CHANGED
@@ -17,13 +17,12 @@ Run the tool from the command line:
|
|
17
17
|
|
18
18
|
magic_frozen_string_literal <directory>
|
19
19
|
|
20
|
-
this will prepend every "
|
20
|
+
this will prepend every "*.rb", "Rakefile", "*.rake", "*.rabl", "*.jbuilder", "*.haml", "*.slim" file in the given <directory> (recursively)
|
21
21
|
with the following magic comment followed by a blank line:
|
22
22
|
|
23
23
|
# frozen_string_literal: true
|
24
24
|
|
25
|
-
(".haml" and ".slim" files will have a "-" prefix before comment and no blank line after.
|
26
|
-
".erb" files will have the comment inside <% ... %> and no blank line after.)
|
25
|
+
(".haml" and ".slim" files will have a "-" prefix before the comment and no blank line after.)
|
27
26
|
|
28
27
|
The <directory> parameter is optional. It defaults to the current working directory.
|
29
28
|
|
@@ -32,3 +31,4 @@ Notes:
|
|
32
31
|
- existing +frozen_string_literal+ magic comments are replaced
|
33
32
|
- the rest of the file remains unchanged
|
34
33
|
- empty files are not touched
|
34
|
+
- if the file starts with #! (shebang) that line is preserved and the magic comment will be added just below it
|
data/lib/add_magic_comment.rb
CHANGED
@@ -10,21 +10,21 @@ module AddMagicComment
|
|
10
10
|
SHEBANG_PATTERN = /^#!/
|
11
11
|
|
12
12
|
EXTENSION_COMMENTS = {
|
13
|
-
"rb" => "# #{MAGIC_COMMENT}\n\n",
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
17
|
-
"
|
18
|
-
"
|
19
|
-
"
|
13
|
+
"*.rb" => "# #{MAGIC_COMMENT}\n\n",
|
14
|
+
"Rakefile" => "# #{MAGIC_COMMENT}\n\n",
|
15
|
+
"*.rake" => "# #{MAGIC_COMMENT}\n\n",
|
16
|
+
"*.rabl" => "# #{MAGIC_COMMENT}\n\n",
|
17
|
+
"*.jbuilder" => "# #{MAGIC_COMMENT}\n\n",
|
18
|
+
"*.haml" => "-# #{MAGIC_COMMENT}\n",
|
19
|
+
"*.slim" => "-# #{MAGIC_COMMENT}\n"
|
20
20
|
}
|
21
21
|
|
22
22
|
def self.process(argv)
|
23
23
|
directory = argv.first || Dir.pwd
|
24
24
|
|
25
25
|
count = 0
|
26
|
-
EXTENSION_COMMENTS.each do |
|
27
|
-
filename_pattern = File.join(directory, "**", "
|
26
|
+
EXTENSION_COMMENTS.each do |pattern, comment|
|
27
|
+
filename_pattern = File.join(directory, "**", "#{pattern}")
|
28
28
|
Dir.glob(filename_pattern).each do |filename|
|
29
29
|
File.open(filename, "r+") do |file|
|
30
30
|
lines = file.readlines
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic_frozen_string_literal
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin Kelley after Jared Roesch after Manuel Ryan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03-
|
11
|
+
date: 2018-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|