dotenv-android 0.1.2 → 0.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: 6368d3b979a5214b8ea3b57658927c3de927061f008362dc5c3c972a5c78cdd3
4
- data.tar.gz: 7ad4465fe1cc946e764de3767732be14bb0c1b752262ce53f63f0bf977e0a733
3
+ metadata.gz: 9d22e91e44e04625949928ec8e9a0c55612faeca178a4d9cd5461b7fbc7ff0db
4
+ data.tar.gz: 7a73cba66ce0b45c73b400e9d382fb908893c2abff44ca1bd74840b53e18aae3
5
5
  SHA512:
6
- metadata.gz: 913c186c562788989d83f35e3b82a5e8f37281fb39e52ee82b1fd126dcd095fb01484d838f20f0e170bae7fade39a2fe93a3f21aeda1253806f03031220bf6f1
7
- data.tar.gz: dd9c513aa1a680b32b23eba862620f8d69d06382e255be13f6e024f9e0075c10f0812940e85c433c59beb0a8cc79337be27b28b2ad15ff813802d19f7bec798a
6
+ metadata.gz: 205123bb2fe02d01e6de518d64200a3c8478f92039d3086368ac4f5666c7b16e1980b61ff4b2bcaeb082a2a185928432628c4f230f93a4e3979788c54624f815
7
+ data.tar.gz: 58ec434f9e4069be26933fb7a7f5d9ecf2fe15a46c1366b3ab01324e792c70ad4400992ef81df1e0a652e08940561822a55fd8d77be10c90fe99880fba622978
@@ -1,3 +1,9 @@
1
+ # [0.2.0] - 2020-03-26
2
+
3
+ ## Changed
4
+ - Allow package name to exist in the .env file instead of CLI param
5
+ - Show warning message instead of abort when a value is not found in .env file.
6
+
1
7
  # [0.1.2] - 2020-03-25
2
8
 
3
9
  ## Fixed
data/README.md CHANGED
@@ -40,6 +40,8 @@ export PATH="$PATH:~/.rbenv/shims/"
40
40
  dotenv-android --source app/src/main/java/com/example/myapplication/ --package PACKAGE_NAME
41
41
  ```
42
42
 
43
+ > Tip: You can put the package name in your `.env` file with key `PACKAGE_NAME` as well instead of as a CLI option.
44
+
43
45
  In your `app/build.gradle` file, add the following to the bottom of the file:
44
46
  ```
45
47
  task generateEnv(type:Exec) {
@@ -25,6 +25,8 @@ module DotEnvAndroid
25
25
  end
26
26
 
27
27
  def parse_options
28
+ Dotenv.load('.env')
29
+
28
30
  options = Options.new
29
31
  options.verbose = false
30
32
  options.debug = false
@@ -48,7 +50,7 @@ module DotEnvAndroid
48
50
  options.verbose = true
49
51
  options.debug = true
50
52
  end
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
53
+ opts.on('--package', '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
52
54
  options.package_name = package_name
53
55
  end
54
56
  opts.on('-o', '--out FILE', 'Output file (example: Path/Env.kt)') do |out|
@@ -66,13 +68,18 @@ module DotEnvAndroid
66
68
 
67
69
  opt_parser.parse!(ARGV)
68
70
 
71
+ if options.package_name.nil?
72
+ options.package_name = ENV["PACKAGE_NAME"]
73
+
74
+ @ui.fail("Cannot find package name in .env file with key, PACKAGE_NAME, or as a CLI argument") if options.package_name.nil?
75
+ end
76
+
69
77
  options
70
78
  end
71
79
 
72
80
  def assert_options
73
81
  prefix = '[ERROR]'
74
82
  @ui.fail("#{prefix} --source required") unless @options.source
75
- @ui.fail("#{prefix} --package required") unless @options.package_name
76
83
  end
77
84
  end
78
85
  end
@@ -15,7 +15,7 @@ module DotEnvAndroid
15
15
 
16
16
  @ui = DotEnvAndroid::UI.new(@options.verbose, @options.debug)
17
17
 
18
- @all_env_vars = Dotenv.parse('.env')
18
+ Dotenv.load('.env')
19
19
  end
20
20
 
21
21
  def start
@@ -67,9 +67,9 @@ module DotEnvAndroid
67
67
  values = {}
68
68
 
69
69
  requests.each do |request|
70
- @ui.fail("Environment variable #{request} not found in .env") unless @all_env_vars[request]
70
+ @ui.warning("Environment variable #{request} not found in .env") unless ENV[request]
71
71
 
72
- values[request] = @all_env_vars[request]
72
+ values[request] = ENV[request]
73
73
  end
74
74
 
75
75
  @ui.debug("Values: #{values}")
@@ -77,17 +77,7 @@ module DotEnvAndroid
77
77
  end
78
78
 
79
79
  def package_header
80
- package_name_header = "package #{@options.package_name}"
81
-
82
- unless @options.package_name.include? '.'
83
- package_name = @all_env_vars[@options.package_name]
84
- @ui.fail("Cannot find package name in .env file with key, #{@options.package_name}") if package_name.nil?
85
- package_name_header = "package #{package_name}"
86
- end
87
-
88
- @ui.debug("Package name header: #{package_name_header}")
89
-
90
- package_name_header
80
+ return "package #{@options.package_name}"
91
81
  end
92
82
 
93
83
  def generate_output(env_variables)
@@ -3,7 +3,7 @@
3
3
  module DotEnvAndroid
4
4
  class Version
5
5
  def self.get
6
- '0.1.2'
6
+ '0.2.0'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotenv-android
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Bostian