heroku-env 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/heroku-env.gemspec +2 -2
- data/lib/heroku-env.rb +25 -0
- data/lib/heroku-env/version.rb +1 -1
- metadata +3 -5
- data/.gitignore +0 -5
- data/README.md +0 -77
- data/Rakefile +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa122904c9efffa4a6203563cf19f7adeab9f122
|
4
|
+
data.tar.gz: 82b3a4658cc13ed5c22d226b3a443f25b60c9f7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9feea723fe84a1ecd9eebe34307cbfc7191a3a6e50477a468470a1b839ec163aff134bd2fe50b136c45d836c0ff35afe7ffcf34326a1c4957b2fdb904b1d40dd
|
7
|
+
data.tar.gz: 50e76f22d0cf3c9b1551b9c0637c14a488c9c36d9eea2147de600296d14392ba297d2fa7675d4434e43c4cfd9833407642459582191ab5128a222841b9531cd1
|
data/Gemfile.lock
CHANGED
data/heroku-env.gemspec
CHANGED
@@ -8,13 +8,13 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.email = ["stefan@stefansundin.com"]
|
9
9
|
s.homepage = "https://github.com/stefansundin/heroku-env"
|
10
10
|
s.summary = "Don't worry about the environment."
|
11
|
-
s.description = "This gem automatically promotes Heroku addons' environment settings."
|
11
|
+
s.description = "This gem automatically promotes Heroku addons' environment settings. See the GitHub page for usage."
|
12
12
|
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
|
15
15
|
s.add_development_dependency "rake", "10.4.2"
|
16
16
|
|
17
|
-
s.files = `git ls-files`.split("\n")
|
17
|
+
s.files = `git ls-files`.split("\n") - %w(.gitignore README.md Rakefile)
|
18
18
|
s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
|
19
19
|
s.require_path = 'lib'
|
20
20
|
end
|
data/lib/heroku-env.rb
CHANGED
@@ -4,6 +4,23 @@ module HerokuEnv
|
|
4
4
|
# Redis
|
5
5
|
ENV["REDIS_URL"] ||= ENV["REDISCLOUD_URL"] || ENV["REDISTOGO_URL"]
|
6
6
|
|
7
|
+
# Memcache
|
8
|
+
ENV["MEMCACHE_SERVERS"] ||= ENV["MEMCACHIER_SERVERS"] || ENV["MEMCACHEDCLOUD_SERVERS"]
|
9
|
+
ENV["MEMCACHE_USERNAME"] ||= ENV["MEMCACHIER_USERNAME"] || ENV["MEMCACHEDCLOUD_USERNAME"]
|
10
|
+
ENV["MEMCACHE_PASSWORD"] ||= ENV["MEMCACHIER_PASSWORD"] || ENV["MEMCACHEDCLOUD_PASSWORD"]
|
11
|
+
|
12
|
+
# Mongo
|
13
|
+
ENV["MONGO_URL"] ||= ENV["MONGOLAB_URI"] || ENV["MONGOSOUP_URL"]
|
14
|
+
|
15
|
+
# MySQL
|
16
|
+
ENV["MYSQL_URL"] ||= ENV["CLEARDB_DATABASE_URL"]
|
17
|
+
|
18
|
+
# Neo4j
|
19
|
+
ENV["NEO4J_URL"] ||= ENV["GRAPHSTORY_URL"] || ENV["GRAPHENEDB_URL"]
|
20
|
+
|
21
|
+
# Elasticsearch
|
22
|
+
ENV["ELASTICSEARCH_URL"] ||= ENV["BONSAI_URL"] || ENV["SEARCHBOX_SSL_URL"]
|
23
|
+
|
7
24
|
# SMTP
|
8
25
|
ENV["MANDRILL_SMTP_SERVER"] ||= "smtp.mandrillapp.com" if ENV["MANDRILL_USERNAME"]
|
9
26
|
ENV["SENDGRID_SMTP_SERVER"] ||= "smtp.sendgrid.net" if ENV["SENDGRID_USERNAME"]
|
@@ -15,5 +32,13 @@ module HerokuEnv
|
|
15
32
|
|
16
33
|
# If you use Postmark, you need to configure MAIL_FROM manually
|
17
34
|
ENV["MAIL_FROM"] ||= ENV["MANDRILL_USERNAME"] || ENV["SENDGRID_USERNAME"] || ENV["MAILGUN_SMTP_LOGIN"]
|
35
|
+
|
36
|
+
# Airbrake
|
37
|
+
ENV["RAYGUN_HOST"] ||= "api.raygun.io" if ENV["RAYGUN_APIKEY"]
|
38
|
+
ENV["ROLLBAR_HOST"] ||= "api.rollbar.com" if ENV["ROLLBAR_ACCESS_TOKEN"]
|
39
|
+
ENV["APPENLIGHT_HOST"] ||= "api.appenlight.com" if ENV["APPENLIGHT_APIKEY"]
|
40
|
+
|
41
|
+
ENV["AIRBRAKE_HOST"] ||= ENV["RAYGUN_HOST"] || ENV["ROLLBAR_HOST"] || ENV["APPENLIGHT_HOST"]
|
42
|
+
ENV["AIRBRAKE_KEY"] ||= ENV["RAYGUN_APIKEY"] || ENV["ROLLBAR_ACCESS_TOKEN"] || ENV["APPENLIGHT_APIKEY"]
|
18
43
|
end
|
19
44
|
end
|
data/lib/heroku-env/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-env
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefan Sundin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -25,17 +25,15 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 10.4.2
|
27
27
|
description: This gem automatically promotes Heroku addons' environment settings.
|
28
|
+
See the GitHub page for usage.
|
28
29
|
email:
|
29
30
|
- stefan@stefansundin.com
|
30
31
|
executables: []
|
31
32
|
extensions: []
|
32
33
|
extra_rdoc_files: []
|
33
34
|
files:
|
34
|
-
- ".gitignore"
|
35
35
|
- Gemfile
|
36
36
|
- Gemfile.lock
|
37
|
-
- README.md
|
38
|
-
- Rakefile
|
39
37
|
- heroku-env.gemspec
|
40
38
|
- lib/heroku-env.rb
|
41
39
|
- lib/heroku-env/version.rb
|
data/README.md
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
# heroku-env
|
2
|
-
|
3
|
-
> Don't worry about the environment.
|
4
|
-
|
5
|
-
This simple gem makes it easier for you to use different Heroku addons in a plug-and-play fashion. Normally, if you decide to add a Redis provider, you have to customize your code to use that addon's environment variables. The problem with this, however, is that if you want to switch provider, you have to update your code.
|
6
|
-
|
7
|
-
What I usually ended up doing was:
|
8
|
-
|
9
|
-
```ruby
|
10
|
-
ENV["REDIS_URL"] ||= ENV["REDISCLOUD_URL"] || ENV["REDISTOGO_URL"]
|
11
|
-
$redis = Redis.new
|
12
|
-
```
|
13
|
-
|
14
|
-
Doing this in every project started to become a little annoying, so I decided to make a gem. The goal is to handle all kinds of addons, but for now it only handles Redis and SMTP. Suggest more types by filing an issue.
|
15
|
-
|
16
|
-
I only add addons that I can test myself, so this gem will only support addons with a free plan. The order that the addons are selected depends on how stable and easy I perceive them to be. So if you are deciding what provider you want to use, a good choice if probably the first one on the lists of supported addons I list below.
|
17
|
-
|
18
|
-
The gem uses `||=` in all the assignments, so you can easily override any variable by manually setting it.
|
19
|
-
|
20
|
-
|
21
|
-
## Installing
|
22
|
-
|
23
|
-
Add to your Gemfile:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
gem "heroku-env"
|
27
|
-
```
|
28
|
-
|
29
|
-
Then run:
|
30
|
-
|
31
|
-
```ruby
|
32
|
-
HerokuEnv.run
|
33
|
-
```
|
34
|
-
|
35
|
-
|
36
|
-
### Redis
|
37
|
-
|
38
|
-
Supports [Redis Cloud](https://addons.heroku.com/rediscloud) and [Redis To Go](https://addons.heroku.com/redistogo).
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
$redis = Redis.new
|
42
|
-
```
|
43
|
-
|
44
|
-
|
45
|
-
### SMTP
|
46
|
-
|
47
|
-
Supports [Mandrill](https://addons.heroku.com/mandrill), [SendGrid](https://addons.heroku.com/sendgrid), [Mailgun](https://addons.heroku.com/mailgun) and [Postmark](https://addons.heroku.com/postmark).
|
48
|
-
|
49
|
-
```ruby
|
50
|
-
Mail.defaults do
|
51
|
-
delivery_method :smtp,
|
52
|
-
address: ENV["SMTP_HOST"],
|
53
|
-
port: ENV["SMTP_PORT"],
|
54
|
-
user_name: ENV["SMTP_USERNAME"],
|
55
|
-
password: ENV["SMTP_PASSWORD"],
|
56
|
-
authentication: "plain",
|
57
|
-
enable_starttls_auto: true
|
58
|
-
end
|
59
|
-
```
|
60
|
-
|
61
|
-
Then send an email with:
|
62
|
-
|
63
|
-
```ruby
|
64
|
-
Mail.deliver do
|
65
|
-
from "Sender <#{ENV["MAIL_FROM"]}>"
|
66
|
-
to "receiver@example.com"
|
67
|
-
subject "Test email"
|
68
|
-
body "Just testing heroku-env"
|
69
|
-
end
|
70
|
-
```
|
71
|
-
|
72
|
-
If you use Postmark, you have to manually set `MAIL_FROM`.
|
73
|
-
|
74
|
-
|
75
|
-
## Misc notes
|
76
|
-
|
77
|
-
- Postmark sends you some unwanted emails if you add the addon.
|
data/Rakefile
DELETED