pco-url 1.5.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: be3eb46f919cb623fbb6232e443ab60a6313c84a
4
- data.tar.gz: 9b18a5461d22051ea2922280b96413b2419a79c4
3
+ metadata.gz: 004aee9017d42a66e9eeeef2365c6dfc033f966b
4
+ data.tar.gz: 6353fd59875302f9849ed3c6821a5607e19c78cf
5
5
  SHA512:
6
- metadata.gz: 25db8d4fe497d0cabf40702822877b6528fdf9c9da48a49e004541077bdae1154fe2a2732caa98276ffcfe3855df63a54352e1b1e56dd0c4287405cb97a709e2
7
- data.tar.gz: 073305bdf03bccc3d17ce0d6ed8ab83ff685a34ec3714fed009ee3f321de61db96742f3649f0b4dc2cefc7eebe0b66c07d0bf739788fe04469de263999142720
6
+ metadata.gz: dcc5a0eb716b9677104abcbf3ad42728205edbb68f661214993d7223a861d87b7a0b2093b94aa18b700f27b4d4cae7c38c961266b8bb1d024c2a107c416f6c27
7
+ data.tar.gz: 7625c45373ef6139fa8dad3934615ac54b808ef9a6f0719e8c416c37bddd58815cab1f2328e803a5f6536342b166e93b53d0b7b3c3e9dbb05aaf16e4b26a770a
@@ -1,5 +1,5 @@
1
1
  module PCO
2
2
  class URL
3
- VERSION = "1.5.0"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
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
- "#{@app_name}-staging.planningcenteronline.com"
82
- when "development"
83
- "#{@app_name}.pco.dev"
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
- query = @query ? "?#{@query}" : nil
91
- url_string = "#{scheme}://#{hostname}/#{@path}#{query}".sub(/(\/)+$/,'')
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 = @app_name.to_s.upcase + "_URL"
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.5.0
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-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: urlcrypt