dotenv-init 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.rubocop.yml +614 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +84 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/dotenv-init +8 -0
- data/bin/rspec +17 -0
- data/bin/setup +8 -0
- data/circle.yml +3 -0
- data/dotenv-init.gemspec +29 -0
- data/lib/dotenv/init.rb +9 -0
- data/lib/dotenv/init/assigner.rb +44 -0
- data/lib/dotenv/init/cli.rb +48 -0
- data/lib/dotenv/init/comment_aware_parser.rb +100 -0
- data/lib/dotenv/init/version.rb +5 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 997a16a8601fe23db03bf06da4681472f96b8fc2
|
4
|
+
data.tar.gz: 5099b8166736ec67344fd90f95ac6a7e14825220
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9b2c7169a60b7e7b5e8cbebb9567691ac206ce85f7c2998202c82b80d35053b14d9ac0cba6c1f60ba21a0039959695c2394a04946e3d71f833978f3465fac667
|
7
|
+
data.tar.gz: 3b07f35dd6443bdd3b49b1a158214b451f827ce627bb04be29f5708def425b5d78d6a4324a3af628e509208f41fa9121e8ecc387895ba89e883017bc7b02ff41
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,614 @@
|
|
1
|
+
AllCops:
|
2
|
+
Exclude:
|
3
|
+
- "*.gemspec"
|
4
|
+
|
5
|
+
TargetRubyVersion: 2.3
|
6
|
+
|
7
|
+
Style/AccessorMethodName:
|
8
|
+
Description: Check the naming of accessor methods for get_/set_.
|
9
|
+
Enabled: false
|
10
|
+
|
11
|
+
Style/Alias:
|
12
|
+
Description: 'Use alias_method instead of alias.'
|
13
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method'
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/ArrayJoin:
|
17
|
+
Description: 'Use Array#join instead of Array#*.'
|
18
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join'
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/AsciiComments:
|
22
|
+
Description: 'Use only ascii symbols in comments.'
|
23
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments'
|
24
|
+
Enabled: false
|
25
|
+
|
26
|
+
Style/AsciiIdentifiers:
|
27
|
+
Description: 'Use only ascii symbols in identifiers.'
|
28
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers'
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/Attr:
|
32
|
+
Description: 'Checks for uses of Module#attr.'
|
33
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr'
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
Style/FrozenStringLiteralComment:
|
37
|
+
Enabled: false
|
38
|
+
|
39
|
+
Metrics/BlockNesting:
|
40
|
+
Description: 'Avoid excessive block nesting'
|
41
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count'
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
Style/CaseEquality:
|
45
|
+
Description: 'Avoid explicit use of the case equality operator(===).'
|
46
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality'
|
47
|
+
Enabled: false
|
48
|
+
|
49
|
+
Style/CharacterLiteral:
|
50
|
+
Description: 'Checks for uses of character literals.'
|
51
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals'
|
52
|
+
Enabled: false
|
53
|
+
|
54
|
+
Style/ClassAndModuleChildren:
|
55
|
+
Description: 'Checks style of children classes and modules.'
|
56
|
+
Enabled: true
|
57
|
+
EnforcedStyle: nested
|
58
|
+
|
59
|
+
Metrics/ClassLength:
|
60
|
+
Description: 'Avoid classes longer than 100 lines of code.'
|
61
|
+
Enabled: false
|
62
|
+
|
63
|
+
Metrics/ModuleLength:
|
64
|
+
Description: 'Avoid modules longer than 100 lines of code.'
|
65
|
+
Enabled: false
|
66
|
+
|
67
|
+
Style/ClassVars:
|
68
|
+
Description: 'Avoid the use of class variables.'
|
69
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars'
|
70
|
+
Enabled: false
|
71
|
+
|
72
|
+
Style/CollectionMethods:
|
73
|
+
Enabled: true
|
74
|
+
PreferredMethods:
|
75
|
+
find: detect
|
76
|
+
inject: reduce
|
77
|
+
collect: map
|
78
|
+
find_all: select
|
79
|
+
|
80
|
+
Style/ColonMethodCall:
|
81
|
+
Description: 'Do not use :: for method call.'
|
82
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons'
|
83
|
+
Enabled: false
|
84
|
+
|
85
|
+
Style/CommentAnnotation:
|
86
|
+
Description: >-
|
87
|
+
Checks formatting of special comments
|
88
|
+
(TODO, FIXME, OPTIMIZE, HACK, REVIEW).
|
89
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords'
|
90
|
+
Enabled: false
|
91
|
+
|
92
|
+
Metrics/CyclomaticComplexity:
|
93
|
+
Description: >-
|
94
|
+
A complexity metric that is strongly correlated to the number
|
95
|
+
of test cases needed to validate a method.
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Rails/Delegate:
|
99
|
+
Description: 'Prefer delegate method for delegations.'
|
100
|
+
Enabled: false
|
101
|
+
|
102
|
+
Style/DeprecatedHashMethods:
|
103
|
+
Description: 'Checks for use of deprecated Hash methods.'
|
104
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key'
|
105
|
+
Enabled: false
|
106
|
+
|
107
|
+
Style/Documentation:
|
108
|
+
Description: 'Document classes and non-namespace modules.'
|
109
|
+
Enabled: false
|
110
|
+
|
111
|
+
Style/DotPosition:
|
112
|
+
Description: 'Checks the position of the dot in multi-line method calls.'
|
113
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains'
|
114
|
+
EnforcedStyle: trailing
|
115
|
+
|
116
|
+
Style/DoubleNegation:
|
117
|
+
Description: 'Checks for uses of double negation (!!).'
|
118
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang'
|
119
|
+
Enabled: false
|
120
|
+
|
121
|
+
Style/EachWithObject:
|
122
|
+
Description: 'Prefer `each_with_object` over `inject` or `reduce`.'
|
123
|
+
Enabled: false
|
124
|
+
|
125
|
+
Style/EmptyLiteral:
|
126
|
+
Description: 'Prefer literals to Array.new/Hash.new/String.new.'
|
127
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash'
|
128
|
+
Enabled: false
|
129
|
+
|
130
|
+
# Checks whether the source file has a utf-8 encoding comment or not
|
131
|
+
# AutoCorrectEncodingComment must match the regex
|
132
|
+
# /#.*coding\s?[:=]\s?(?:UTF|utf)-8/
|
133
|
+
Style/Encoding:
|
134
|
+
Enabled: false
|
135
|
+
|
136
|
+
Style/EvenOdd:
|
137
|
+
Description: 'Favor the use of Fixnum#even? && Fixnum#odd?'
|
138
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
|
139
|
+
Enabled: false
|
140
|
+
|
141
|
+
Style/ExtraSpacing:
|
142
|
+
Description: 'Do not use unnecessary spacing.'
|
143
|
+
Enabled: true
|
144
|
+
|
145
|
+
Style/FileName:
|
146
|
+
Description: 'Use snake_case for source file names.'
|
147
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files'
|
148
|
+
Enabled: false
|
149
|
+
|
150
|
+
Style/FlipFlop:
|
151
|
+
Description: 'Checks for flip flops'
|
152
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops'
|
153
|
+
Enabled: false
|
154
|
+
|
155
|
+
Style/FormatString:
|
156
|
+
Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.'
|
157
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf'
|
158
|
+
Enabled: false
|
159
|
+
|
160
|
+
Style/GlobalVars:
|
161
|
+
Description: 'Do not introduce global variables.'
|
162
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars'
|
163
|
+
Reference: 'http://www.zenspider.com/Languages/Ruby/QuickRef.html'
|
164
|
+
Enabled: false
|
165
|
+
|
166
|
+
Style/GuardClause:
|
167
|
+
Description: 'Check for conditionals that can be replaced with guard clauses'
|
168
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
|
169
|
+
Enabled: false
|
170
|
+
|
171
|
+
Style/IfUnlessModifier:
|
172
|
+
Description: >-
|
173
|
+
Favor modifier if/unless usage when you have a
|
174
|
+
single-line body.
|
175
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier'
|
176
|
+
Enabled: false
|
177
|
+
|
178
|
+
Style/IfWithSemicolon:
|
179
|
+
Description: 'Do not use if x; .... Use the ternary operator instead.'
|
180
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs'
|
181
|
+
Enabled: false
|
182
|
+
|
183
|
+
Style/InlineComment:
|
184
|
+
Description: 'Avoid inline comments.'
|
185
|
+
Enabled: false
|
186
|
+
|
187
|
+
Style/Lambda:
|
188
|
+
Description: 'Use the new lambda literal syntax for single-line blocks.'
|
189
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line'
|
190
|
+
Enabled: false
|
191
|
+
|
192
|
+
Style/LambdaCall:
|
193
|
+
Description: 'Use lambda.call(...) instead of lambda.(...).'
|
194
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call'
|
195
|
+
Enabled: false
|
196
|
+
|
197
|
+
Style/LineEndConcatenation:
|
198
|
+
Description: >-
|
199
|
+
Use \ instead of + or << to concatenate two string literals at
|
200
|
+
line end.
|
201
|
+
Enabled: false
|
202
|
+
|
203
|
+
Metrics/LineLength:
|
204
|
+
Description: 'Limit lines to 100 characters.'
|
205
|
+
Max: 100
|
206
|
+
Exclude:
|
207
|
+
- config/initializers/secret_token.rb
|
208
|
+
|
209
|
+
Metrics/MethodLength:
|
210
|
+
Description: 'Avoid methods longer than 10 lines of code.'
|
211
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods'
|
212
|
+
Enabled: false
|
213
|
+
|
214
|
+
Style/ModuleFunction:
|
215
|
+
Description: 'Checks for usage of `extend self` in modules.'
|
216
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function'
|
217
|
+
Enabled: false
|
218
|
+
|
219
|
+
Style/MultilineOperationIndentation:
|
220
|
+
Description: >-
|
221
|
+
Checks indentation of binary operations that span more than
|
222
|
+
one line.
|
223
|
+
Enabled: true
|
224
|
+
EnforcedStyle: indented
|
225
|
+
|
226
|
+
Style/NegatedIf:
|
227
|
+
Description: >-
|
228
|
+
Favor unless over if for negative conditions
|
229
|
+
(or control flow or).
|
230
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives'
|
231
|
+
Enabled: false
|
232
|
+
|
233
|
+
Style/NegatedWhile:
|
234
|
+
Description: 'Favor until over while for negative conditions.'
|
235
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives'
|
236
|
+
Enabled: false
|
237
|
+
|
238
|
+
Style/Next:
|
239
|
+
Description: 'Use `next` to skip iteration instead of a condition at the end.'
|
240
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals'
|
241
|
+
Enabled: false
|
242
|
+
|
243
|
+
Style/NilComparison:
|
244
|
+
Description: 'Prefer x.nil? to x == nil.'
|
245
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods'
|
246
|
+
Enabled: false
|
247
|
+
|
248
|
+
Style/Not:
|
249
|
+
Description: 'Use ! instead of not.'
|
250
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not'
|
251
|
+
Enabled: false
|
252
|
+
|
253
|
+
Style/NumericLiterals:
|
254
|
+
Description: >-
|
255
|
+
Add underscores to large numeric literals to improve their
|
256
|
+
readability.
|
257
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics'
|
258
|
+
Enabled: false
|
259
|
+
|
260
|
+
Style/OneLineConditional:
|
261
|
+
Description: >-
|
262
|
+
Favor the ternary operator(?:) over
|
263
|
+
if/then/else/end constructs.
|
264
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator'
|
265
|
+
Enabled: false
|
266
|
+
|
267
|
+
Style/OpMethod:
|
268
|
+
Description: 'When defining binary operators, name the argument other.'
|
269
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg'
|
270
|
+
Enabled: false
|
271
|
+
|
272
|
+
Metrics/ParameterLists:
|
273
|
+
Description: 'Avoid parameter lists longer than three or four parameters.'
|
274
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params'
|
275
|
+
Enabled: false
|
276
|
+
|
277
|
+
Style/PercentLiteralDelimiters:
|
278
|
+
Description: 'Use `%`-literal delimiters consistently'
|
279
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces'
|
280
|
+
Enabled: false
|
281
|
+
|
282
|
+
Style/PerlBackrefs:
|
283
|
+
Description: 'Avoid Perl-style regex back references.'
|
284
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers'
|
285
|
+
Enabled: false
|
286
|
+
|
287
|
+
Style/PredicateName:
|
288
|
+
Description: 'Check the names of predicate methods.'
|
289
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark'
|
290
|
+
NamePrefixBlacklist:
|
291
|
+
- is_
|
292
|
+
Exclude:
|
293
|
+
- spec/**/*
|
294
|
+
|
295
|
+
Style/Proc:
|
296
|
+
Description: 'Use proc instead of Proc.new.'
|
297
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc'
|
298
|
+
Enabled: false
|
299
|
+
|
300
|
+
Style/RaiseArgs:
|
301
|
+
Description: 'Checks the arguments passed to raise/fail.'
|
302
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages'
|
303
|
+
Enabled: false
|
304
|
+
|
305
|
+
Style/RegexpLiteral:
|
306
|
+
Description: 'Use / or %r around regular expressions.'
|
307
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r'
|
308
|
+
Enabled: false
|
309
|
+
|
310
|
+
Style/SelfAssignment:
|
311
|
+
Description: >-
|
312
|
+
Checks for places where self-assignment shorthand should have
|
313
|
+
been used.
|
314
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment'
|
315
|
+
Enabled: false
|
316
|
+
|
317
|
+
Style/SingleLineBlockParams:
|
318
|
+
Description: 'Enforces the names of some block params.'
|
319
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks'
|
320
|
+
Enabled: false
|
321
|
+
|
322
|
+
Style/SingleLineMethods:
|
323
|
+
Description: 'Avoid single-line methods.'
|
324
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods'
|
325
|
+
Enabled: false
|
326
|
+
|
327
|
+
Style/SignalException:
|
328
|
+
Description: 'Checks for proper usage of fail and raise.'
|
329
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method'
|
330
|
+
Enabled: false
|
331
|
+
|
332
|
+
Style/SpecialGlobalVars:
|
333
|
+
Description: 'Avoid Perl-style global variables.'
|
334
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms'
|
335
|
+
Enabled: false
|
336
|
+
|
337
|
+
Style/StringLiterals:
|
338
|
+
Description: 'Checks if uses of quotes match the configured preference.'
|
339
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals'
|
340
|
+
EnforcedStyle: double_quotes
|
341
|
+
Enabled: true
|
342
|
+
|
343
|
+
Style/TrailingCommaInArguments:
|
344
|
+
Description: 'Checks for trailing comma in argument lists.'
|
345
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
346
|
+
EnforcedStyleForMultiline: comma
|
347
|
+
SupportedStyles:
|
348
|
+
- comma
|
349
|
+
- consistent_comma
|
350
|
+
- no_comma
|
351
|
+
Enabled: true
|
352
|
+
|
353
|
+
Style/TrailingCommaInLiteral:
|
354
|
+
Description: 'Checks for trailing comma in array and hash literals.'
|
355
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
356
|
+
EnforcedStyleForMultiline: comma
|
357
|
+
SupportedStyles:
|
358
|
+
- comma
|
359
|
+
- consistent_comma
|
360
|
+
- no_comma
|
361
|
+
Enabled: true
|
362
|
+
|
363
|
+
Style/TrivialAccessors:
|
364
|
+
Description: 'Prefer attr_* methods to trivial readers/writers.'
|
365
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family'
|
366
|
+
Enabled: false
|
367
|
+
|
368
|
+
Style/VariableInterpolation:
|
369
|
+
Description: >-
|
370
|
+
Don't interpolate global, instance and class variables
|
371
|
+
directly in strings.
|
372
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate'
|
373
|
+
Enabled: false
|
374
|
+
|
375
|
+
Style/WhenThen:
|
376
|
+
Description: 'Use when x then ... for one-line cases.'
|
377
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases'
|
378
|
+
Enabled: false
|
379
|
+
|
380
|
+
Style/WhileUntilModifier:
|
381
|
+
Description: >-
|
382
|
+
Favor modifier while/until usage when you have a
|
383
|
+
single-line body.
|
384
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier'
|
385
|
+
Enabled: false
|
386
|
+
|
387
|
+
Style/WordArray:
|
388
|
+
Description: 'Use %w or %W for arrays of words.'
|
389
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w'
|
390
|
+
Enabled: false
|
391
|
+
|
392
|
+
# Lint
|
393
|
+
|
394
|
+
Lint/AmbiguousOperator:
|
395
|
+
Description: >-
|
396
|
+
Checks for ambiguous operators in the first argument of a
|
397
|
+
method invocation without parentheses.
|
398
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args'
|
399
|
+
Enabled: false
|
400
|
+
|
401
|
+
Lint/AmbiguousRegexpLiteral:
|
402
|
+
Description: >-
|
403
|
+
Checks for ambiguous regexp literals in the first argument of
|
404
|
+
a method invocation without parenthesis.
|
405
|
+
Enabled: false
|
406
|
+
|
407
|
+
Lint/AssignmentInCondition:
|
408
|
+
Description: "Don't use assignment in conditions."
|
409
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition'
|
410
|
+
Enabled: false
|
411
|
+
|
412
|
+
Lint/CircularArgumentReference:
|
413
|
+
Description: "Don't refer to the keyword argument in the default value."
|
414
|
+
Enabled: false
|
415
|
+
|
416
|
+
Lint/ConditionPosition:
|
417
|
+
Description: >-
|
418
|
+
Checks for condition placed in a confusing position relative to
|
419
|
+
the keyword.
|
420
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition'
|
421
|
+
Enabled: false
|
422
|
+
|
423
|
+
Lint/DeprecatedClassMethods:
|
424
|
+
Description: 'Check for deprecated class method calls.'
|
425
|
+
Enabled: false
|
426
|
+
|
427
|
+
Lint/DuplicatedKey:
|
428
|
+
Description: 'Check for duplicate keys in hash literals.'
|
429
|
+
Enabled: false
|
430
|
+
|
431
|
+
Lint/EachWithObjectArgument:
|
432
|
+
Description: 'Check for immutable argument given to each_with_object.'
|
433
|
+
Enabled: false
|
434
|
+
|
435
|
+
Lint/ElseLayout:
|
436
|
+
Description: 'Check for odd code arrangement in an else block.'
|
437
|
+
Enabled: false
|
438
|
+
|
439
|
+
Lint/FormatParameterMismatch:
|
440
|
+
Description: 'The number of parameters to format/sprint must match the fields.'
|
441
|
+
Enabled: false
|
442
|
+
|
443
|
+
Lint/HandleExceptions:
|
444
|
+
Description: "Don't suppress exception."
|
445
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions'
|
446
|
+
Enabled: false
|
447
|
+
|
448
|
+
Lint/InvalidCharacterLiteral:
|
449
|
+
Description: >-
|
450
|
+
Checks for invalid character literals with a non-escaped
|
451
|
+
whitespace character.
|
452
|
+
Enabled: false
|
453
|
+
|
454
|
+
Style/InitialIndentation:
|
455
|
+
Description: >-
|
456
|
+
Checks the indentation of the first non-blank non-comment line in a file.
|
457
|
+
Enabled: false
|
458
|
+
|
459
|
+
Lint/LiteralInCondition:
|
460
|
+
Description: 'Checks of literals used in conditions.'
|
461
|
+
Enabled: false
|
462
|
+
|
463
|
+
Lint/LiteralInInterpolation:
|
464
|
+
Description: 'Checks for literals used in interpolation.'
|
465
|
+
Enabled: false
|
466
|
+
|
467
|
+
Lint/Loop:
|
468
|
+
Description: >-
|
469
|
+
Use Kernel#loop with break rather than begin/end/until or
|
470
|
+
begin/end/while for post-loop tests.
|
471
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break'
|
472
|
+
Enabled: false
|
473
|
+
|
474
|
+
Lint/NestedMethodDefinition:
|
475
|
+
Description: 'Do not use nested method definitions.'
|
476
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-methods'
|
477
|
+
Enabled: false
|
478
|
+
|
479
|
+
Lint/NonLocalExitFromIterator:
|
480
|
+
Description: 'Do not use return in iterator to cause non-local exit.'
|
481
|
+
Enabled: false
|
482
|
+
|
483
|
+
Lint/ParenthesesAsGroupedExpression:
|
484
|
+
Description: >-
|
485
|
+
Checks for method calls with a space before the opening
|
486
|
+
parenthesis.
|
487
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces'
|
488
|
+
Enabled: false
|
489
|
+
|
490
|
+
Lint/RequireParentheses:
|
491
|
+
Description: >-
|
492
|
+
Use parentheses in the method call to avoid confusion
|
493
|
+
about precedence.
|
494
|
+
Enabled: false
|
495
|
+
|
496
|
+
Lint/UnderscorePrefixedVariableName:
|
497
|
+
Description: 'Do not use prefix `_` for a variable that is used.'
|
498
|
+
Enabled: false
|
499
|
+
|
500
|
+
Lint/UnneededDisable:
|
501
|
+
Description: >-
|
502
|
+
Checks for rubocop:disable comments that can be removed.
|
503
|
+
Note: this cop is not disabled when disabling all cops.
|
504
|
+
It must be explicitly disabled.
|
505
|
+
Enabled: false
|
506
|
+
|
507
|
+
Lint/Void:
|
508
|
+
Description: 'Possible use of operator/literal/variable in void context.'
|
509
|
+
Enabled: false
|
510
|
+
|
511
|
+
# Performance
|
512
|
+
|
513
|
+
Performance/CaseWhenSplat:
|
514
|
+
Description: >-
|
515
|
+
Place `when` conditions that use splat at the end
|
516
|
+
of the list of `when` branches.
|
517
|
+
Enabled: false
|
518
|
+
|
519
|
+
Performance/Count:
|
520
|
+
Description: >-
|
521
|
+
Use `count` instead of `select...size`, `reject...size`,
|
522
|
+
`select...count`, `reject...count`, `select...length`,
|
523
|
+
and `reject...length`.
|
524
|
+
Enabled: false
|
525
|
+
|
526
|
+
Performance/Detect:
|
527
|
+
Description: >-
|
528
|
+
Use `detect` instead of `select.first`, `find_all.first`,
|
529
|
+
`select.last`, and `find_all.last`.
|
530
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerabledetect-vs-enumerableselectfirst-code'
|
531
|
+
Enabled: false
|
532
|
+
|
533
|
+
Performance/FlatMap:
|
534
|
+
Description: >-
|
535
|
+
Use `Enumerable#flat_map`
|
536
|
+
instead of `Enumerable#map...Array#flatten(1)`
|
537
|
+
or `Enumberable#collect..Array#flatten(1)`
|
538
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablemaparrayflatten-vs-enumerableflat_map-code'
|
539
|
+
Enabled: false
|
540
|
+
|
541
|
+
Performance/ReverseEach:
|
542
|
+
Description: 'Use `reverse_each` instead of `reverse.each`.'
|
543
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#enumerablereverseeach-vs-enumerablereverse_each-code'
|
544
|
+
Enabled: false
|
545
|
+
|
546
|
+
Performance/Sample:
|
547
|
+
Description: >-
|
548
|
+
Use `sample` instead of `shuffle.first`,
|
549
|
+
`shuffle.last`, and `shuffle[Fixnum]`.
|
550
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arrayshufflefirst-vs-arraysample-code'
|
551
|
+
Enabled: false
|
552
|
+
|
553
|
+
Performance/Size:
|
554
|
+
Description: >-
|
555
|
+
Use `size` instead of `count` for counting
|
556
|
+
the number of elements in `Array` and `Hash`.
|
557
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#arraycount-vs-arraysize-code'
|
558
|
+
Enabled: false
|
559
|
+
|
560
|
+
Performance/StringReplacement:
|
561
|
+
Description: >-
|
562
|
+
Use `tr` instead of `gsub` when you are replacing the same
|
563
|
+
number of characters. Use `delete` instead of `gsub` when
|
564
|
+
you are deleting characters.
|
565
|
+
Reference: 'https://github.com/JuanitoFatas/fast-ruby#stringgsub-vs-stringtr-code'
|
566
|
+
Enabled: false
|
567
|
+
|
568
|
+
# Rails
|
569
|
+
|
570
|
+
Rails/ActionFilter:
|
571
|
+
Description: 'Enforces consistent use of action filter methods.'
|
572
|
+
Enabled: false
|
573
|
+
|
574
|
+
Rails/Date:
|
575
|
+
Description: >-
|
576
|
+
Checks the correct usage of date aware methods,
|
577
|
+
such as Date.today, Date.current etc.
|
578
|
+
Enabled: false
|
579
|
+
|
580
|
+
Rails/FindBy:
|
581
|
+
Description: 'Prefer find_by over where.first.'
|
582
|
+
Enabled: false
|
583
|
+
|
584
|
+
Rails/FindEach:
|
585
|
+
Description: 'Prefer all.find_each over all.find.'
|
586
|
+
Enabled: false
|
587
|
+
|
588
|
+
Rails/HasAndBelongsToMany:
|
589
|
+
Description: 'Prefer has_many :through to has_and_belongs_to_many.'
|
590
|
+
Enabled: false
|
591
|
+
|
592
|
+
Rails/Output:
|
593
|
+
Description: 'Checks for calls to puts, print, etc.'
|
594
|
+
Enabled: false
|
595
|
+
|
596
|
+
Rails/ReadWriteAttribute:
|
597
|
+
Description: >-
|
598
|
+
Checks for read_attribute(:attr) and
|
599
|
+
write_attribute(:attr, val).
|
600
|
+
Enabled: false
|
601
|
+
|
602
|
+
Rails/ScopeArgs:
|
603
|
+
Description: 'Checks the arguments of ActiveRecord scopes.'
|
604
|
+
Enabled: false
|
605
|
+
|
606
|
+
Rails/TimeZone:
|
607
|
+
Description: 'Checks the correct usage of time zone aware methods.'
|
608
|
+
StyleGuide: 'https://github.com/bbatsov/rails-style-guide#time'
|
609
|
+
Reference: 'http://danilenko.org/2012/7/6/rails_timezones'
|
610
|
+
Enabled: false
|
611
|
+
|
612
|
+
Rails/Validation:
|
613
|
+
Description: 'Use validates :attribute, hash of validations.'
|
614
|
+
Enabled: false
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Steven Petryk
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Dotenv::Init
|
2
|
+
|
3
|
+
[![CircleCI](https://circleci.com/gh/stevenpetryk/dotenv-init.svg?style=svg)](https://circleci.com/gh/stevenpetryk/dotenv-init)
|
4
|
+
|
5
|
+
Copy over your `.env.example` in style.
|
6
|
+
|
7
|
+
## Rationale
|
8
|
+
|
9
|
+
Typically, in any marginally complex app using [dotenv](https://github.com/bkeepers/dotenv), you'll have some step in new developer onboarding where you need to copy over a `.env.example` file to `.env`.
|
10
|
+
|
11
|
+
Also, in most Rails apps, gems, and other setups, you typically have a `bin/setup` script that will do its best to automate the app bootstrapping process for freshly cloned copies.
|
12
|
+
|
13
|
+
This is an attempt to harmonize these two concepts by creating a user-friendly automated flow for filling in `.env`.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
To install globally and run anywhere:
|
18
|
+
|
19
|
+
```
|
20
|
+
gem install dotenv-init
|
21
|
+
```
|
22
|
+
|
23
|
+
Or, to use in your project (i.e., in `bin/setup`):
|
24
|
+
|
25
|
+
```
|
26
|
+
gem "dotenv-init", group: :development
|
27
|
+
|
28
|
+
# Optional: enable colors
|
29
|
+
gem "colorize"
|
30
|
+
```
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
|
34
|
+
Given a `.env.example` like this:
|
35
|
+
|
36
|
+
```
|
37
|
+
# Facebook credentials can be found in the 1Password Vault.
|
38
|
+
# Create a test app specifically for your local copy of this
|
39
|
+
# app and then grab its app ID.
|
40
|
+
export FACEBOOK_APP_ID=
|
41
|
+
|
42
|
+
# This is the password used as a backdoor to the admin
|
43
|
+
# console in the event the client locks themselves out (again).
|
44
|
+
# Regenerate with `rake secret`, or just use the default in development:
|
45
|
+
export ADMIN_PASSWORD=hunter2
|
46
|
+
```
|
47
|
+
|
48
|
+
Running `dotenv-init` will present you with a prompt interactively walking you through filling these values in, providing defaults when they're given:
|
49
|
+
|
50
|
+
```
|
51
|
+
Facebook credentials can be found in the 1Password Vault.
|
52
|
+
Create a test app specifically for your local copy of this
|
53
|
+
app and then grab its app ID.
|
54
|
+
FACEBOOK_APP_ID: 110318327925842
|
55
|
+
|
56
|
+
This is the password used as a backdoor to the admin
|
57
|
+
console in the event the client locks themselves out (again).
|
58
|
+
Regenerate with `rake secret`, or just use the default in development:
|
59
|
+
ADMIN_PASSWORD: (hunter2) hunter3
|
60
|
+
```
|
61
|
+
|
62
|
+
Providing all of the values will populate `.env` with the exact same formatting as your `.env.example`, including comments and whitespace.
|
63
|
+
|
64
|
+
## Contributing
|
65
|
+
|
66
|
+
1. Fork this repo
|
67
|
+
2. Add your feature in a branch
|
68
|
+
3. Open a pull request
|
69
|
+
|
70
|
+
Before making a commit, please run `rake spec` and `rubocop` to ensure it will pass CI.
|
71
|
+
|
72
|
+
Please write [good commit messages](https://robots.thoughtbot.com/5-useful-tips-for-a-better-commit-message), be polite, and be open to discussing ways to improve on the code you've contributed.
|
73
|
+
|
74
|
+
## Architecture
|
75
|
+
|
76
|
+
For details on how the parser works, check out [dotenv's parser](https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb) as well as [comment_aware_parser_spec.rb](spec/dotenv/init/comment_aware_parser_spec.rb). This project's parser simply subclasses dotenv's parser to add more functionality.
|
77
|
+
|
78
|
+
## Contributing
|
79
|
+
|
80
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/dotenv-assigner.
|
81
|
+
|
82
|
+
## License
|
83
|
+
|
84
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dotenv/assigner"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/dotenv-init
ADDED
data/bin/rspec
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'rspec' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("rspec-core", "rspec")
|
data/bin/setup
ADDED
data/circle.yml
ADDED
data/dotenv-init.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "dotenv/init/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dotenv-init"
|
8
|
+
spec.version = Dotenv::Init::VERSION
|
9
|
+
spec.authors = ["Steven Petryk"]
|
10
|
+
spec.email = ["me@stevenpetryk.com"]
|
11
|
+
|
12
|
+
spec.summary = "Sick of copying from .env.example files? Me too."
|
13
|
+
spec.homepage = "https://github.com/stevenpetryk/dotenv-init"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = ["dotenv-init"]
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "dotenv", "~> 2.1.1"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
26
|
+
spec.add_development_dependency "rubocop", "~> 0.40.0"
|
27
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
28
|
+
spec.add_development_dependency "rspec_junit_formatter", "0.2.2"
|
29
|
+
end
|
data/lib/dotenv/init.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
require "dotenv/init/comment_aware_parser"
|
2
|
+
|
3
|
+
module Dotenv
|
4
|
+
module Init
|
5
|
+
class Assigner
|
6
|
+
attr_reader :string, :env, :lines
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def call(string, env)
|
10
|
+
new(string, env).call
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize(string, env)
|
15
|
+
@string = string
|
16
|
+
@lines = string.split(/[\n\r]/)
|
17
|
+
@env = env
|
18
|
+
end
|
19
|
+
|
20
|
+
def call
|
21
|
+
parsed.each do |key, value|
|
22
|
+
line_number, offset, default = value.values_at(:line_number, :offset, :default)
|
23
|
+
|
24
|
+
replacement = lines[line_number]
|
25
|
+
replacement[range(offset)] = env[key] || default
|
26
|
+
|
27
|
+
lines[line_number] = replacement
|
28
|
+
end
|
29
|
+
|
30
|
+
lines.join("\n") + "\n"
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def range(offset)
|
36
|
+
offset[0]..(offset[1] - 1)
|
37
|
+
end
|
38
|
+
|
39
|
+
def parsed
|
40
|
+
@parsed ||= CommentAwareParser.call(@string)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "pry"
|
2
|
+
|
3
|
+
module Dotenv
|
4
|
+
module Init
|
5
|
+
class CLI
|
6
|
+
class << self
|
7
|
+
def start
|
8
|
+
@file = File.open(".env.example")
|
9
|
+
@contents = @file.read
|
10
|
+
|
11
|
+
env = {}
|
12
|
+
|
13
|
+
parsed.each do |key, value|
|
14
|
+
print prompt(key, value)
|
15
|
+
|
16
|
+
value = $stdin.gets.chomp
|
17
|
+
env[key] = value.empty? ? nil : value
|
18
|
+
puts
|
19
|
+
end
|
20
|
+
|
21
|
+
File.write(".env", Assigner.call(@contents, env))
|
22
|
+
end
|
23
|
+
|
24
|
+
def prompt(key, value)
|
25
|
+
<<~PROMPT.chomp
|
26
|
+
#{value[:comments]}
|
27
|
+
#{try_color(key, :yellow)}: #{default_value(value)}
|
28
|
+
PROMPT
|
29
|
+
end
|
30
|
+
|
31
|
+
def parsed
|
32
|
+
@parsed ||= CommentAwareParser.call(@contents)
|
33
|
+
end
|
34
|
+
|
35
|
+
def default_value(value)
|
36
|
+
try_color("(#{value[:default]}) ", :green) unless value[:default].empty?
|
37
|
+
end
|
38
|
+
|
39
|
+
def try_color(string, color)
|
40
|
+
require "colorize"
|
41
|
+
string.colorize(color)
|
42
|
+
rescue LoadError
|
43
|
+
string
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "dotenv/parser"
|
2
|
+
require "dotenv/substitutions/variable"
|
3
|
+
require "dotenv/substitutions/command" if RUBY_VERSION > "1.8.7"
|
4
|
+
|
5
|
+
module Dotenv
|
6
|
+
module Init
|
7
|
+
class CommentAwareParser < Dotenv::Parser
|
8
|
+
@substitutions =
|
9
|
+
[Dotenv::Substitutions::Variable, Dotenv::Substitutions::Command]
|
10
|
+
|
11
|
+
LINE = /
|
12
|
+
\A
|
13
|
+
(?: # optional variable setting
|
14
|
+
(?:export\s+)? # optional export
|
15
|
+
([\w\.]+) # key
|
16
|
+
(?:\s*(=)\s*|:\s+?) # separator
|
17
|
+
( # optional value
|
18
|
+
'(?:\'|[^'])*' # single quoted value
|
19
|
+
| # or
|
20
|
+
"(?:\"|[^"])*" # double quoted value
|
21
|
+
| # or
|
22
|
+
[^#\n\s]+ # unquoted value
|
23
|
+
)? #
|
24
|
+
)? #
|
25
|
+
(?:\s*\#\s*(.*))? # optional comment
|
26
|
+
\z
|
27
|
+
/x # '
|
28
|
+
|
29
|
+
COMMENT_OR_BLANK_LINE = /\A\s*(?:#.*)?\z/
|
30
|
+
|
31
|
+
def initialize(*args)
|
32
|
+
@line_number = 0
|
33
|
+
@comments = []
|
34
|
+
super
|
35
|
+
end
|
36
|
+
|
37
|
+
def call
|
38
|
+
@string.split(/[\n\r]/).each do |line|
|
39
|
+
parse_line(line)
|
40
|
+
@line_number += 1
|
41
|
+
end
|
42
|
+
@hash
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def parse_line(line)
|
48
|
+
if match = validate_line!(line)
|
49
|
+
key, _, value, comment = match.captures
|
50
|
+
@comments << comment
|
51
|
+
|
52
|
+
if key
|
53
|
+
@hash[key] = {
|
54
|
+
default: parse_value(value),
|
55
|
+
comments: flush_comments,
|
56
|
+
line_number: @line_number,
|
57
|
+
offset: offset_for(match, value),
|
58
|
+
}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def offset_for(match, value)
|
64
|
+
return [match.offset(2)[1]] * 2 unless value
|
65
|
+
|
66
|
+
offset = match.offset(3)
|
67
|
+
|
68
|
+
if value.start_with?("'", '"')
|
69
|
+
[offset[0] + 1, offset[1] - 1]
|
70
|
+
else
|
71
|
+
offset
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def validate_line!(line)
|
76
|
+
if match = line.match(LINE)
|
77
|
+
return match
|
78
|
+
elsif exports_nothing?(line)
|
79
|
+
raise FormatError, "Line #{line.inspect} has an unset variable"
|
80
|
+
elsif line !~ COMMENT_OR_BLANK_LINE
|
81
|
+
raise FormatError, "Line #{line.inspect} doesn't match format"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def parse_value(value)
|
86
|
+
super(value || "")
|
87
|
+
end
|
88
|
+
|
89
|
+
def flush_comments
|
90
|
+
comments = @comments
|
91
|
+
@comments = []
|
92
|
+
comments.compact.map(&:chomp).join(" ")
|
93
|
+
end
|
94
|
+
|
95
|
+
def exports_nothing?(line)
|
96
|
+
line.split.first == "export" && variable_not_set?(line)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dotenv-init
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Petryk
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dotenv
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.1.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.1.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.10.3
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.10.3
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.40.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.40.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec_junit_formatter
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.2.2
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.2.2
|
111
|
+
description:
|
112
|
+
email:
|
113
|
+
- me@stevenpetryk.com
|
114
|
+
executables:
|
115
|
+
- dotenv-init
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".rspec"
|
121
|
+
- ".rubocop.yml"
|
122
|
+
- Gemfile
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.md
|
125
|
+
- Rakefile
|
126
|
+
- bin/console
|
127
|
+
- bin/dotenv-init
|
128
|
+
- bin/rspec
|
129
|
+
- bin/setup
|
130
|
+
- circle.yml
|
131
|
+
- dotenv-init.gemspec
|
132
|
+
- lib/dotenv/init.rb
|
133
|
+
- lib/dotenv/init/assigner.rb
|
134
|
+
- lib/dotenv/init/cli.rb
|
135
|
+
- lib/dotenv/init/comment_aware_parser.rb
|
136
|
+
- lib/dotenv/init/version.rb
|
137
|
+
homepage: https://github.com/stevenpetryk/dotenv-init
|
138
|
+
licenses:
|
139
|
+
- MIT
|
140
|
+
metadata: {}
|
141
|
+
post_install_message:
|
142
|
+
rdoc_options: []
|
143
|
+
require_paths:
|
144
|
+
- lib
|
145
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - ">="
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
version: '0'
|
155
|
+
requirements: []
|
156
|
+
rubyforge_project:
|
157
|
+
rubygems_version: 2.6.4
|
158
|
+
signing_key:
|
159
|
+
specification_version: 4
|
160
|
+
summary: Sick of copying from .env.example files? Me too.
|
161
|
+
test_files: []
|