heroku-env 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7b36ac2535c255cbde68f7d3748f7eb90bd99440
4
+ data.tar.gz: ba93cb44537b0ab9498e5a9b78b81add53e88c43
5
+ SHA512:
6
+ metadata.gz: 2bd0101624c4d2a1a210b4a9ce25726e0d40320a5188fa520be388890de585477f347aa0f58db06bc8d5bf0f6a83247b6a0f7d62080ce1e5c3002d1afac2f2b5
7
+ data.tar.gz: ddc464c2e1a7f32675bf14ed265a03aed10b6c769594ebbb9261eef5e3d69698be90e339ac8ca734e2b3c048ed4ba7e4729f81f666ec41f870b622a6e2765c10
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ /pkg
2
+ *.gem
3
+ Thumbs.db
4
+ .DS_Store
5
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ heroku-env (0.0.2)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ rake (10.4.2)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ heroku-env!
16
+ rake (= 10.4.2)
data/README.md ADDED
@@ -0,0 +1,77 @@
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 ADDED
@@ -0,0 +1,3 @@
1
+ require "rubygems"
2
+ require "bundler"
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,20 @@
1
+ require File.expand_path("../lib/heroku-env/version", __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "heroku-env"
5
+ s.version = HerokuEnv::VERSION
6
+ s.platform = Gem::Platform::RUBY
7
+ s.authors = ["Stefan Sundin"]
8
+ s.email = ["stefan@stefansundin.com"]
9
+ s.homepage = "https://github.com/stefansundin/heroku-env"
10
+ s.summary = "Don't worry about the environment."
11
+ s.description = "This gem automatically promotes Heroku addons' environment settings."
12
+
13
+ s.required_rubygems_version = ">= 1.3.6"
14
+
15
+ s.add_development_dependency "rake", "10.4.2"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.executables = `git ls-files`.split("\n").map{|f| f =~ /^bin\/(.*)/ ? $1 : nil}.compact
19
+ s.require_path = 'lib'
20
+ end
data/lib/heroku-env.rb ADDED
@@ -0,0 +1,19 @@
1
+ module HerokuEnv
2
+ module_function
3
+ def run
4
+ # Redis
5
+ ENV["REDIS_URL"] ||= ENV["REDISCLOUD_URL"] || ENV["REDISTOGO_URL"]
6
+
7
+ # SMTP
8
+ ENV["MANDRILL_SMTP_SERVER"] ||= "smtp.mandrillapp.com" if ENV["MANDRILL_USERNAME"]
9
+ ENV["SENDGRID_SMTP_SERVER"] ||= "smtp.sendgrid.net" if ENV["SENDGRID_USERNAME"]
10
+
11
+ ENV["SMTP_HOST"] ||= ENV["MANDRILL_SMTP_SERVER"] || ENV["SENDGRID_SMTP_SERVER"] || ENV["MAILGUN_SMTP_SERVER"] || ENV["POSTMARK_SMTP_SERVER"]
12
+ ENV["SMTP_PORT"] ||= ENV["MAILGUN_SMTP_PORT"] || "587"
13
+ ENV["SMTP_USERNAME"] ||= ENV["MANDRILL_USERNAME"] || ENV["SENDGRID_USERNAME"] || ENV["MAILGUN_SMTP_LOGIN"] || ENV["POSTMARK_API_KEY"]
14
+ ENV["SMTP_PASSWORD"] ||= ENV["MANDRILL_APIKEY"] || ENV["SENDGRID_PASSWORD"] || ENV["MAILGUN_SMTP_PASSWORD"] || ENV["POSTMARK_API_KEY"]
15
+
16
+ # If you use Postmark, you need to configure MAIL_FROM manually
17
+ ENV["MAIL_FROM"] ||= ENV["MANDRILL_USERNAME"] || ENV["SENDGRID_USERNAME"] || ENV["MAILGUN_SMTP_LOGIN"]
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module HerokuEnv
2
+ VERSION = "0.0.2"
3
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: heroku-env
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Stefan Sundin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-03-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 10.4.2
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 10.4.2
27
+ description: This gem automatically promotes Heroku addons' environment settings.
28
+ email:
29
+ - stefan@stefansundin.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - Gemfile
36
+ - Gemfile.lock
37
+ - README.md
38
+ - Rakefile
39
+ - heroku-env.gemspec
40
+ - lib/heroku-env.rb
41
+ - lib/heroku-env/version.rb
42
+ homepage: https://github.com/stefansundin/heroku-env
43
+ licenses: []
44
+ metadata: {}
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: 1.3.6
59
+ requirements: []
60
+ rubyforge_project:
61
+ rubygems_version: 2.2.2
62
+ signing_key:
63
+ specification_version: 4
64
+ summary: Don't worry about the environment.
65
+ test_files: []