pragmater 6.3.1 → 6.3.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
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/README.md +73 -34
- data/lib/pragmater/cli.rb +6 -6
- data/lib/pragmater/identity.rb +1 -1
- metadata +5 -5
- 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: 3bbff78c69e65f1816000b849c2afc9221fe76abdc792c6fcfccb9b8ced75c36
|
|
4
|
+
data.tar.gz: 60dcd02d1968a0e09f36927057529872f5df5399514fd401c29fc95c3e348c60
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fa916a2da9adacc71ee99edd4d8b4c8d1d5dbccecfa9c535a999699553e775f7e5e7153a82e25b90287b4e5b81b5731fdc28490974594d0b742cc1ff50d6aee
|
|
7
|
+
data.tar.gz: 1abfda2b22b89d5c4af0954d11aa48fa750a18c625089a125bdd42f6753a612b0f70a8ec5a357cdd8fa3732bae749f8f7a7712e4a3324a1f9a4c914c7e9b6188
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/README.md
CHANGED
|
@@ -9,17 +9,16 @@
|
|
|
9
9
|
[](https://codeclimate.com/github/bkuhlmann/pragmater/test_coverage)
|
|
10
10
|
[](https://circleci.com/gh/bkuhlmann/pragmater)
|
|
11
11
|
|
|
12
|
-
A command line interface for managing/formatting source file
|
|
13
|
-
|
|
14
|
-
(a.k.a. *magic comments*). Examples:
|
|
12
|
+
A command line interface for managing/formatting source file [directive
|
|
13
|
+
pragmas](https://en.wikipedia.org/wiki/Directive_(programming)) (a.k.a. *magic comments*). Examples:
|
|
15
14
|
|
|
16
15
|
#! /usr/bin/env ruby
|
|
17
16
|
# frozen_string_literal: true
|
|
18
17
|
# encoding: UTF-8
|
|
19
18
|
|
|
20
19
|
With [Ruby 2.3.0](https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released), frozen strings
|
|
21
|
-
are supported via a pragma
|
|
22
|
-
|
|
20
|
+
are supported via a pragma. This gem provides an easy way to add pragmas to single or multiple Ruby
|
|
21
|
+
source files in order to benefit from improved memory and concurrency performance.
|
|
23
22
|
|
|
24
23
|
<!-- Tocer[start]: Auto-generated, don't remove. -->
|
|
25
24
|
|
|
@@ -32,8 +31,10 @@ or multiple Ruby source files in order to benefit from improved memory and concu
|
|
|
32
31
|
- [Usage](#usage)
|
|
33
32
|
- [Command Line Interface (CLI)](#command-line-interface-cli)
|
|
34
33
|
- [Customization](#customization)
|
|
34
|
+
- [Available Pragmas](#available-pragmas)
|
|
35
|
+
- [Syntax](#syntax)
|
|
36
|
+
- [Precedence](#precedence)
|
|
35
37
|
- [Frozen String Literals](#frozen-string-literals)
|
|
36
|
-
- [Available Comments](#available-comments)
|
|
37
38
|
- [Tests](#tests)
|
|
38
39
|
- [Versioning](#versioning)
|
|
39
40
|
- [Code of Conduct](#code-of-conduct)
|
|
@@ -46,11 +47,11 @@ or multiple Ruby source files in order to benefit from improved memory and concu
|
|
|
46
47
|
|
|
47
48
|
## Features
|
|
48
49
|
|
|
49
|
-
- Supports adding a pragma
|
|
50
|
-
- Supports removing
|
|
50
|
+
- Supports adding a pragma or multiple pragmas to single or multiple source files.
|
|
51
|
+
- Supports removing pragma(s) from single or multiple source files.
|
|
51
52
|
- Supports file list filtering. Defaults to any file.
|
|
52
|
-
- Ensures duplicate
|
|
53
|
-
- Ensures
|
|
53
|
+
- Ensures duplicate pragmas never exist.
|
|
54
|
+
- Ensures pragmas are consistently formatted.
|
|
54
55
|
|
|
55
56
|
## Screencasts
|
|
56
57
|
|
|
@@ -72,17 +73,17 @@ Type the following to install:
|
|
|
72
73
|
|
|
73
74
|
From the command line, type: `pragmater help`
|
|
74
75
|
|
|
75
|
-
pragmater -a, [--add=PATH] # Add
|
|
76
|
+
pragmater -a, [--add=PATH] # Add comments to source file(s).
|
|
76
77
|
pragmater -c, [--config] # Manage gem configuration.
|
|
77
78
|
pragmater -h, [--help=COMMAND] # Show this message or get help for a command.
|
|
78
|
-
pragmater -r, [--remove=PATH] # Remove
|
|
79
|
+
pragmater -r, [--remove=PATH] # Remove comments from source file(s).
|
|
79
80
|
pragmater -v, [--version] # Show gem version.
|
|
80
81
|
|
|
81
|
-
Both the `--add` and `--remove` commands support options for specifying
|
|
82
|
-
|
|
82
|
+
Both the `--add` and `--remove` commands support options for specifying pragmas and/or included
|
|
83
|
+
files (viewable by running `pragmater --help --add` or `pragmater --help --remove`):
|
|
83
84
|
|
|
84
|
-
-c, [--comments=one two three] #
|
|
85
|
-
-i, [--includes=one two three] #
|
|
85
|
+
-c, [--comments=one two three] # Define desired comments
|
|
86
|
+
-i, [--includes=one two three] # Include specific files and/or directories
|
|
86
87
|
|
|
87
88
|
Example (same options could be used for the `--remove` command too):
|
|
88
89
|
|
|
@@ -114,10 +115,61 @@ Feel free to take this default configuration, modify, and save as your own custo
|
|
|
114
115
|
|
|
115
116
|
The `configuration.yml` file can be configured as follows:
|
|
116
117
|
|
|
117
|
-
- `add`: Defines global/local comments and/or file include lists when adding
|
|
118
|
-
`comments` and `includes` options can be either a single string or an array
|
|
119
|
-
- `remove`: Defines global/local comments and/or file include lists when removing
|
|
120
|
-
The `comments` and `includes` options can be either a single string or an array
|
|
118
|
+
- `add`: Defines global/local comments and/or file include lists when adding pragmas. The
|
|
119
|
+
`comments` and `includes` options can be either a single string or an array.
|
|
120
|
+
- `remove`: Defines global/local comments and/or file include lists when removing pragmas.
|
|
121
|
+
The `comments` and `includes` options can be either a single string or an array.
|
|
122
|
+
|
|
123
|
+
### Available Pragmas
|
|
124
|
+
|
|
125
|
+
With Ruby 2.3 and higher, the following pragmas are available:
|
|
126
|
+
|
|
127
|
+
- `# encoding:` Defaults to `UTF-8` but any supported encoding can be used. For a list of values,
|
|
128
|
+
launch an IRB session and run `Encoding.name_list`.
|
|
129
|
+
- `# coding:` The shorthand for `# encoding:`. Supports the same values as mentioned above.
|
|
130
|
+
- `# frozen_string_literal:` Defaults to `false` but can take either `true` or `false` as a value.
|
|
131
|
+
When enabled, Ruby will throw errors when strings are used in a mutable fashion.
|
|
132
|
+
- `# warn_indent:` Defaults to `false` but can take either `true` or `false` as a value. When
|
|
133
|
+
enabled, and running Ruby with the `-w` option, it'll throw warnings for code that isn't indented
|
|
134
|
+
by two spaces.
|
|
135
|
+
|
|
136
|
+
### Syntax
|
|
137
|
+
|
|
138
|
+
The pragma syntax allows for two kinds of styles. Example:
|
|
139
|
+
|
|
140
|
+
# encoding: UTF-8
|
|
141
|
+
# -*- encoding: UTF-8 -*-
|
|
142
|
+
|
|
143
|
+
Only the former syntax is supported by this gem as the latter syntax is more verbose and requires
|
|
144
|
+
additional typing.
|
|
145
|
+
|
|
146
|
+
### Precedence
|
|
147
|
+
|
|
148
|
+
When different multiple pragmas are defined, they all take precedence:
|
|
149
|
+
|
|
150
|
+
# encoding: binary
|
|
151
|
+
# frozen_string_literal: true
|
|
152
|
+
|
|
153
|
+
In the above example, both *binary* encoding and *frozen string literals* behavior will be applied.
|
|
154
|
+
|
|
155
|
+
When defining multiple pragmas that are similar, behavior can differ based on the *kind* of pragma
|
|
156
|
+
used. The following walks through each use case so you know what to expect:
|
|
157
|
+
|
|
158
|
+
# encoding: binary
|
|
159
|
+
# encoding: UTF-8
|
|
160
|
+
|
|
161
|
+
In the above example, only the *binary* encoding will be applied while the *UTF-8* encoding will be
|
|
162
|
+
ignored (same principle applies for the `coding` pragma too).
|
|
163
|
+
|
|
164
|
+
# frozen_string_literal: false
|
|
165
|
+
# frozen_string_literal: true
|
|
166
|
+
|
|
167
|
+
In the above example, frozen string literal support *will be enabled* instead of being disabled.
|
|
168
|
+
|
|
169
|
+
# warn_indent: false
|
|
170
|
+
# warn_indent: true
|
|
171
|
+
|
|
172
|
+
In the above example, indentation warnings *will be enabled* instead of being disabled.
|
|
121
173
|
|
|
122
174
|
### Frozen String Literals
|
|
123
175
|
|
|
@@ -167,24 +219,11 @@ to hard to read code. Instead use the following:
|
|
|
167
219
|
mutable = "test"
|
|
168
220
|
|
|
169
221
|
While this requires extra typing, it expresses intent more clearly. There is a slight caveat to this
|
|
170
|
-
rule in
|
|
222
|
+
rule in which the use of `String#-@` was [enhanced in Ruby 2.5.0](http://bit.ly/2DGAjgG) to
|
|
171
223
|
*deduplicate* all instances of the same string thus reducing your memory footprint. This can be
|
|
172
224
|
valuable in situations where you are not using the frozen string comment and need to selectively
|
|
173
225
|
freeze strings.
|
|
174
226
|
|
|
175
|
-
### Available Comments
|
|
176
|
-
|
|
177
|
-
With Ruby 2.3 and higher, the following comments are available:
|
|
178
|
-
|
|
179
|
-
- `# encoding:` Defaults to `UTF-8` but any supported encoding can be used. For a list of values,
|
|
180
|
-
launch an IRB session and run `Encoding.name_list`.
|
|
181
|
-
- `# coding:` The shorthand for `# encoding:`. Supports the same values as mentioned above.
|
|
182
|
-
- `# frozen_string_literal:` Defaults to `false` but can take either `true` or `false` as a value.
|
|
183
|
-
When enabled, Ruby will throw errors when strings are used in a mutable fashion.
|
|
184
|
-
- `# warn_indent:` Defaults to `false` but can take either `true` or `false` as a value. When
|
|
185
|
-
enabled, and running Ruby with the `-w` option, it'll throw warnings for code that isn't indented
|
|
186
|
-
by two spaces.
|
|
187
|
-
|
|
188
227
|
## Tests
|
|
189
228
|
|
|
190
229
|
To test, run:
|
data/lib/pragmater/cli.rb
CHANGED
|
@@ -35,16 +35,16 @@ module Pragmater
|
|
|
35
35
|
abort error.message
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
desc "-a, [--add=PATH]", "Add
|
|
38
|
+
desc "-a, [--add=PATH]", "Add comments to source file(s)."
|
|
39
39
|
map %w[-a --add] => :add
|
|
40
40
|
method_option :comments,
|
|
41
41
|
aliases: "-c",
|
|
42
|
-
desc: "
|
|
42
|
+
desc: "Define desired comments",
|
|
43
43
|
type: :array,
|
|
44
44
|
default: configuration.to_h.dig(:add, :comments)
|
|
45
45
|
method_option :includes,
|
|
46
46
|
aliases: "-i",
|
|
47
|
-
desc: "
|
|
47
|
+
desc: "Include specific files and/or directories",
|
|
48
48
|
type: :array,
|
|
49
49
|
default: configuration.to_h.dig(:add, :includes)
|
|
50
50
|
def add path = "."
|
|
@@ -59,16 +59,16 @@ module Pragmater
|
|
|
59
59
|
runner.run(action: :add) { |file| say_status :info, "Processed: #{file}.", :green }
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
desc "-r, [--remove=PATH]", "Remove
|
|
62
|
+
desc "-r, [--remove=PATH]", "Remove comments from source file(s)."
|
|
63
63
|
map %w[-r --remove] => :remove
|
|
64
64
|
method_option :comments,
|
|
65
65
|
aliases: "-c",
|
|
66
|
-
desc: "
|
|
66
|
+
desc: "Define desired comments",
|
|
67
67
|
type: :array,
|
|
68
68
|
default: configuration.to_h.dig(:remove, :comments)
|
|
69
69
|
method_option :includes,
|
|
70
70
|
aliases: "-i",
|
|
71
|
-
desc: "
|
|
71
|
+
desc: "Include specific files and/or directories",
|
|
72
72
|
type: :array,
|
|
73
73
|
default: configuration.to_h.dig(:remove, :includes)
|
|
74
74
|
def remove path = "."
|
data/lib/pragmater/identity.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pragmater
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 6.3.
|
|
4
|
+
version: 6.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brooke Kuhlmann
|
|
@@ -28,7 +28,7 @@ cert_chain:
|
|
|
28
28
|
dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
|
|
29
29
|
y84=
|
|
30
30
|
-----END CERTIFICATE-----
|
|
31
|
-
date: 2019-
|
|
31
|
+
date: 2019-09-01 00:00:00.000000000 Z
|
|
32
32
|
dependencies:
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
34
|
name: runcom
|
|
@@ -246,14 +246,14 @@ dependencies:
|
|
|
246
246
|
requirements:
|
|
247
247
|
- - "~>"
|
|
248
248
|
- !ruby/object:Gem::Version
|
|
249
|
-
version: '0.
|
|
249
|
+
version: '0.73'
|
|
250
250
|
type: :development
|
|
251
251
|
prerelease: false
|
|
252
252
|
version_requirements: !ruby/object:Gem::Requirement
|
|
253
253
|
requirements:
|
|
254
254
|
- - "~>"
|
|
255
255
|
- !ruby/object:Gem::Version
|
|
256
|
-
version: '0.
|
|
256
|
+
version: '0.73'
|
|
257
257
|
- !ruby/object:Gem::Dependency
|
|
258
258
|
name: rubocop-performance
|
|
259
259
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -352,7 +352,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
352
352
|
- !ruby/object:Gem::Version
|
|
353
353
|
version: '0'
|
|
354
354
|
requirements: []
|
|
355
|
-
rubygems_version: 3.0.
|
|
355
|
+
rubygems_version: 3.0.6
|
|
356
356
|
signing_key:
|
|
357
357
|
specification_version: 4
|
|
358
358
|
summary: A command line interface for managing/formatting source file pragma comments.
|
metadata.gz.sig
CHANGED
|
Binary file
|