dotenv-android 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf9107a7eac6ffceeeaf4712d9e70915ad47c9d5577eb76be97360b97b85addd
4
- data.tar.gz: 5dfbc805c2c8331ad16a9d421767ab94401970629dbc768627f5634901365cd0
3
+ metadata.gz: 6368d3b979a5214b8ea3b57658927c3de927061f008362dc5c3c972a5c78cdd3
4
+ data.tar.gz: 7ad4465fe1cc946e764de3767732be14bb0c1b752262ce53f63f0bf977e0a733
5
5
  SHA512:
6
- metadata.gz: 20651196c68f0a337f54d62f4a694f8d6eb76db602073ed9b251eddc93b1dd556f4b2639b298cf0f10c869eef8d053eb388b7f4d20666dc10845fcf9d55054ae
7
- data.tar.gz: a360617fcb5d34ad1bb244a293b006bfe86dce259b8657cb20a872ee8451d78af1dcb6d8cc48d9690913a70ab62c0a977b1fb0200e88a1e43f524775d5b5c77a
6
+ metadata.gz: 913c186c562788989d83f35e3b82a5e8f37281fb39e52ee82b1fd126dcd095fb01484d838f20f0e170bae7fade39a2fe93a3f21aeda1253806f03031220bf6f1
7
+ data.tar.gz: dd9c513aa1a680b32b23eba862620f8d69d06382e255be13f6e024f9e0075c10f0812940e85c433c59beb0a8cc79337be27b28b2ad15ff813802d19f7bec798a
@@ -1,3 +1,8 @@
1
+ # [0.1.2] - 2020-03-25
2
+
3
+ ## Fixed
4
+ - Special characters at end of var ignored
5
+
1
6
  # [0.1.1] - 2019-11-30
2
7
 
3
8
  ## Fixed
data/README.md CHANGED
@@ -29,6 +29,14 @@ At first, Android Studio will complain that `Env.apiHost` cannot be found. Don't
29
29
  ```
30
30
  #!/bin/bash
31
31
 
32
+ # You may need to edit the PATH environment variable in order for dotenv-android to execute. It may not be found at first.
33
+ # After you run `gem install dotenv-android`, run `which dotenv-android` to find out where it is located.
34
+ # You may need to add the path to that executable to your script. Android Studio launches with it's own PATH
35
+ # that may differ from your system's PATH.
36
+ # To see what the PATH variable contains in Android Studio, uncomment the line below and perform a build to run this script:
37
+ # /usr/bin/env
38
+ export PATH="$PATH:~/.rbenv/shims/"
39
+
32
40
  dotenv-android --source app/src/main/java/com/example/myapplication/ --package PACKAGE_NAME
33
41
  ```
34
42
 
@@ -29,6 +29,7 @@ module DotEnvAndroid
29
29
  options.verbose = false
30
30
  options.debug = false
31
31
 
32
+ # rubocop:disable Metrics/BlockLength
32
33
  opt_parser = OptionParser.new do |opts|
33
34
  opts.banner = 'Usage: dotenv-android [options]'
34
35
 
@@ -47,7 +48,7 @@ module DotEnvAndroid
47
48
  options.verbose = true
48
49
  options.debug = true
49
50
  end
50
- opts.on('--package PACKAGE_NAME', 'Package name to add to the top of the generated Env.kt file (example: com.yourdomain.app, or PACKAGE_NAME environment variable found in .env)') do |package_name|
51
+ opts.on('--package PACKAGE_NAME', 'Package name to add to the top of the generated Env.kt file (example: com.yourdomain.app, or PACKAGE_NAME environment variable found in .env)') do |package_name| # rubocop:disable Metrics/LineLength
51
52
  options.package_name = package_name
52
53
  end
53
54
  opts.on('-o', '--out FILE', 'Output file (example: Path/Env.kt)') do |out|
@@ -58,6 +59,7 @@ module DotEnvAndroid
58
59
  exit
59
60
  end
60
61
  end
62
+ # rubocop:enable Metrics/BlockLength
61
63
 
62
64
  help = opt_parser.help
63
65
  abort(help) if ARGV.empty?
@@ -46,9 +46,12 @@ module DotEnvAndroid
46
46
  requests = []
47
47
 
48
48
  File.readlines(file).each do |line|
49
- line.split(' ').each do |word|
50
- # https://regexr.com/4pmp0
51
- next unless /Env\.[a-z]\w*/.match? word
49
+ # Regex matcher: https://regexr.com/4rf2s
50
+ matches = line.match(/Env\.[a-z]\w*/)
51
+ next if matches.nil?
52
+
53
+ matches.to_a.each do |word|
54
+ word = word.gsub('_', '') # \w in regex pattern above allows underscores. We want to remove those.
52
55
 
53
56
  requested_variable = word.split('.')[1]
54
57
  requested_variable = DotEnvAndroid::Util.to_snakecase(requested_variable).upcase
@@ -60,7 +63,7 @@ module DotEnvAndroid
60
63
  requests
61
64
  end
62
65
 
63
- def get_values(requests)
66
+ def get_values(requests)
64
67
  values = {}
65
68
 
66
69
  requests.each do |request|
@@ -73,25 +76,25 @@ module DotEnvAndroid
73
76
  values
74
77
  end
75
78
 
76
- def get_package_header
79
+ def package_header
77
80
  package_name_header = "package #{@options.package_name}"
78
81
 
79
- if !@options.package_name.include? "."
82
+ unless @options.package_name.include? '.'
80
83
  package_name = @all_env_vars[@options.package_name]
81
84
  @ui.fail("Cannot find package name in .env file with key, #{@options.package_name}") if package_name.nil?
82
85
  package_name_header = "package #{package_name}"
83
- end
86
+ end
84
87
 
85
88
  @ui.debug("Package name header: #{package_name_header}")
86
89
 
87
- return package_name_header
88
- end
90
+ package_name_header
91
+ end
89
92
 
90
93
  def generate_output(env_variables)
91
94
  @ui.verbose("Outputting environment variables to #{@options.out}")
92
95
 
93
- package_name_header = get_package_header
94
- file_contents = "#{package_name_header}\n\n"
96
+ package_name_header = package_header
97
+ file_contents = "#{package_name_header}\n\n"
95
98
  file_contents += "object Env {\n\n"
96
99
  env_variables.each do |key, value|
97
100
  file_contents += " val #{DotEnvAndroid::Util.snake_to_camel(key)} = \"#{value}\"\n"
@@ -3,7 +3,7 @@
3
3
  module DotEnvAndroid
4
4
  class Version
5
5
  def self.get
6
- '0.1.1'
6
+ '0.1.2'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Bostian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-30 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize
@@ -94,22 +94,22 @@ dependencies:
94
94
  name: rspec
95
95
  requirement: !ruby/object:Gem::Requirement
96
96
  requirements:
97
- - - "~>"
98
- - !ruby/object:Gem::Version
99
- version: '3.8'
100
97
  - - ">="
101
98
  - !ruby/object:Gem::Version
102
99
  version: 3.8.0
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '3.8'
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '3.8'
110
107
  - - ">="
111
108
  - !ruby/object:Gem::Version
112
109
  version: 3.8.0
110
+ - - "~>"
111
+ - !ruby/object:Gem::Version
112
+ version: '3.8'
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: rspec_junit_formatter
115
115
  requirement: !ruby/object:Gem::Requirement
@@ -169,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  - !ruby/object:Gem::Version
170
170
  version: '0'
171
171
  requirements: []
172
- rubyforge_project:
173
- rubygems_version: 2.7.7
172
+ rubygems_version: 3.0.6
174
173
  signing_key:
175
174
  specification_version: 4
176
175
  summary: Access environment variables at runtime of Android app