pco-url 1.5.0 → 1.6.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 +4 -4
- data/lib/pco/url/version.rb +1 -1
- data/lib/pco/url.rb +21 -11
- data/spec/pco_url_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 004aee9017d42a66e9eeeef2365c6dfc033f966b
|
4
|
+
data.tar.gz: 6353fd59875302f9849ed3c6821a5607e19c78cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcc5a0eb716b9677104abcbf3ad42728205edbb68f661214993d7223a861d87b7a0b2093b94aa18b700f27b4d4cae7c38c961266b8bb1d024c2a107c416f6c27
|
7
|
+
data.tar.gz: 7625c45373ef6139fa8dad3934615ac54b808ef9a6f0719e8c416c37bddd58815cab1f2328e803a5f6536342b166e93b53d0b7b3c3e9dbb05aaf16e4b26a770a
|
data/lib/pco/url/version.rb
CHANGED
data/lib/pco/url.rb
CHANGED
@@ -47,9 +47,10 @@ module PCO
|
|
47
47
|
attr_reader :path
|
48
48
|
attr_reader :query
|
49
49
|
|
50
|
-
def initialize(app_name:, path: nil, query: nil, encrypt_query_params: false)
|
50
|
+
def initialize(app_name:, path: nil, query: nil, encrypt_query_params: false, domain: nil)
|
51
51
|
@app_name = app_name.to_s.gsub("_", "-")
|
52
52
|
@path = path
|
53
|
+
@domain = domain
|
53
54
|
|
54
55
|
@path = @path[1..-1] if @path && @path[0] == "/"
|
55
56
|
|
@@ -70,25 +71,34 @@ module PCO
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
|
74
|
+
def domain
|
75
|
+
return @domain if @domain
|
76
|
+
|
77
|
+
case env
|
78
|
+
when "production", "staging"
|
79
|
+
"planningcenteronline.com"
|
80
|
+
when "development"
|
81
|
+
"pco.dev"
|
82
|
+
when "test"
|
83
|
+
"pco.test"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
73
87
|
def hostname
|
74
88
|
# Try "CHECK_INS_URL" then url_for_app("check-ins")
|
75
89
|
return env_overridden_hostname.split("://")[1] if env_overridden_hostname
|
76
90
|
|
77
91
|
case env
|
78
|
-
when "production"
|
79
|
-
"#{@app_name}.planningcenteronline.com"
|
80
92
|
when "staging"
|
81
|
-
"#{
|
82
|
-
|
83
|
-
"#{
|
84
|
-
when "test"
|
85
|
-
"#{@app_name}.pco.test"
|
93
|
+
"#{app_name}-staging.#{domain}"
|
94
|
+
else
|
95
|
+
"#{app_name}.#{domain}"
|
86
96
|
end
|
87
97
|
end
|
88
98
|
|
89
99
|
def uri
|
90
|
-
|
91
|
-
url_string = "#{scheme}://#{hostname}/#{
|
100
|
+
q = query ? "?#{query}" : nil
|
101
|
+
url_string = "#{scheme}://#{hostname}/#{path}#{q}".sub(/(\/)+$/,'')
|
92
102
|
URI(url_string)
|
93
103
|
end
|
94
104
|
|
@@ -103,7 +113,7 @@ module PCO
|
|
103
113
|
end
|
104
114
|
|
105
115
|
def env_overridden_hostname
|
106
|
-
env_var =
|
116
|
+
env_var = app_name.to_s.upcase + "_URL"
|
107
117
|
ENV[env_var]
|
108
118
|
end
|
109
119
|
end
|
data/spec/pco_url_spec.rb
CHANGED
@@ -66,6 +66,12 @@ describe PCO::URL do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
describe "custom domains" do
|
70
|
+
it "returns a URL with a custom domain" do
|
71
|
+
expect(PCO::URL.new(app_name: "us-east", domain: "pcocdn.com").to_s).to eq("http://us-east.pcocdn.com")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
69
75
|
context "with path starting with /" do
|
70
76
|
Applications.map(&:to_s).each do |app|
|
71
77
|
it "has an #{app} URL with path" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pco-url
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Miller
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: urlcrypt
|