pragmater 6.3.2 → 7.2.0

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: 3bbff78c69e65f1816000b849c2afc9221fe76abdc792c6fcfccb9b8ced75c36
4
- data.tar.gz: 60dcd02d1968a0e09f36927057529872f5df5399514fd401c29fc95c3e348c60
3
+ metadata.gz: 17f31f5ee7db80b11e49894b0db270e17c1fcdedb97fd9fb19bfebc04af238c2
4
+ data.tar.gz: fe4b1203fb590733575f72ccc569481617b978a7949dd13605582fb7a52b7bfe
5
5
  SHA512:
6
- metadata.gz: 3fa916a2da9adacc71ee99edd4d8b4c8d1d5dbccecfa9c535a999699553e775f7e5e7153a82e25b90287b4e5b81b5731fdc28490974594d0b742cc1ff50d6aee
7
- data.tar.gz: 1abfda2b22b89d5c4af0954d11aa48fa750a18c625089a125bdd42f6753a612b0f70a8ec5a357cdd8fa3732bae749f8f7a7712e4a3324a1f9a4c914c7e9b6188
6
+ metadata.gz: 5e5f6b2b569226308f251b080d7e51df7352f23dfa33be98afef5424982566d9a8e55f234c052752554ba2e1f8c10740b22859ed39de06a8fd03d096e1dcd15c
7
+ data.tar.gz: 5961184d11177ccea0a041783b6df77e4cced27a5088c63325915ed75fc20748e2ea0c59a05d0071d4d8786154905e83fda922788a67c6386b6241d4025e7177
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,4 +1,4 @@
1
- # Apache License
1
+ = Apache License
2
2
 
3
3
  Version 2.0, January 2004
4
4
 
@@ -6,7 +6,7 @@ http://www.apache.org/licenses
6
6
 
7
7
  TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
8
 
9
- ## 1. Definitions
9
+ == 1. Definitions
10
10
 
11
11
  "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by
12
12
  Sections 1 through 9 of this document.
@@ -54,14 +54,14 @@ Contribution."
54
54
  "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a
55
55
  Contribution has been received by Licensor and subsequently incorporated within the Work.
56
56
 
57
- ## 2. Grant of Copyright License
57
+ == 2. Grant of Copyright License
58
58
 
59
59
  Subject to the terms and conditions of this License, each Contributor hereby grants to You a
60
60
  perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to
61
61
  reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and
62
62
  distribute the Work and such Derivative Works in Source or Object form.
63
63
 
64
- ## 3. Grant of Patent License
64
+ == 3. Grant of Patent License
65
65
 
66
66
  Subject to the terms and conditions of this License, each Contributor hereby grants to You a
67
67
  perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
@@ -74,39 +74,38 @@ a Contribution incorporated within the Work constitutes direct or contributory p
74
74
  then any patent licenses granted to You under this License for that Work shall terminate as of the
75
75
  date such litigation is filed.
76
76
 
77
- ## 4. Redistribution
77
+ == 4. Redistribution
78
78
 
79
79
  You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with
80
80
  or without modifications, and in Source or Object form, provided that You meet the following
81
81
  conditions:
82
82
 
83
- 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and
83
+ . You must give any other recipients of the Work or Derivative Works a copy of this License; and
84
84
 
85
- 2. You must cause any modified files to carry prominent notices stating that You changed the
86
- files; and
85
+ . You must cause any modified files to carry prominent notices stating that You changed the files;
86
+ and
87
87
 
88
- 3. You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
89
- patent, trademark, and attribution notices from the Source form of the Work, excluding those
90
- notices that do not pertain to any part of the Derivative Works; and
88
+ . You must retain, in the Source form of any Derivative Works that You distribute, all copyright,
89
+ patent, trademark, and attribution notices from the Source form of the Work, excluding those
90
+ notices that do not pertain to any part of the Derivative Works; and
91
91
 
92
- 4. If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative
93
- Works that You distribute must include a readable copy of the attribution notices contained
94
- within such NOTICE file, excluding those notices that do not pertain to any part of the
95
- Derivative Works, in at least one of the following places: within a NOTICE text file
96
- distributed as part of the Derivative Works; within the Source form or documentation, if
97
- provided along with the Derivative Works; or, within a display generated by the Derivative
98
- Works, if and wherever such third-party notices normally appear. The contents of the NOTICE
99
- file are for informational purposes only and do not modify the License. You may add Your own
100
- attribution notices within Derivative Works that You distribute, alongside or as an addendum to
101
- the NOTICE text from the Work, provided that such additional attribution notices cannot be
102
- construed as modifying the License.
92
+ . If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works
93
+ that You distribute must include a readable copy of the attribution notices contained within such
94
+ NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in
95
+ at least one of the following places: within a NOTICE text file distributed as part of the
96
+ Derivative Works; within the Source form or documentation, if provided along with the Derivative
97
+ Works; or, within a display generated by the Derivative Works, if and wherever such third-party
98
+ notices normally appear. The contents of the NOTICE file are for informational purposes only and
99
+ do not modify the License. You may add Your own attribution notices within Derivative Works that
100
+ You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such
101
+ additional attribution notices cannot be construed as modifying the License.
103
102
 
104
103
  You may add Your own copyright statement to Your modifications and may provide additional or
105
104
  different license terms and conditions for use, reproduction, or distribution of Your modifications,
106
105
  or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of
107
106
  the Work otherwise complies with the conditions stated in this License.
108
107
 
109
- ## 5. Submission of Contributions
108
+ == 5. Submission of Contributions
110
109
 
111
110
  Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the
112
111
  Work by You to the Licensor shall be under the terms and conditions of this License, without any
@@ -114,13 +113,13 @@ additional terms or conditions. Notwithstanding the above, nothing herein shall
114
113
  the terms of any separate license agreement you may have executed with Licensor regarding such
115
114
  Contributions.
116
115
 
117
- ## 6. Trademarks
116
+ == 6. Trademarks
118
117
 
119
118
  This License does not grant permission to use the trade names, trademarks, service marks, or product
120
119
  names of the Licensor, except as required for reasonable and customary use in describing the origin
121
120
  of the Work and reproducing the content of the NOTICE file.
122
121
 
123
- ## 7. Disclaimer of Warranty
122
+ == 7. Disclaimer of Warranty
124
123
 
125
124
  Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each
126
125
  Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -129,7 +128,7 @@ TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. Y
129
128
  responsible for determining the appropriateness of using or redistributing the Work and assume any
130
129
  risks associated with Your exercise of permissions under this License.
131
130
 
132
- ## 8. Limitation of Liability
131
+ == 8. Limitation of Liability
133
132
 
134
133
  In no event and under no legal theory, whether in tort (including negligence), contract, or
135
134
  otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or
@@ -139,7 +138,7 @@ License or out of the use or inability to use the Work (including but not limite
139
138
  loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial
140
139
  damages or losses), even if such Contributor has been advised of the possibility of such damages.
141
140
 
142
- ## 9. Accepting Warranty or Additional Liability
141
+ == 9. Accepting Warranty or Additional Liability
143
142
 
144
143
  While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee
145
144
  for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights
@@ -151,11 +150,11 @@ additional liability.
151
150
 
152
151
  END OF TERMS AND CONDITIONS
153
152
 
154
- Copyright 2015 [Alchemists](https://www.alchemists.io).
153
+ Copyright link:https://www.alchemists.io[Alchemists].
155
154
 
156
155
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
157
- compliance with the License. You may obtain a [copy](http://www.apache.org/licenses/LICENSE-2.0) of
158
- the License.
156
+ compliance with the License. You may obtain a link:https://www.apache.org/licenses/LICENSE-2.0[copy]
157
+ of the License.
159
158
 
160
159
  Unless required by applicable law or agreed to in writing, software distributed under the License is
161
160
  distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
@@ -0,0 +1,327 @@
1
+ :toc: macro
2
+ :toclevels: 5
3
+ :figure-caption!:
4
+
5
+ = Pragmater
6
+
7
+ [link=http://badge.fury.io/rb/pragmater]
8
+ image::https://badge.fury.io/rb/pragmater.svg[Gem Version]
9
+ [link=https://circleci.com/gh/bkuhlmann/pragmater]
10
+ image::https://circleci.com/gh/bkuhlmann/pragmater.svg?style=svg[Circle CI Status]
11
+
12
+ A command line interface for managing/formatting source file
13
+ https://en.wikipedia.org/wiki/Directive_(programming)[directive pragmas] (a.k.a. _magic comments_).
14
+ Examples:
15
+
16
+ [source,ruby]
17
+ ----
18
+ #! /usr/bin/env ruby
19
+ # frozen_string_literal: true
20
+ # encoding: UTF-8
21
+ ----
22
+
23
+ With https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released[Ruby 2.3.0], frozen strings
24
+ are supported via a pragma. This gem provides an easy way to add pragmas to single or multiple Ruby
25
+ source files in order to benefit from improved memory and concurrency performance.
26
+
27
+ toc::[]
28
+
29
+ == Features
30
+
31
+ * Supports adding a pragma or multiple pragmas to single or multiple source files.
32
+ * Supports removing pragma(s) from single or multiple source files.
33
+ * Supports file list filtering. Defaults to any file.
34
+ * Ensures duplicate pragmas never exist.
35
+ * Ensures pragmas are consistently formatted.
36
+
37
+ == Screencasts
38
+
39
+ [link=https://www.alchemists.io/screencasts/pragmater]
40
+ image::https://www.alchemists.io/images/screencasts/pragmater/cover.svg[Screencast,600,240,role=focal_point]
41
+
42
+ == Requirements
43
+
44
+ . https://www.ruby-lang.org[Ruby]
45
+
46
+ == Setup
47
+
48
+ === Production
49
+
50
+ To install, run:
51
+
52
+ [source,bash]
53
+ ----
54
+ gem install pragmater
55
+ ----
56
+
57
+ === Development
58
+
59
+ To contribute, run:
60
+
61
+ [source,bash]
62
+ ----
63
+ git clone https://github.com/bkuhlmann/pragmater.git
64
+ cd pragmater
65
+ bin/setup
66
+ ----
67
+
68
+ You can also use the IRB console for direct access to all objects:
69
+
70
+ [source,bash]
71
+ ----
72
+ bin/console
73
+ ----
74
+
75
+ == Usage
76
+
77
+ === Command Line Interface (CLI)
78
+
79
+ From the command line, type: `+pragmater help+`
80
+
81
+ ....
82
+ pragmater -a, [--add=PATH] # Add comments to source file(s).
83
+ pragmater -c, [--config] # Manage gem configuration.
84
+ pragmater -h, [--help=COMMAND] # Show this message or get help for a command.
85
+ pragmater -r, [--remove=PATH] # Remove comments from source file(s).
86
+ pragmater -v, [--version] # Show gem version.
87
+ ....
88
+
89
+ Both the `+--add+` and `+--remove+` commands support options for specifying pragmas and/or included
90
+ files (viewable by running `+pragmater --help --add+` or `+pragmater --help --remove+`):
91
+
92
+ ....
93
+ -c, [--comments=one two three] # Define desired comments
94
+ -i, [--includes=one two three] # Include specific files and/or directories
95
+ ....
96
+
97
+ Example (same options could be used for the `+--remove+` command too):
98
+
99
+ [source,bash]
100
+ ----
101
+ pragmater --add --comments "# frozen_string_literal: true" --includes "Gemfile" "Guardfile" "Rakefile" ".gemspec" "config.ru" "bin/**/*" "**/*.rake" "**/*.rb"
102
+ ----
103
+
104
+ The `--add` and `--remove` commands default to the current working directory so a path isn’t
105
+ necessary unless you want to run Pragmater on a directory structure other than your current working
106
+ directory.
107
+
108
+ === Customization
109
+
110
+ This gem can be configured via a global configuration: `$HOME/.config/pragmater/configuration.yml`
111
+
112
+ It can also be configured via link:https://www.alchemists.io/projects/xdg[XDG] environment
113
+ variables.
114
+
115
+ The default configuration is as follows:
116
+
117
+ [source,yaml]
118
+ ----
119
+ :add:
120
+ :comments: []
121
+ :includes: []
122
+ :remove:
123
+ :comments: []
124
+ :includes: []
125
+ ----
126
+
127
+ Feel free to take the above configuration, modify, and save as your own custom `configuration.yml`.
128
+
129
+ The `configuration.yml` file can be configured as follows:
130
+
131
+ * `add`: Defines global/local comments and/or file include lists when adding pragmas. The `comments`
132
+ and `includes` options can be either a single string or an array.
133
+ * `remove`: Defines global/local comments and/or file include lists when removing pragmas. The
134
+ `comments` and `includes` options can be either a single string or an array.
135
+
136
+ === Available Pragmas
137
+
138
+ With Ruby 2.3 and higher, the following pragmas are available:
139
+
140
+ * `# encoding:` Defaults to `UTF-8` but any supported encoding can be used. For a list of values,
141
+ launch an IRB session and run `Encoding.name_list`.
142
+ * `# coding:` The shorthand for `# encoding:`. Supports the same values as mentioned above.
143
+ * `# frozen_string_literal:` Defaults to `false` but can take either `true` or `false` as a value.
144
+ When enabled, Ruby will throw errors when strings are used in a mutable fashion.
145
+ * `# warn_indent:` Defaults to `false` but can take either `true` or `false` as a value. When
146
+ enabled, and running Ruby with the `-w` option, it’ll throw warnings for code that isn’t indented
147
+ by two spaces.
148
+
149
+ === Syntax
150
+
151
+ The pragma syntax allows for two kinds of styles. Example:
152
+
153
+ [source,ruby]
154
+ ----
155
+ # encoding: UTF-8
156
+ # -*- encoding: UTF-8 -*-
157
+ ----
158
+
159
+ Only the former syntax is supported by this gem as the latter syntax is more verbose and requires
160
+ additional typing.
161
+
162
+ === Precedence
163
+
164
+ When different multiple pragmas are defined, they all take precedence:
165
+
166
+ [source,ruby]
167
+ ----
168
+ # encoding: binary
169
+ # frozen_string_literal: true
170
+ ----
171
+
172
+ In the above example, both _binary_ encoding and _frozen string literals_ behavior will be applied.
173
+
174
+ When defining multiple pragmas that are similar, behavior can differ based on the _kind_ of pragma
175
+ used. The following walks through each use case so you know what to expect:
176
+
177
+ [source,ruby]
178
+ ----
179
+ # encoding: binary
180
+ # encoding: UTF-8
181
+ ----
182
+
183
+ In the above example, only the _binary_ encoding will be applied while the _UTF-8_ encoding will be
184
+ ignored (same principle applies for the `coding` pragma too).
185
+
186
+ [source,ruby]
187
+ ----
188
+ # frozen_string_literal: false
189
+ # frozen_string_literal: true
190
+ ----
191
+
192
+ In the above example, frozen string literal support _will be enabled_ instead of being disabled.
193
+
194
+ [source,ruby]
195
+ ----
196
+ # warn_indent: false
197
+ # warn_indent: true
198
+ ----
199
+
200
+ In the above example, indentation warnings _will be enabled_ instead of being disabled.
201
+
202
+ === Frozen String Literals
203
+
204
+ Support for frozen string literals was added in Ruby 2.3.0. The ability to freeze strings within a
205
+ source can be done by placing a frozen string pragma at the top of each source file. Example:
206
+
207
+ [source,ruby]
208
+ ----
209
+ # frozen_string_literal: true
210
+ ----
211
+
212
+ This is great for _selective_ enablement of frozen string literals but might be too much work for
213
+ some (even with the aid of this gem). As an alternative, frozen string literals can be enabled via
214
+ the following Ruby command line option:
215
+
216
+ ....
217
+ --enable=frozen-string-literal
218
+ ....
219
+
220
+ It is important to note that, once enabled, this freezes strings program-wide – It’s an all or
221
+ nothing option.
222
+
223
+ Regardless of whether you leverage the capabilities of this gem or the Ruby command line option
224
+ mentioned above, the following Ruby command line option is available to aid debugging and tracking
225
+ down frozen string literal issues:
226
+
227
+ ....
228
+ --debug=frozen-string-literal
229
+ ....
230
+
231
+ Ruby 2.3.0 also added the following methods to the `String` class:
232
+
233
+ * `String#+@`: Answers a duplicated, mutable, string if not already frozen. Example:
234
+ +
235
+ [source,ruby]
236
+ ----
237
+ immutable = "test".freeze
238
+ mutable = +immutable
239
+ mutable.capitalize! # => "Test"
240
+ ----
241
+ * `String#-@`: Answers a immutable string if not already frozen. Example:
242
+ +
243
+ [source,ruby]
244
+ ----
245
+ mutable = "test"
246
+ immutable = -mutable
247
+ immutable.capitalize! # => FrozenError
248
+ ----
249
+
250
+ You can also use the methods, shown above, for variable initialization. Example:
251
+
252
+ [source,ruby]
253
+ ----
254
+ immutable = -"test"
255
+ mutable = +"test"
256
+ ----
257
+
258
+ Despite Ruby allowing you to do this, it is _not recommended_ to use the above examples as it leads
259
+ to hard to read code. Instead use the following:
260
+
261
+ [source,ruby]
262
+ ----
263
+ immutable = "test".freeze
264
+ mutable = "test"
265
+ ----
266
+
267
+ While this requires extra typing, it expresses intent more clearly. There is a slight caveat to this
268
+ rule in which the use of `+String#-@+` was http://bit.ly/2DGAjgG[enhanced in Ruby 2.5.0] to
269
+ _deduplicate_ all instances of the same string thus reducing your memory footprint. This can be
270
+ valuable in situations where you are not using the frozen string comment and need to selectively
271
+ freeze strings.
272
+
273
+ === Consistency
274
+
275
+ As an added bonus, this gem ensures pragmas for all analyzed files are formatted in a consistent
276
+ style. This means there is always a space after the octothorpe (`#`). Here are multiple pragmas
277
+ presented together for a visual comparison:
278
+
279
+ [source,ruby]
280
+ ----
281
+ #! /usr/bin/env ruby
282
+ # encoding: UTF-8
283
+ # coding: UTF-8
284
+ # frozen_string_literal: true
285
+ # warn_indent: true
286
+ ----
287
+
288
+ One oddity to the above is the use of `# !/usr/bin/env ruby` is not allowed but `#! /usr/bin/env
289
+ ruby` is which is why spacing is slightly different for shell pragmas.
290
+
291
+ == Tests
292
+
293
+ To test, run:
294
+
295
+ [source,bash]
296
+ ----
297
+ bundle exec rake
298
+ ----
299
+
300
+ == Versioning
301
+
302
+ Read link:https://semver.org[Semantic Versioning] for details. Briefly, it means:
303
+
304
+ * Major (X.y.z) - Incremented for any backwards incompatible public API changes.
305
+ * Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
306
+ * Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
307
+
308
+ == Code of Conduct
309
+
310
+ Please note that this project is released with a link:CODE_OF_CONDUCT.adoc[CODE OF CONDUCT]. By
311
+ participating in this project you agree to abide by its terms.
312
+
313
+ == Contributions
314
+
315
+ Read link:CONTRIBUTING.adoc[CONTRIBUTING] for details.
316
+
317
+ == License
318
+
319
+ Read link:LICENSE.adoc[LICENSE] for details.
320
+
321
+ == History
322
+
323
+ Read link:CHANGES.adoc[CHANGES] for details.
324
+
325
+ == Credits
326
+
327
+ Engineered by link:https://www.alchemists.io/team/brooke_kuhlmann[Brooke Kuhlmann].
@@ -5,5 +5,5 @@ require "pragmater"
5
5
  require "pragmater/cli"
6
6
  require "pragmater/identity"
7
7
 
8
- Process.setproctitle Pragmater::Identity.version_label
8
+ Process.setproctitle Pragmater::Identity::VERSION_LABEL
9
9
  Pragmater::CLI.start
@@ -10,11 +10,11 @@ module Pragmater
10
10
  class CLI < Thor
11
11
  include Thor::Actions
12
12
 
13
- package_name Identity.version_label
13
+ package_name Identity::VERSION_LABEL
14
14
 
15
15
  # rubocop:disable Metrics/MethodLength
16
16
  def self.configuration
17
- Runcom::Config.new Identity.name,
17
+ Runcom::Config.new "#{Identity::NAME}/configuration.yml",
18
18
  defaults: {
19
19
  add: {
20
20
  comments: "",
@@ -96,7 +96,7 @@ module Pragmater
96
96
  type: :boolean,
97
97
  default: false
98
98
  def config
99
- path = configuration.path
99
+ path = configuration.current
100
100
 
101
101
  if options.edit? then `#{ENV["EDITOR"]} #{path}`
102
102
  elsif options.info?
@@ -108,7 +108,7 @@ module Pragmater
108
108
  desc "-v, [--version]", "Show gem version."
109
109
  map %w[-v --version] => :version
110
110
  def version
111
- say Identity.version_label
111
+ say Identity::VERSION_LABEL
112
112
  end
113
113
 
114
114
  desc "-h, [--help=COMMAND]", "Show this message or get help for a command."
@@ -4,7 +4,7 @@ module Pragmater
4
4
  # Formats pragma comments in a consistent manner.
5
5
  class Formatter
6
6
  def self.shebang_format
7
- %r(\A\#\!\s?\/.*ruby\Z)
7
+ %r(\A\#!\s?/.*ruby\Z)
8
8
  end
9
9
 
10
10
  def self.pragma_format
@@ -13,9 +13,9 @@ module Pragmater
13
13
  \# # Start of comment.
14
14
  \s? # Space - optional.
15
15
  \w+ # Key - 1 or more word characters only.
16
- \: # Key and value delimiter.
16
+ : # Key and value delimiter.
17
17
  \s? # Space - optional.
18
- [\w\-]+ # Value - 1 or more word or dash characters.
18
+ [\w-]+ # Value - 1 or more word or dash characters.
19
19
  \Z # End of line.
20
20
  /x
21
21
  end
@@ -3,20 +3,9 @@
3
3
  module Pragmater
4
4
  # Gem identity information.
5
5
  module Identity
6
- def self.name
7
- "pragmater"
8
- end
9
-
10
- def self.label
11
- "Pragmater"
12
- end
13
-
14
- def self.version
15
- "6.3.2"
16
- end
17
-
18
- def self.version_label
19
- "#{label} #{version}"
20
- end
6
+ NAME = "pragmater"
7
+ LABEL = "Pragmater"
8
+ VERSION = "7.2.0"
9
+ VERSION_LABEL = "#{LABEL} #{VERSION}"
21
10
  end
22
11
  end
metadata CHANGED
@@ -1,18 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmater
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.3.2
4
+ version: 7.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIC/jCCAeagAwIBAgIBAjANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
- a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0xOTAyMTcxNjAxMTFaFw0yMDAyMTcx
15
- NjAxMTFaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
13
+ MIIC/jCCAeagAwIBAgIBAzANBgkqhkiG9w0BAQsFADAlMSMwIQYDVQQDDBpicm9v
14
+ a2UvREM9YWxjaGVtaXN0cy9EQz1pbzAeFw0yMDAzMTUxNDQ1MzJaFw0yMTAzMTUx
15
+ NDQ1MzJaMCUxIzAhBgNVBAMMGmJyb29rZS9EQz1hbGNoZW1pc3RzL0RDPWlvMIIB
16
16
  IjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA6l1qpXTiomH1RfMRloyw7MiE
17
17
  xyVx/x8Yc3EupdH7uhNaTXQGyORN6aOY//1QXXMHIZ9tW74nZLhesWMSUMYy0XhB
18
18
  brs+KkurHnc9FnEJAbG7ebGvl/ncqZt72nQvaxpDxvuCBHgJAz+8i5wl6FhLw+oT
@@ -20,15 +20,15 @@ cert_chain:
20
20
  D5vkU0YlAm1r98BymuJlcQ1qdkVEI1d48ph4kcS0S0nv1RiuyVb6TCAR3Nu3VaVq
21
21
  3fPzZKJLZBx67UvXdbdicWPiUR75elI4PXpLIic3xytaF52ZJYyKZCNZJhNwfQID
22
22
  AQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU0nzow9vc
23
- 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBANgfX7kPZkJvsbdWMvbe
24
- DUUYxRTqTUzCDpLd2p3sQvgLMKjTNSKt6CFq/kh+98b6RCgO6DqiVfxvOEq02dvf
25
- ebMN/ylQqan2FgiAs1rpP0/D4C0MlBjoDktsT+2IyLol1KmkDB20ExJ4Sf1GRNdA
26
- hpWOtcgqHtmrc7xzgB6BuyoYufrKKUlCO3ewTM4C375D2qO7hIdKuMOO3CdPMtSk
27
- OrWpbzCL+nbbXqeoqiHgZaUvcyyQrGj5sQRxMTzuMXzzQxtHnuTuKrcz16HMTX/O
28
- dKvURM+1PwDCzC5tvRwjhUJIizau6+MtkFCvJHmaAj1aZL3odcPejHj5Hxt/0CUW
29
- y84=
23
+ 2CdikiiE3fJhP/gY4ggwDQYJKoZIhvcNAQELBQADggEBAIHhAlD3po4sTYqacXaQ
24
+ XI9jIhrfMy//2PgbHWcETtlJPBeNUbbSNBABcllUHKqYsVDlSvSmss034KSWNR8F
25
+ bF1GcloicyvcCC4y6IoW4it0COAcdeaaxkxiBSgKdQFpff9REnDlIKK4uQ9lLxIo
26
+ Y2G5xubiziKZkyfWFuSr67PIjW3Bu673D1JVBArhA1qbgQmYQcy1CkGOjo+iO8Nf
27
+ 7u/QSfBHb+r/bXhKscDgPpnKwbUmvgO2+94zJG9KsrmIydlzYfsD09aXKx0t6Xy4
28
+ 2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
+ QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2019-09-01 00:00:00.000000000 Z
31
+ date: 2020-07-23 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: runcom
@@ -36,14 +36,14 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '5.0'
39
+ version: '6.0'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '5.0'
46
+ version: '6.0'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: thor
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -58,34 +58,6 @@ dependencies:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0.20'
61
- - !ruby/object:Gem::Dependency
62
- name: awesome_print
63
- requirement: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '1.8'
68
- type: :development
69
- prerelease: false
70
- version_requirements: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - "~>"
73
- - !ruby/object:Gem::Version
74
- version: '1.8'
75
- - !ruby/object:Gem::Dependency
76
- name: bond
77
- requirement: !ruby/object:Gem::Requirement
78
- requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.5'
82
- type: :development
83
- prerelease: false
84
- version_requirements: !ruby/object:Gem::Requirement
85
- requirements:
86
- - - "~>"
87
- - !ruby/object:Gem::Version
88
- version: '0.5'
89
61
  - !ruby/object:Gem::Dependency
90
62
  name: bundler-audit
91
63
  requirement: !ruby/object:Gem::Requirement
@@ -120,28 +92,28 @@ dependencies:
120
92
  requirements:
121
93
  - - "~>"
122
94
  - !ruby/object:Gem::Version
123
- version: '13.5'
95
+ version: '14.2'
124
96
  type: :development
125
97
  prerelease: false
126
98
  version_requirements: !ruby/object:Gem::Requirement
127
99
  requirements:
128
100
  - - "~>"
129
101
  - !ruby/object:Gem::Version
130
- version: '13.5'
102
+ version: '14.2'
131
103
  - !ruby/object:Gem::Dependency
132
- name: git-cop
104
+ name: git-lint
133
105
  requirement: !ruby/object:Gem::Requirement
134
106
  requirements:
135
107
  - - "~>"
136
108
  - !ruby/object:Gem::Version
137
- version: '3.5'
109
+ version: '1.0'
138
110
  type: :development
139
111
  prerelease: false
140
112
  version_requirements: !ruby/object:Gem::Requirement
141
113
  requirements:
142
114
  - - "~>"
143
115
  - !ruby/object:Gem::Version
144
- version: '3.5'
116
+ version: '1.0'
145
117
  - !ruby/object:Gem::Dependency
146
118
  name: guard-rspec
147
119
  requirement: !ruby/object:Gem::Requirement
@@ -156,172 +128,158 @@ dependencies:
156
128
  - - "~>"
157
129
  - !ruby/object:Gem::Version
158
130
  version: '4.7'
159
- - !ruby/object:Gem::Dependency
160
- name: hirb
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '0.7'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '0.7'
173
131
  - !ruby/object:Gem::Dependency
174
132
  name: pry
175
133
  requirement: !ruby/object:Gem::Requirement
176
134
  requirements:
177
135
  - - "~>"
178
136
  - !ruby/object:Gem::Version
179
- version: '0.10'
137
+ version: '0.13'
180
138
  type: :development
181
139
  prerelease: false
182
140
  version_requirements: !ruby/object:Gem::Requirement
183
141
  requirements:
184
142
  - - "~>"
185
143
  - !ruby/object:Gem::Version
186
- version: '0.10'
144
+ version: '0.13'
187
145
  - !ruby/object:Gem::Dependency
188
146
  name: pry-byebug
189
147
  requirement: !ruby/object:Gem::Requirement
190
148
  requirements:
191
149
  - - "~>"
192
150
  - !ruby/object:Gem::Version
193
- version: '3.5'
151
+ version: '3.9'
194
152
  type: :development
195
153
  prerelease: false
196
154
  version_requirements: !ruby/object:Gem::Requirement
197
155
  requirements:
198
156
  - - "~>"
199
157
  - !ruby/object:Gem::Version
200
- version: '3.5'
158
+ version: '3.9'
201
159
  - !ruby/object:Gem::Dependency
202
160
  name: rake
203
161
  requirement: !ruby/object:Gem::Requirement
204
162
  requirements:
205
163
  - - "~>"
206
164
  - !ruby/object:Gem::Version
207
- version: '12.3'
165
+ version: '13.0'
208
166
  type: :development
209
167
  prerelease: false
210
168
  version_requirements: !ruby/object:Gem::Requirement
211
169
  requirements:
212
170
  - - "~>"
213
171
  - !ruby/object:Gem::Version
214
- version: '12.3'
172
+ version: '13.0'
215
173
  - !ruby/object:Gem::Dependency
216
174
  name: reek
217
175
  requirement: !ruby/object:Gem::Requirement
218
176
  requirements:
219
177
  - - "~>"
220
178
  - !ruby/object:Gem::Version
221
- version: '5.4'
179
+ version: '6.0'
222
180
  type: :development
223
181
  prerelease: false
224
182
  version_requirements: !ruby/object:Gem::Requirement
225
183
  requirements:
226
184
  - - "~>"
227
185
  - !ruby/object:Gem::Version
228
- version: '5.4'
186
+ version: '6.0'
229
187
  - !ruby/object:Gem::Dependency
230
188
  name: rspec
231
189
  requirement: !ruby/object:Gem::Requirement
232
190
  requirements:
233
191
  - - "~>"
234
192
  - !ruby/object:Gem::Version
235
- version: '3.8'
193
+ version: '3.9'
236
194
  type: :development
237
195
  prerelease: false
238
196
  version_requirements: !ruby/object:Gem::Requirement
239
197
  requirements:
240
198
  - - "~>"
241
199
  - !ruby/object:Gem::Version
242
- version: '3.8'
200
+ version: '3.9'
243
201
  - !ruby/object:Gem::Dependency
244
202
  name: rubocop
245
203
  requirement: !ruby/object:Gem::Requirement
246
204
  requirements:
247
205
  - - "~>"
248
206
  - !ruby/object:Gem::Version
249
- version: '0.73'
207
+ version: '0.83'
250
208
  type: :development
251
209
  prerelease: false
252
210
  version_requirements: !ruby/object:Gem::Requirement
253
211
  requirements:
254
212
  - - "~>"
255
213
  - !ruby/object:Gem::Version
256
- version: '0.73'
214
+ version: '0.83'
257
215
  - !ruby/object:Gem::Dependency
258
216
  name: rubocop-performance
259
217
  requirement: !ruby/object:Gem::Requirement
260
218
  requirements:
261
219
  - - "~>"
262
220
  - !ruby/object:Gem::Version
263
- version: '1.4'
221
+ version: '1.5'
264
222
  type: :development
265
223
  prerelease: false
266
224
  version_requirements: !ruby/object:Gem::Requirement
267
225
  requirements:
268
226
  - - "~>"
269
227
  - !ruby/object:Gem::Version
270
- version: '1.4'
228
+ version: '1.5'
271
229
  - !ruby/object:Gem::Dependency
272
- name: rubocop-rspec
230
+ name: rubocop-rake
273
231
  requirement: !ruby/object:Gem::Requirement
274
232
  requirements:
275
233
  - - "~>"
276
234
  - !ruby/object:Gem::Version
277
- version: '1.33'
235
+ version: '0.5'
278
236
  type: :development
279
237
  prerelease: false
280
238
  version_requirements: !ruby/object:Gem::Requirement
281
239
  requirements:
282
240
  - - "~>"
283
241
  - !ruby/object:Gem::Version
284
- version: '1.33'
242
+ version: '0.5'
285
243
  - !ruby/object:Gem::Dependency
286
- name: simplecov
244
+ name: rubocop-rspec
287
245
  requirement: !ruby/object:Gem::Requirement
288
246
  requirements:
289
247
  - - "~>"
290
248
  - !ruby/object:Gem::Version
291
- version: '0.13'
249
+ version: '1.39'
292
250
  type: :development
293
251
  prerelease: false
294
252
  version_requirements: !ruby/object:Gem::Requirement
295
253
  requirements:
296
254
  - - "~>"
297
255
  - !ruby/object:Gem::Version
298
- version: '0.13'
256
+ version: '1.39'
299
257
  - !ruby/object:Gem::Dependency
300
- name: wirb
258
+ name: simplecov
301
259
  requirement: !ruby/object:Gem::Requirement
302
260
  requirements:
303
261
  - - "~>"
304
262
  - !ruby/object:Gem::Version
305
- version: '2.1'
263
+ version: '0.18'
306
264
  type: :development
307
265
  prerelease: false
308
266
  version_requirements: !ruby/object:Gem::Requirement
309
267
  requirements:
310
268
  - - "~>"
311
269
  - !ruby/object:Gem::Version
312
- version: '2.1'
313
- description:
270
+ version: '0.18'
271
+ description:
314
272
  email:
315
273
  - brooke@alchemists.io
316
274
  executables:
317
275
  - pragmater
318
276
  extensions: []
319
277
  extra_rdoc_files:
320
- - README.md
321
- - LICENSE.md
278
+ - README.adoc
279
+ - LICENSE.adoc
322
280
  files:
323
- - LICENSE.md
324
- - README.md
281
+ - LICENSE.adoc
282
+ - README.adoc
325
283
  - bin/pragmater
326
284
  - lib/pragmater.rb
327
285
  - lib/pragmater/cli.rb
@@ -330,14 +288,15 @@ files:
330
288
  - lib/pragmater/identity.rb
331
289
  - lib/pragmater/runner.rb
332
290
  - lib/pragmater/writer.rb
333
- homepage: https://github.com/bkuhlmann/pragmater
291
+ homepage: https://www.alchemists.io/projects/pragmater
334
292
  licenses:
335
293
  - Apache-2.0
336
294
  metadata:
337
- source_code_uri: https://github.com/bkuhlmann/pragmater
338
- changelog_uri: https://github.com/bkuhlmann/pragmater/blob/master/CHANGES.md
339
295
  bug_tracker_uri: https://github.com/bkuhlmann/pragmater/issues
340
- post_install_message:
296
+ changelog_uri: https://www.alchemists.io/projects/pragmater/changes.html
297
+ documentation_uri: https://www.alchemists.io/projects/pragmater
298
+ source_code_uri: https://github.com/bkuhlmann/pragmater
299
+ post_install_message:
341
300
  rdoc_options: []
342
301
  require_paths:
343
302
  - lib
@@ -345,15 +304,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
345
304
  requirements:
346
305
  - - "~>"
347
306
  - !ruby/object:Gem::Version
348
- version: '2.6'
307
+ version: '2.7'
349
308
  required_rubygems_version: !ruby/object:Gem::Requirement
350
309
  requirements:
351
310
  - - ">="
352
311
  - !ruby/object:Gem::Version
353
312
  version: '0'
354
313
  requirements: []
355
- rubygems_version: 3.0.6
356
- signing_key:
314
+ rubygems_version: 3.1.4
315
+ signing_key:
357
316
  specification_version: 4
358
317
  summary: A command line interface for managing/formatting source file pragma comments.
359
318
  test_files: []
metadata.gz.sig CHANGED
Binary file
data/README.md DELETED
@@ -1,263 +0,0 @@
1
- <p align="center">
2
- <img src="pragmater.png" alt="Pragmater Icon"/>
3
- </p>
4
-
5
- # Pragmater
6
-
7
- [![Gem Version](https://badge.fury.io/rb/pragmater.svg)](http://badge.fury.io/rb/pragmater)
8
- [![Code Climate Maintainability](https://api.codeclimate.com/v1/badges/f0971ab6985309ce4db4/maintainability)](https://codeclimate.com/github/bkuhlmann/pragmater/maintainability)
9
- [![Code Climate Test Coverage](https://api.codeclimate.com/v1/badges/f0971ab6985309ce4db4/test_coverage)](https://codeclimate.com/github/bkuhlmann/pragmater/test_coverage)
10
- [![Circle CI Status](https://circleci.com/gh/bkuhlmann/pragmater.svg?style=svg)](https://circleci.com/gh/bkuhlmann/pragmater)
11
-
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:
14
-
15
- #! /usr/bin/env ruby
16
- # frozen_string_literal: true
17
- # encoding: UTF-8
18
-
19
- With [Ruby 2.3.0](https://www.ruby-lang.org/en/news/2015/12/25/ruby-2-3-0-released), frozen strings
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.
22
-
23
- <!-- Tocer[start]: Auto-generated, don't remove. -->
24
-
25
- ## Table of Contents
26
-
27
- - [Features](#features)
28
- - [Screencasts](#screencasts)
29
- - [Requirements](#requirements)
30
- - [Setup](#setup)
31
- - [Usage](#usage)
32
- - [Command Line Interface (CLI)](#command-line-interface-cli)
33
- - [Customization](#customization)
34
- - [Available Pragmas](#available-pragmas)
35
- - [Syntax](#syntax)
36
- - [Precedence](#precedence)
37
- - [Frozen String Literals](#frozen-string-literals)
38
- - [Tests](#tests)
39
- - [Versioning](#versioning)
40
- - [Code of Conduct](#code-of-conduct)
41
- - [Contributions](#contributions)
42
- - [License](#license)
43
- - [History](#history)
44
- - [Credits](#credits)
45
-
46
- <!-- Tocer[finish]: Auto-generated, don't remove. -->
47
-
48
- ## Features
49
-
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.
52
- - Supports file list filtering. Defaults to any file.
53
- - Ensures duplicate pragmas never exist.
54
- - Ensures pragmas are consistently formatted.
55
-
56
- ## Screencasts
57
-
58
- [![asciicast](https://asciinema.org/a/155880.png)](https://asciinema.org/a/155880)
59
-
60
- ## Requirements
61
-
62
- 1. [Ruby 2.6.x](https://www.ruby-lang.org)
63
-
64
- ## Setup
65
-
66
- Type the following to install:
67
-
68
- gem install pragmater
69
-
70
- ## Usage
71
-
72
- ### Command Line Interface (CLI)
73
-
74
- From the command line, type: `pragmater help`
75
-
76
- pragmater -a, [--add=PATH] # Add comments to source file(s).
77
- pragmater -c, [--config] # Manage gem configuration.
78
- pragmater -h, [--help=COMMAND] # Show this message or get help for a command.
79
- pragmater -r, [--remove=PATH] # Remove comments from source file(s).
80
- pragmater -v, [--version] # Show gem version.
81
-
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`):
84
-
85
- -c, [--comments=one two three] # Define desired comments
86
- -i, [--includes=one two three] # Include specific files and/or directories
87
-
88
- Example (same options could be used for the `--remove` command too):
89
-
90
- pragmater --add --comments "# frozen_string_literal: true" --includes "Gemfile" "Guardfile" "Rakefile" ".gemspec" "config.ru" "bin/**/*" "**/*.rake" "**/*.rb"
91
-
92
- The `--add` and `--remove` commands default to the current working directory so a path isn't
93
- necessary unless you want to run Pragmater on a directory structure *other than* your current
94
- working directory.
95
-
96
- ### Customization
97
-
98
- This gem can be configured via a global configuration:
99
-
100
- ~/.config/pragmater/configuration.yml
101
-
102
- It can also be configured via [XDG](https://github.com/bkuhlmann/xdg) environment variables.
103
-
104
- The default configuration is as follows:
105
-
106
- :add:
107
- :comments: []
108
- :includes: []
109
- :remove:
110
- :comments: []
111
- :includes: []
112
-
113
- Feel free to take this default configuration, modify, and save as your own custom
114
- `configuration.yml`.
115
-
116
- The `configuration.yml` file can be configured as follows:
117
-
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.
173
-
174
- ### Frozen String Literals
175
-
176
- Support for frozen string literals was added in Ruby 2.3.0. The ability to freeze strings within a
177
- source can be done by placing a frozen string pragma at the top of each source file. Example:
178
-
179
- # frozen_string_literal: true
180
-
181
- This is great for *selective* enablement of frozen string literals but might be too much work for
182
- some (even with the aid of this gem). As an alternative, frozen string literals can be enabled via
183
- the following Ruby command line option:
184
-
185
- --enable=frozen-string-literal
186
-
187
- It is important to note that, once enabled, this freezes strings program-wide -- It's an all or
188
- nothing option.
189
-
190
- Regardless of whether you leverage the capabilities of this gem or the Ruby command line option
191
- mentioned above, the following Ruby command line option is available to aid debugging and tracking
192
- down frozen string literal issues:
193
-
194
- --debug=frozen-string-literal
195
-
196
- Ruby 2.3.0 also added the following methods to the `String` class:
197
-
198
- - `String#+@`: Answers a duplicated, mutable, string if not already frozen. Example:
199
-
200
- immutable = "test".freeze
201
- mutable = +immutable
202
- mutable.capitalize! # => "Test"
203
-
204
- - `String#-@`: Answers a immutable string if not already frozen. Example:
205
-
206
- mutable = "test"
207
- immutable = -mutable
208
- immutable.capitalize! # => FrozenError
209
-
210
- You can also use the methods, shown above, for variable initialization. Example:
211
-
212
- immutable = -"test"
213
- mutable = +"test"
214
-
215
- Despite Ruby allowing you to do this, it is *not recommended* to use the above examples as it leads
216
- to hard to read code. Instead use the following:
217
-
218
- immutable = "test".freeze
219
- mutable = "test"
220
-
221
- While this requires extra typing, it expresses intent more clearly. There is a slight caveat to this
222
- rule in which the use of `String#-@` was [enhanced in Ruby 2.5.0](http://bit.ly/2DGAjgG) to
223
- *deduplicate* all instances of the same string thus reducing your memory footprint. This can be
224
- valuable in situations where you are not using the frozen string comment and need to selectively
225
- freeze strings.
226
-
227
- ## Tests
228
-
229
- To test, run:
230
-
231
- bundle exec rake
232
-
233
- ## Versioning
234
-
235
- Read [Semantic Versioning](https://semver.org) for details. Briefly, it means:
236
-
237
- - Major (X.y.z) - Incremented for any backwards incompatible public API changes.
238
- - Minor (x.Y.z) - Incremented for new, backwards compatible, public API enhancements/fixes.
239
- - Patch (x.y.Z) - Incremented for small, backwards compatible, bug fixes.
240
-
241
- ## Code of Conduct
242
-
243
- Please note that this project is released with a [CODE OF CONDUCT](CODE_OF_CONDUCT.md). By
244
- participating in this project you agree to abide by its terms.
245
-
246
- ## Contributions
247
-
248
- Read [CONTRIBUTING](CONTRIBUTING.md) for details.
249
-
250
- ## License
251
-
252
- Copyright 2015 [Alchemists](https://www.alchemists.io).
253
- Read [LICENSE](LICENSE.md) for details.
254
-
255
- ## History
256
-
257
- Read [CHANGES](CHANGES.md) for details.
258
- Built with [Gemsmith](https://github.com/bkuhlmann/gemsmith).
259
-
260
- ## Credits
261
-
262
- Developed by [Brooke Kuhlmann](https://www.alchemists.io) at
263
- [Alchemists](https://www.alchemists.io).