magic_frozen_string_literal 1.0.1 → 1.0.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
  SHA1:
3
- metadata.gz: ea34af2a4526f180999632150118a905ba15954a
4
- data.tar.gz: c4c480187e8422e87c2ab91154360887b5e6a1b5
3
+ metadata.gz: 7849ddcf3260bb9df23f55fc85805523b9af2a4f
4
+ data.tar.gz: b078cd7183943c59dfd81a88b654af38c26f4945
5
5
  SHA512:
6
- metadata.gz: d2c791c80c142890733e68c55ab4606648e53ae473991d3f57da80a1209868d5fcba930362b8f4c9a69e015fe7dad25cfe8308c22a9f6b85074a92cae8ec9e47
7
- data.tar.gz: df218232b077d02775b593bfbd94997a20882f79424efdceb4cd3e55dd9a46433a1bcc6af59dc1b2e8b71c7a423162d5e7699e99b791b95a9b94b79e158d282e
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 ".rb", ".rake", ".rabl", ".jbuilder", ".haml", ".slim", ".erb" file in the given <directory> (recursively)
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
@@ -10,21 +10,21 @@ module AddMagicComment
10
10
  SHEBANG_PATTERN = /^#!/
11
11
 
12
12
  EXTENSION_COMMENTS = {
13
- "rb" => "# #{MAGIC_COMMENT}\n\n",
14
- "rake" => "# #{MAGIC_COMMENT}\n\n",
15
- "rabl" => "# #{MAGIC_COMMENT}\n\n",
16
- "jbuilder" => "# #{MAGIC_COMMENT}\n\n",
17
- "haml" => "-# #{MAGIC_COMMENT}\n",
18
- "slim" => "-# #{MAGIC_COMMENT}\n",
19
- "erb" => "<%# #{MAGIC_COMMENT} -%>\n"
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 |ext, comment|
27
- filename_pattern = File.join(directory, "**", "*.#{ext}")
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.1
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-18 00:00:00.000000000 Z
11
+ date: 2018-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler