env_compat 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48b6b2f664497b9bc21ab7262b68012252a8aa9d
4
- data.tar.gz: abab2b2f22800d4f1e5e07f0297bf16bcd8b13ed
3
+ metadata.gz: 122f8ca8d129b5e80ab418738aab64c716b88409
4
+ data.tar.gz: 5f13c4c6e0f6980617cdc1771365a93a2ba6e63c
5
5
  SHA512:
6
- metadata.gz: 74705b27246406f69d22ccb43c01849b2903225942845777293e6667d9b09ccea3e0c4538f0605aa0dc5542dcb442f2391928432d88736e34403d9cb441a38c6
7
- data.tar.gz: 4a83f5b98a9eb24c1cbcaf207385712aa1fb1978b91425b530f59efb8e24d5a6743217de933224b9521880e1cf2bdbd44c0afb5ad2083019dfcac480b0f731da
6
+ metadata.gz: baf554e871754b85379ae242e2ed30eccdbb28e57a5e3a3eaff21676a7238b5612a510191416ee1807446d751f32cbcc10c20838cd2168ea61628691b5b1ed19
7
+ data.tar.gz: 62680154a37b7531f6f334df8b3ff4f30d161e2644bc4087981b158df2c3434c58b2cc7d49605f791b457eb3a6d3b97280535dd2221d55a8bd878cd38d12c944
data/README.md CHANGED
@@ -20,7 +20,18 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
+ Three methods are provided `:auto`, `:encode`, and `:decode`. Provide a tag for
24
+ `:auto` and it will use that to determine whether or not to encode or decode. You
25
+ can see this example tag usage in the Bundler library.
26
+
23
27
  ```ruby
28
+
29
+ EnvCompat.auto :bundle, "https://github.com/company/private-repo.git"
30
+ # => "BUNDLE_HTTPS_CFF_GITHUB_D_COM_F_COMPANY_F_PRIVATE_M_REPO_D_GIT"
31
+
32
+ EnvCompat.auto :bundle, "BUNDLE_HTTPS_CFF_GITHUB_D_COM_F_COMPANY_F_PRIVATE_M_REPO_D_GIT"
33
+ # => "HTTPS://GITHUB.COM/COMPANY/PRIVATE-REPO.GIT"
34
+
24
35
  EnvCompat.encode "https://github.com/company/private-repo.git"
25
36
  # => "HTTPS_CFF_GITHUB_D_COM_F_COMPANY_F_PRIVATE_M_REPO_D_GIT"
26
37
 
@@ -28,8 +39,9 @@ EnvCompat.decode "HTTPS_CFF_GITHUB_D_COM_F_COMPANY_F_PRIVATE_M_REPO_D_GIT"
28
39
  # => HTTPS://GITHUB.COM/COMPANY/PRIVATE-REPO.GIT
29
40
  ```
30
41
 
31
- To define you own custom special character mappings feel free to overwrite
32
- the EnvCompat module instance method of `:mapping`.
42
+ To define your own custom special character mappings feel free to overwrite
43
+ the EnvCompat module instance method of `:mapping`. **NOTE:** When changing
44
+ mapping the underscore symbol must be mapped.
33
45
 
34
46
  ```ruby
35
47
  def EnvCompat.mapping
data/lib/env_compat.rb CHANGED
@@ -2,6 +2,14 @@ require "env_compat/version"
2
2
 
3
3
  module EnvCompat
4
4
  class << self
5
+ def auto tag, str
6
+ if str[/#{tag}_/i]
7
+ decode str[tag.length.+(1)..-1]
8
+ else
9
+ "#{tag.upcase}_#{encode str}"
10
+ end
11
+ end
12
+
5
13
  def encode str
6
14
  builder = ''
7
15
  _ = CodeBlock.new
@@ -1,3 +1,3 @@
1
1
  module EnvCompat
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: env_compat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel P. Clark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler