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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -0
- data/lib/dotenv-android/cli.rb +3 -1
- data/lib/dotenv-android/generator.rb +14 -11
- data/lib/dotenv-android/version.rb +1 -1
- metadata +9 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6368d3b979a5214b8ea3b57658927c3de927061f008362dc5c3c972a5c78cdd3
|
4
|
+
data.tar.gz: 7ad4465fe1cc946e764de3767732be14bb0c1b752262ce53f63f0bf977e0a733
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 913c186c562788989d83f35e3b82a5e8f37281fb39e52ee82b1fd126dcd095fb01484d838f20f0e170bae7fade39a2fe93a3f21aeda1253806f03031220bf6f1
|
7
|
+
data.tar.gz: dd9c513aa1a680b32b23eba862620f8d69d06382e255be13f6e024f9e0075c10f0812940e85c433c59beb0a8cc79337be27b28b2ad15ff813802d19f7bec798a
|
data/CHANGELOG.md
CHANGED
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
|
|
data/lib/dotenv-android/cli.rb
CHANGED
@@ -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
|
-
|
50
|
-
|
51
|
-
|
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
|
79
|
+
def package_header
|
77
80
|
package_name_header = "package #{@options.package_name}"
|
78
81
|
|
79
|
-
|
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
|
-
|
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 =
|
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"
|
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.
|
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:
|
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
|
-
|
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
|