heroku-domainr 0.1.0
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.
- data/GEMFILE +10 -0
- data/MIT.LICENSE +20 -0
- data/README.md +47 -0
- data/lib/heroku/plugins/domainr/config.rb +26 -0
- data/lib/heroku/plugins/domainr/version.rb +7 -0
- data/lib/heroku/plugins/heroku_domainr.rb +41 -0
- data/spec/config_spec.rb +43 -0
- data/spec/heroku_domainr_spec.rb +37 -0
- metadata +85 -0
data/GEMFILE
ADDED
data/MIT.LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Marcin Naglik
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Heroku Domainr
|
2
|
+
==============
|
3
|
+
|
4
|
+
Simple Heroku plugin for managing heroku domains.
|
5
|
+
|
6
|
+
This gem adds functionality to add/remove/clear Heroku domains from within the Heroku application.
|
7
|
+
|
8
|
+
##Setup
|
9
|
+
|
10
|
+
In order for the management of the Heroku domains the plugin needs to know your Heroku app credentials. By default they're read from the following env variables:
|
11
|
+
|
12
|
+
- HEROKU_APP
|
13
|
+
- HEROKU_USER
|
14
|
+
- HEROKU_PASS
|
15
|
+
|
16
|
+
You can also setup it using the following initializer:
|
17
|
+
|
18
|
+
require 'heroku/plugins/heroku_domainr'
|
19
|
+
|
20
|
+
Heroku::Plugins::Domainr.config do |c|
|
21
|
+
c.heroku_user = 'heroku user'
|
22
|
+
c.heroku_pass = 'heroku password'
|
23
|
+
c.heroku_app = 'heroku app'
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
##Usage
|
28
|
+
|
29
|
+
Using the heroku-domainr plugin:
|
30
|
+
|
31
|
+
require 'heroku/plugins/heroku_domainr'
|
32
|
+
|
33
|
+
class SampleRailsClass
|
34
|
+
include Heroku::Plugins::Domainr
|
35
|
+
|
36
|
+
def perform_add_domain
|
37
|
+
domains_add("my-domain.com")
|
38
|
+
end
|
39
|
+
|
40
|
+
def perform_remove_domain
|
41
|
+
domains_remove("my-domain.com")
|
42
|
+
end
|
43
|
+
|
44
|
+
def perform_clear_domain
|
45
|
+
domains_clear
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Heroku
|
2
|
+
module Plugins
|
3
|
+
module Domainr
|
4
|
+
module Config
|
5
|
+
extend self
|
6
|
+
|
7
|
+
attr_writer :heroku_user
|
8
|
+
attr_writer :heroku_pass
|
9
|
+
attr_writer :heroku_app
|
10
|
+
|
11
|
+
def heroku_user
|
12
|
+
@heroku_user || ENV['HEROKU_USER']
|
13
|
+
end
|
14
|
+
|
15
|
+
def heroku_pass
|
16
|
+
@heroku_pass || ENV['HEROKU_PASS']
|
17
|
+
end
|
18
|
+
|
19
|
+
def heroku_app
|
20
|
+
@heroku_app || ENV['HEROKU_APP']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'heroku'
|
2
|
+
require 'heroku/plugins/domainr/config'
|
3
|
+
|
4
|
+
module Heroku
|
5
|
+
module Plugins
|
6
|
+
module Domainr
|
7
|
+
@@heroku_client = nil
|
8
|
+
|
9
|
+
def domains_add(domain)
|
10
|
+
heroku_client.add_domain(Heroku::Plugins::Domainr::Config.heroku_app, domain)
|
11
|
+
end
|
12
|
+
|
13
|
+
def domains_remove(domain)
|
14
|
+
heroku_client.remove_domain(Heroku::Plugins::Domainr::Config.heroku_app, domain)
|
15
|
+
end
|
16
|
+
|
17
|
+
def domains_clear()
|
18
|
+
heroku_client.remove_domains(Heroku::Plugins::Domainr::Config.heroku_app)
|
19
|
+
end
|
20
|
+
|
21
|
+
def heroku_client
|
22
|
+
@@heroku_client || @@heroku_client = Heroku::Client.new(Heroku::Plugins::Domainr::Config.heroku_user,
|
23
|
+
Heroku::Plugins::Domainr::Config.heroku_pass)
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.config
|
27
|
+
yield Heroku::Plugins::Domainr::Config
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def log(message)
|
33
|
+
if defined?(Rails)
|
34
|
+
Rails.logger.info(message)
|
35
|
+
else
|
36
|
+
puts message
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/config_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'heroku/plugins/domainr/config'
|
3
|
+
|
4
|
+
describe Heroku::Plugins::Domainr::Config do
|
5
|
+
describe "heroku_user" do
|
6
|
+
it "stores the given heroku user name" do
|
7
|
+
subject.heroku_user = "user@example.com"
|
8
|
+
subject.heroku_user.should == "user@example.com"
|
9
|
+
end
|
10
|
+
|
11
|
+
it "defaults to HEROKU_USER environment variable" do
|
12
|
+
subject.heroku_user = nil
|
13
|
+
ENV["HEROKU_USER"] = "other-user@example.com"
|
14
|
+
subject.heroku_user.should == "other-user@example.com"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "heroku_pass" do
|
19
|
+
it "stores the given heroku password" do
|
20
|
+
subject.heroku_pass = "password"
|
21
|
+
subject.heroku_pass.should == "password"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "defaults to HEROKU_PASS environment variable" do
|
25
|
+
subject.heroku_pass = nil
|
26
|
+
ENV["HEROKU_PASS"] = "other-password"
|
27
|
+
subject.heroku_pass.should == "other-password"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "heroku_app" do
|
32
|
+
it "stores the given heroku application name" do
|
33
|
+
subject.heroku_app = "my-app"
|
34
|
+
subject.heroku_app.should == "my-app"
|
35
|
+
end
|
36
|
+
|
37
|
+
it "defaults to HEROKU_APP environment variable" do
|
38
|
+
subject.heroku_app = nil
|
39
|
+
ENV["HEROKU_APP"] = "my-other-app"
|
40
|
+
subject.heroku_app.should == "my-other-app"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'heroku/plugins/heroku_domainr'
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
config.mock_with :rr
|
6
|
+
end
|
7
|
+
|
8
|
+
Heroku::Plugins::Domainr.config do |c|
|
9
|
+
c.heroku_app = "app_name"
|
10
|
+
end
|
11
|
+
|
12
|
+
class DomainrImpl
|
13
|
+
include Heroku::Plugins::Domainr
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Heroku::Plugins::Domainr do
|
17
|
+
before do
|
18
|
+
@domainr = DomainrImpl.new
|
19
|
+
@fake_heroku_client = Object.new
|
20
|
+
stub(@domainr).heroku_client{ @fake_heroku_client }
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should call heroku add domain with app name and domain" do
|
24
|
+
mock(@fake_heroku_client).add_domain("app_name", "alamakota")
|
25
|
+
@domainr.domains_add("alamakota")
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should call heroku remove domain with app name and domain" do
|
29
|
+
mock(@fake_heroku_client).remove_domain("app_name", "alamialakota")
|
30
|
+
@domainr.domains_remove("alamialakota")
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should call heroku remove domains with app name" do
|
34
|
+
mock(@fake_heroku_client).remove_domains("app_name")
|
35
|
+
@domainr.domains_clear()
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: heroku-domainr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Marcin Naglik
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-05-09 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: heroku
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
description: |
|
34
|
+
This gem adds Heroku domains management to the heroku application.
|
35
|
+
|
36
|
+
email: marcin.naglik@gmail.com
|
37
|
+
executables: []
|
38
|
+
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- README.md
|
45
|
+
- MIT.LICENSE
|
46
|
+
- GEMFILE
|
47
|
+
- lib/heroku/plugins/domainr/config.rb
|
48
|
+
- lib/heroku/plugins/domainr/version.rb
|
49
|
+
- lib/heroku/plugins/heroku_domainr.rb
|
50
|
+
- spec/config_spec.rb
|
51
|
+
- spec/heroku_domainr_spec.rb
|
52
|
+
has_rdoc: true
|
53
|
+
homepage: https://github.com/managr/heroku-domainr
|
54
|
+
licenses: []
|
55
|
+
|
56
|
+
post_install_message:
|
57
|
+
rdoc_options: []
|
58
|
+
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
version: "0"
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.7
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: Heroku plugin to manage heroku domains from the heroku application
|
84
|
+
test_files: []
|
85
|
+
|