pco-url 1.0.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.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +34 -0
- data/Rakefile +2 -0
- data/lib/pco/url/version.rb +5 -0
- data/lib/pco/url.rb +48 -0
- data/pco-url.gemspec +23 -0
- data/spec/pco_url_spec.rb +90 -0
- data/spec/spec_helper.rb +12 -0
- metadata +104 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b7d83f7b0622788c8066d64acf56f40f10bd9db7
|
4
|
+
data.tar.gz: 1ad717341534953c53535c6c646b3d31475d483a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8d5a4fb5507e25211a0f53c7685b1e838cee30af3d3e73c465664217b81cf406ca4ca9ae9a666c37aca4b964a3a13f0cc96249ff9c4fbde4d09689a9ae6b5c2
|
7
|
+
data.tar.gz: 4732298a1bd72dabf8f1ff85036d58017d2edb79019fab65177483a19ba881086989914f97416677adfdec5bdb335c638c0fa01486002f1d517f44ce508ae063
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 James Miller
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# PCO::URL
|
2
|
+
|
3
|
+
Fetch the base URL for the current and other applications based on the current application environment.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Uses `Rails.env` by default to determine the environment name.
|
8
|
+
|
9
|
+
Set `ENV["DEPLOY_ENV"]` to override this default.
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
ENV["DEPLOY_ENV"] = "staging"
|
13
|
+
|
14
|
+
Rails.env
|
15
|
+
# => "production"
|
16
|
+
|
17
|
+
PCO::URL.accounts
|
18
|
+
# => "https://accounts-staging.planningcenteronline.com"
|
19
|
+
```
|
20
|
+
|
21
|
+
For individual apps, change an environment variable to specify the URL for a given app:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
ENV["ACCOUNTS_URL"] = "https://accounts-test1.planningcenteronline.com"
|
25
|
+
|
26
|
+
Rails.env
|
27
|
+
# => "staging"
|
28
|
+
|
29
|
+
PCO::URL.accounts
|
30
|
+
# => "https://accounts-test1.planningcenteronline.com"
|
31
|
+
|
32
|
+
PCO::URL.services
|
33
|
+
# => "https://services-staging.planningcenteronline.com"
|
34
|
+
```
|
data/Rakefile
ADDED
data/lib/pco/url.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require "pco/url/version"
|
2
|
+
|
3
|
+
module PCO
|
4
|
+
class URL
|
5
|
+
Applications = [
|
6
|
+
:accounts,
|
7
|
+
:avatars,
|
8
|
+
:services,
|
9
|
+
:check_ins,
|
10
|
+
:people,
|
11
|
+
:registrations,
|
12
|
+
:resources
|
13
|
+
]
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def method_missing(method_name)
|
17
|
+
if Applications.include? method_name
|
18
|
+
app_name = method_name.to_s.gsub("_", "-")
|
19
|
+
env_var = method_name.to_s.upcase + "_URL"
|
20
|
+
|
21
|
+
# Try "CHECK_INS_URL" then url_for_app("check-ins")
|
22
|
+
ENV[env_var] || url_for_app(app_name)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def env
|
31
|
+
ENV["DEPLOY_ENV"] || Rails.env
|
32
|
+
end
|
33
|
+
|
34
|
+
def url_for_app(app_name)
|
35
|
+
case env
|
36
|
+
when "production"
|
37
|
+
"https://#{app_name}.planningcenteronline.com"
|
38
|
+
when "staging"
|
39
|
+
"https://#{app_name}-staging.planningcenteronline.com"
|
40
|
+
when "development"
|
41
|
+
"http://#{app_name}.pco.dev"
|
42
|
+
when "test"
|
43
|
+
"http://#{app_name}.pco.test"
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/pco-url.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pco/url/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "pco-url"
|
8
|
+
spec.version = PCO::URL::VERSION
|
9
|
+
spec.authors = ["James Miller"]
|
10
|
+
spec.email = ["bensie@gmail.com"]
|
11
|
+
spec.summary = %q{Generate URLs for app PCO apps in all environments}
|
12
|
+
spec.homepage = "https://github.com/ministrycentered/pco-url"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0")
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
21
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
22
|
+
spec.add_development_dependency "rspec", ">= 3.0.0", "< 4"
|
23
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PCO::URL do
|
4
|
+
describe "defaults" do
|
5
|
+
describe "development" do
|
6
|
+
before do
|
7
|
+
Rails.env = "development"
|
8
|
+
end
|
9
|
+
|
10
|
+
PCO::URL::Applications.map(&:to_s).each do |app|
|
11
|
+
it "has an #{app} URL" do
|
12
|
+
expect(PCO::URL.send(app)).to eq("http://#{app.gsub('_','-')}.pco.dev")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "staging" do
|
18
|
+
before do
|
19
|
+
Rails.env = "staging"
|
20
|
+
end
|
21
|
+
|
22
|
+
PCO::URL::Applications.map(&:to_s).each do |app|
|
23
|
+
it "has an #{app} URL" do
|
24
|
+
expect(PCO::URL.send(app)).to eq("https://#{app.gsub('_','-')}-staging.planningcenteronline.com")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "production" do
|
30
|
+
before do
|
31
|
+
Rails.env = "production"
|
32
|
+
end
|
33
|
+
|
34
|
+
PCO::URL::Applications.map(&:to_s).each do |app|
|
35
|
+
it "has an #{app} URL" do
|
36
|
+
expect(PCO::URL.send(app)).to eq("https://#{app.gsub('_','-')}.planningcenteronline.com")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "test" do
|
42
|
+
before do
|
43
|
+
Rails.env = "test"
|
44
|
+
end
|
45
|
+
|
46
|
+
PCO::URL::Applications.map(&:to_s).each do |app|
|
47
|
+
it "has an #{app} URL" do
|
48
|
+
expect(PCO::URL.send(app)).to eq("http://#{app.gsub('_','-')}.pco.test")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "overrides" do
|
55
|
+
describe "development with accounts URL override" do
|
56
|
+
before do
|
57
|
+
Rails.env = "development"
|
58
|
+
ENV["ACCOUNTS_URL"] = "http://bazinga.com"
|
59
|
+
end
|
60
|
+
|
61
|
+
it "has a custom accounts URL" do
|
62
|
+
expect(PCO::URL.accounts).to eq("http://bazinga.com")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "Rails.env staging with DEPLOY_ENV override" do
|
67
|
+
before do
|
68
|
+
Rails.env = "development"
|
69
|
+
ENV["ACCOUNTS_URL"] = nil
|
70
|
+
ENV["DEPLOY_ENV"] = "staging"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "loads the DEPLOY_ENV URLs" do
|
74
|
+
expect(PCO::URL.accounts).to eq("https://accounts-staging.planningcenteronline.com")
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
describe "Rails.env staging with DEPLOY_ENV override and ACCOUNTS_URL override" do
|
79
|
+
before do
|
80
|
+
Rails.env = "development"
|
81
|
+
ENV["ACCOUNTS_URL"] = "http://accounts-test1.planningcenteronline.com"
|
82
|
+
ENV["DEPLOY_ENV"] = "staging"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "loads the DEPLOY_ENV URLs" do
|
86
|
+
expect(PCO::URL.accounts).to eq("http://accounts-test1.planningcenteronline.com")
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pco-url
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- James Miller
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.0.0
|
48
|
+
- - "<"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '4'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 3.0.0
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '4'
|
61
|
+
description:
|
62
|
+
email:
|
63
|
+
- bensie@gmail.com
|
64
|
+
executables: []
|
65
|
+
extensions: []
|
66
|
+
extra_rdoc_files: []
|
67
|
+
files:
|
68
|
+
- ".gitignore"
|
69
|
+
- Gemfile
|
70
|
+
- LICENSE.txt
|
71
|
+
- README.md
|
72
|
+
- Rakefile
|
73
|
+
- lib/pco/url.rb
|
74
|
+
- lib/pco/url/version.rb
|
75
|
+
- pco-url.gemspec
|
76
|
+
- spec/pco_url_spec.rb
|
77
|
+
- spec/spec_helper.rb
|
78
|
+
homepage: https://github.com/ministrycentered/pco-url
|
79
|
+
licenses:
|
80
|
+
- MIT
|
81
|
+
metadata: {}
|
82
|
+
post_install_message:
|
83
|
+
rdoc_options: []
|
84
|
+
require_paths:
|
85
|
+
- lib
|
86
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 2.2.2
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Generate URLs for app PCO apps in all environments
|
102
|
+
test_files:
|
103
|
+
- spec/pco_url_spec.rb
|
104
|
+
- spec/spec_helper.rb
|