egg 0.5.0 → 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d75e3a224f4e96b79ba91e6e62b43b46efed0f15
4
- data.tar.gz: 835698e87464bf1fe70cbcdb3bfa910c7c4c1054
3
+ metadata.gz: 1d58b8dead4880b093bab77fd6778a5bf9c7a65e
4
+ data.tar.gz: 3d7eaca180c80110f3d5a072731153c38142a81f
5
5
  SHA512:
6
- metadata.gz: ed225dc0cc7953ab54988a3d337147d9f9e6bdac9a24a589b749f81d223fb512dc68a2fc52a8292c2d973bbaad21041611e284ec1fa8dc1fddac18a4df36b7e2
7
- data.tar.gz: fab3916a82f6eff8524a9c4c9f7de4ade7c1a32c922ef070e7a4726c2fc1dbff1cf8bfe89919fd7f196a38c5dd34068d7f3c557427a5f2af09ea0752f71ebf74
6
+ metadata.gz: e1c47ba956d668acddfdc3455627f543e06227277fb9f60172f8b52e2e7473515bf4b48ac0fa5ebceda7905f62d2367c750db806e4a5a679bd40398a24223afc
7
+ data.tar.gz: 266a52d7302d056563fe2156d3d9e89a2706ffebbc361d8521a5c340f61934ad2363541aa032a6df4b00aae75f0b13af529ec80af3c55e7deda044c6fa9751b4
@@ -2,6 +2,26 @@
2
2
 
3
3
  # Provides Generic support for manipulating Dotenv files
4
4
  class DotenvUtil
5
+
6
+ # Retrieved from https://github.com/bkeepers/dotenv/blob/master/lib/dotenv/parser.rb
7
+ LINE = /
8
+ \A
9
+ \s*
10
+ (?:export\s+)? # optional export
11
+ ([\w\.]+) # key
12
+ (?:\s*=\s*|:\s+?) # separator
13
+ ( # optional value begin
14
+ '(?:\'|[^'])*' # single quoted value
15
+ | # or
16
+ "(?:\"|[^"])*" # double quoted value
17
+ | # or
18
+ [^#\n]+ # unquoted value
19
+ )? # value end
20
+ \s*
21
+ (?:\#.*)? # optional comment
22
+ \z
23
+ /x
24
+
5
25
  attr_reader :env_text, :env
6
26
  def initialize(env_file)
7
27
  @env_text = env_file
@@ -14,7 +34,8 @@ class DotenvUtil
14
34
 
15
35
  def generate_env
16
36
  env.collect do |key, val|
17
- %(#{key}="#{val}")
37
+ val = %("#{val}") if val =~ /\s/
38
+ "#{key}=#{val}"
18
39
  end.join("\n")
19
40
  end
20
41
 
@@ -22,7 +43,7 @@ class DotenvUtil
22
43
 
23
44
  def parse_env_file
24
45
  env_text.split.each_with_object({}) do |line, hash|
25
- match = line.match(/^([A-Z_]+)="?(.+)?"?$/)
46
+ match = line.match(LINE)
26
47
  next unless match
27
48
  hash.store(*match.captures)
28
49
  hash
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Egg
4
- VERSION = "0.5.0".freeze
4
+ VERSION = "0.5.1".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Thuringer
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-09-11 00:00:00.000000000 Z
12
+ date: 2017-09-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor