-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from gdotdesign/env
Support for different environments.
- Loading branch information
Showing
6 changed files
with
85 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"key": "value" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Elm.Native.Env = {}; | ||
Elm.Native.Env.make = function(elm) { | ||
elm.Native = elm.Native || {}; | ||
elm.Native.Env = elm.Native.Env || {}; | ||
if (elm.Native.Env.values) {return elm.Native.Env.values; } | ||
|
||
/* Gets a value from the ENV. */ | ||
function get(key){ | ||
return window.ENV && window.ENV[key] | ||
} | ||
|
||
/* Interface. */ | ||
return elm.Native.Env.values = { | ||
get: get | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
module Ui.Utils.Env where | ||
|
||
{-| Module for interacting with the environment variables. | ||
@docs get | ||
-} | ||
import Json.Decode as Json | ||
import Native.Env | ||
import Debug | ||
|
||
{-| Gets the value of the given environment variable with a decoder and a | ||
default value. -} | ||
get : String -> a -> Json.Decoder a -> a | ||
get key default decoder = | ||
let | ||
value = Native.Env.get key | ||
in | ||
case Json.decodeValue decoder value of | ||
Ok data -> data | ||
Err msg -> | ||
let | ||
log = | ||
Debug.log | ||
("Error getting ENV value '" ++ key ++ "'") | ||
msg | ||
in | ||
default |