dotenv-ios 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 +22 -3
- data/lib/dotenv-ios/generator.rb +6 -3
- data/lib/dotenv-ios/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: 9092e00a68fd903a04d60a3f4b779981aa5ea2d8790b769fb3eb44aba9980ef9
|
4
|
+
data.tar.gz: f5169bd131725c2af3be918ba10e5fc477d5eebbf82d42d687329d68e74afda5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c0e41544d932fc28ac91c25963ee030035ca0921b378ae6cc52158da1a4a5fa17171c450128ac51f4b7d87f5488284ae45f3554233c8f9ba001e353fda6dc14
|
7
|
+
data.tar.gz: ae311a6359e6f19422bb3196aa2eabed4e25bd5bc29915d427b7923474429b6ff7b9853d4b0988c180e5a8fb5d3d6a6393d4ddf50a671d348090c286cae1f57a
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -24,11 +24,30 @@ let apiHost: String = Env.apiHost
|
|
24
24
|
|
25
25
|
At first, XCode will complain that `Env.apiHost` cannot be found. Don't worry. We will be fixing that. `dotenv-ios` CLI crawls your source code looking for `Env.X` requests and generating a `Env.swift` file for you! Anytime you want to use environmental variables, you just need to add it to your source. Super easy.
|
26
26
|
|
27
|
-
* Create a new Build Phase in XCode to run this command.
|
27
|
+
* Create a new Build Phase in XCode to run this command. Reorder the new Build Phase to be first to run. That way this tool can generate the environment variables before XCode tries to compile your app's source code.
|
28
28
|
|
29
|
-
|
29
|
+
First, create a bash script in your project (for example purposes here, we created a script named, `dot_env_ios.rb` in the root of the project. It's important to put it there so dotenv-ios can find the `.env` file in the root):
|
30
30
|
|
31
|
-
|
31
|
+
```ruby
|
32
|
+
#!/usr/bin/env ruby
|
33
|
+
|
34
|
+
require 'dotenv'
|
35
|
+
Dotenv.load('.env')
|
36
|
+
|
37
|
+
`bundle exec dotenv-ios --source #{ENV["SOURCE_CODE_DIRECTORY"]}`
|
38
|
+
```
|
39
|
+
|
40
|
+
You will notice above that I am also using the `dotenv` ruby gem to make life even easier storing a variable `SOURCE_CODE_DIRECTORY` in `.env` I can use in this script.
|
41
|
+
|
42
|
+
Now, back to XCode build scripts. Leave the shell as the default, `/bin/sh` and have the script in XCode simply execute your bash script you just made:
|
43
|
+
|
44
|
+
```
|
45
|
+
./dot_env_ios.rb
|
46
|
+
```
|
47
|
+
|
48
|
+
Done!
|
49
|
+
|
50
|
+
*Note: It's highly recommended you checkout [this quick doc](https://gist.github.com/levibostian/aac45628ff00f677888824d651cc7724) on how to run ruby scripts within XCode as you may encounter issues along the way.*
|
32
51
|
|
33
52
|
* Run a build in XCode (Cmd + B) to run the `dotenv-ios` CLI tool.
|
34
53
|
|
data/lib/dotenv-ios/generator.rb
CHANGED
@@ -44,9 +44,12 @@ module DotEnviOS
|
|
44
44
|
requests = []
|
45
45
|
|
46
46
|
File.readlines(file).each do |line|
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
# Regex matcher: https://regexr.com/4rf2s
|
48
|
+
matches = line.match(/Env\.[a-z]\w*/)
|
49
|
+
next if matches.nil?
|
50
|
+
|
51
|
+
matches.to_a.each do |word|
|
52
|
+
word = word.gsub('_', '') # \w in regex pattern above allows underscores. We want to remove those.
|
50
53
|
|
51
54
|
requested_variable = word.split('.')[1]
|
52
55
|
requested_variable = DotEnviOS::Util.to_snakecase(requested_variable).upcase
|
data/lib/dotenv-ios/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dotenv-ios
|
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: 2019-
|
11
|
+
date: 2019-12-30 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 iOS app
|