exvo_helpers 0.0.8 → 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/.gitignore +1 -0
- data/MIT-LICENSE +20 -0
- data/README.md +31 -26
- data/exvo_helpers.gemspec +5 -3
- data/lib/exvo_helpers/helpers.rb +24 -16
- data/lib/exvo_helpers/version.rb +1 -1
- data/spec/exvo_helpers/helpers_spec.rb +17 -15
- data/spec/spec_helper.rb +5 -0
- metadata +39 -15
data/.gitignore
CHANGED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright © 2011-2012 Exvo.com Development BV
|
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
CHANGED
@@ -7,6 +7,7 @@ Ruby gem providing helper methods for various Exvo apps/services. It takes into
|
|
7
7
|
Results are from the 'development' Rails environment:
|
8
8
|
|
9
9
|
```ruby
|
10
|
+
Exvo::Helpers.auth_host => 'auth.exvo.local'
|
10
11
|
Exvo::Helpers.cdn_host => 'www.exvo.local'
|
11
12
|
Exvo::Helpers.cfs_host => 'cfs.exvo.local'
|
12
13
|
Exvo::Helpers.desktop_host => 'www.exvo.local'
|
@@ -18,6 +19,7 @@ Exvo::Helpers.music_host => 'music.exvo.local'
|
|
18
19
|
Exvo::Helpers.pics_host => 'pics.exvo.local'
|
19
20
|
Exvo::Helpers.preview_host => 'preview.exvo.local'
|
20
21
|
|
22
|
+
Exvo::Helpers.auth_uri => 'http://auth.exvo.local'
|
21
23
|
Exvo::Helpers.cdn_uri => 'http://www.exvo.local'
|
22
24
|
Exvo::Helpers.cfs_uri => 'http://cfs.exvo.local'
|
23
25
|
Exvo::Helpers.desktop_uri => 'http://www.exvo.local'
|
@@ -30,44 +32,47 @@ Exvo::Helpers.pics_uri => 'http://pics.exvo.local'
|
|
30
32
|
Exvo::Helpers.preview_uri => 'http://preview.exvo.local'
|
31
33
|
```
|
32
34
|
|
33
|
-
|
35
|
+
There is also an `auth_require_ssl` method, which takes true/false values and is used to construct `auth_uri`. It returns `true` in production and `false` in all other environments.
|
34
36
|
|
35
37
|
```ruby
|
36
|
-
Exvo::Helpers.
|
37
|
-
Exvo::Helpers.auth_uri => 'http://exvo.auth.local'
|
38
|
+
Exvo::Helpers.auth_require_ssl => false
|
38
39
|
```
|
39
40
|
|
40
41
|
|
41
|
-
### Overwriting
|
42
|
+
### Overwriting the defaults
|
42
43
|
|
43
|
-
There are two ways to do it. One is by the means of ENV variables (preferred
|
44
|
+
There are two ways to do it. One is by the means of ENV variables (the preferred method):
|
44
45
|
|
45
46
|
```ruby
|
46
|
-
ENV['
|
47
|
-
ENV['
|
48
|
-
ENV['
|
49
|
-
ENV['
|
50
|
-
ENV['
|
51
|
-
ENV['
|
52
|
-
ENV['
|
53
|
-
ENV['
|
54
|
-
ENV['
|
55
|
-
ENV['
|
47
|
+
ENV['AUTH_REQUIRE_SSL'] = 'true'
|
48
|
+
ENV['AUTH_HOST'] = 'test.auth.exvo.com'
|
49
|
+
ENV['CDN_HOST'] = 'test.cdn.exvo.com'
|
50
|
+
ENV['CFS_HOST'] = 'test.cfs.exvo.com'
|
51
|
+
ENV['DESKTOP_HOST'] = 'test.exvo.com'
|
52
|
+
ENV['THEMES_HOST'] = 'test.themes.exvo.com'
|
53
|
+
ENV['BLOG_HOST'] = 'test.blog.exvo.local'
|
54
|
+
ENV['CONTACTS_HOST'] = 'test.contacts.exvo.local'
|
55
|
+
ENV['INBOX_HOST'] = 'test.inbox.exvo.local'
|
56
|
+
ENV['MUSIC_HOST'] = 'test.music.exvo.local'
|
57
|
+
ENV['PICS_HOST'] = 'test.pics.exvo.local'
|
58
|
+
ENV['PREVIEW_HOST'] = 'test.preview.exvo.local'
|
56
59
|
```
|
57
60
|
|
58
61
|
The other one is to set it in the application's config file:
|
59
62
|
|
60
63
|
```ruby
|
61
|
-
Exvo::Helpers.
|
62
|
-
Exvo::Helpers.
|
63
|
-
Exvo::Helpers.
|
64
|
-
Exvo::Helpers.
|
65
|
-
Exvo::Helpers.
|
66
|
-
Exvo::Helpers.
|
67
|
-
Exvo::Helpers.
|
68
|
-
Exvo::Helpers.
|
69
|
-
Exvo::Helpers.
|
70
|
-
Exvo::Helpers.
|
64
|
+
Exvo::Helpers.auth_require_ssl = true
|
65
|
+
Exvo::Helpers.auth_host = 'test.auth.exvo.com'
|
66
|
+
Exvo::Helpers.cdn_host = 'test.cdn.exvo.com'
|
67
|
+
Exvo::Helpers.cfs_host = 'test.cfs.exvo.com'
|
68
|
+
Exvo::Helpers.desktop_host = 'test.exvo.com'
|
69
|
+
Exvo::Helpers.themes_host = 'test.themes.exvo.com'
|
70
|
+
Exvo::Helpers.blog_host = 'test.blog.exvo.local'
|
71
|
+
Exvo::Helpers.contacts_host = 'test.contacts.exvo.local'
|
72
|
+
Exvo::Helpers.inbox_host = 'test.inbox.exvo.local'
|
73
|
+
Exvo::Helpers.music_host = 'test.music.exvo.local'
|
74
|
+
Exvo::Helpers.pics_host = 'test.pics.exvo.local'
|
75
|
+
Exvo::Helpers.preview_host = 'test.preview.exvo.local'
|
71
76
|
```
|
72
77
|
|
73
78
|
|
@@ -127,4 +132,4 @@ Note, that this helper does not support full API of Rails' `stylesheet_link_tag`
|
|
127
132
|
```
|
128
133
|
|
129
134
|
|
130
|
-
Copyright © 2011 Exvo.com Development BV
|
135
|
+
Copyright © 2011-2012 Exvo.com Development BV, released under the MIT license
|
data/exvo_helpers.gemspec
CHANGED
@@ -16,9 +16,11 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
|
-
s.add_development_dependency 'rspec', ['>= 2.
|
20
|
-
s.add_development_dependency 'guard', ['>= 0.
|
21
|
-
s.add_development_dependency 'guard-rspec', ['>= 0.
|
19
|
+
s.add_development_dependency 'rspec', ['>= 2.8']
|
20
|
+
s.add_development_dependency 'guard', ['>= 0.10.0']
|
21
|
+
s.add_development_dependency 'guard-rspec', ['>= 0.6.0']
|
22
22
|
s.add_development_dependency "rb-fsevent"
|
23
23
|
s.add_development_dependency "rb-inotify"
|
24
|
+
s.add_development_dependency "simplecov"
|
25
|
+
s.add_development_dependency "simplecov-rcov"
|
24
26
|
end
|
data/lib/exvo_helpers/helpers.rb
CHANGED
@@ -5,16 +5,24 @@ module Exvo
|
|
5
5
|
# Dynamically define class methods
|
6
6
|
class << self
|
7
7
|
|
8
|
-
%w(cdn cfs desktop themes blog contacts inbox music pics preview).each do |service|
|
8
|
+
%w(auth cdn cfs desktop themes blog contacts inbox music pics preview).each do |service|
|
9
9
|
|
10
10
|
# def self.cdn_uri
|
11
|
-
# protocol =
|
11
|
+
# protocol = 'http://'
|
12
|
+
# protocol = 'https://' if service == "auth" && auth_require_ssl
|
13
|
+
# protocol = '//' if ["cdn", "cfs", "themes"].include?(service) && env.to_sym == :production
|
12
14
|
# protocol + cdn_host
|
13
15
|
# end
|
14
16
|
define_method "#{service}_uri" do
|
17
|
+
protocol = 'http://'
|
18
|
+
|
19
|
+
# explicit https for auth
|
20
|
+
protocol = 'https://' if service == "auth" && send(:auth_require_ssl)
|
21
|
+
|
15
22
|
# special link starting with '//' in production so that the webserver can choose between HTTP and HTTPS
|
16
23
|
# but only for those apps/services that have proper SSL support (i.e. valid certificates)
|
17
|
-
protocol = ["cdn", "cfs", "themes"].include?(service) && env.to_sym == :production
|
24
|
+
protocol = '//' if ["cdn", "cfs", "themes"].include?(service) && env.to_sym == :production
|
25
|
+
|
18
26
|
protocol + send("#{service}_host")
|
19
27
|
end
|
20
28
|
|
@@ -45,21 +53,13 @@ module Exvo
|
|
45
53
|
|
46
54
|
# AUTH
|
47
55
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
ExvoAuth::Config.uri
|
52
|
-
else
|
53
|
-
raise "Exvo.auth_uri method is available only when exvo-auth gem is available"
|
54
|
-
end
|
56
|
+
def self.auth_require_ssl
|
57
|
+
return @@auth_require_ssl if defined?(@@auth_require_ssl) && !@@auth_require_ssl.nil?
|
58
|
+
@@auth_require_ssl = (ENV['AUTH_REQUIRE_SSL'] == 'true') || default_opts[env.to_sym][:auth_require_ssl]
|
55
59
|
end
|
56
60
|
|
57
|
-
def self.
|
58
|
-
|
59
|
-
ExvoAuth::Config.host
|
60
|
-
else
|
61
|
-
raise "Exvo.auth_host method is available only when exvo-auth gem is available"
|
62
|
-
end
|
61
|
+
def self.auth_require_ssl=(require_ssl)
|
62
|
+
@@auth_require_ssl = require_ssl
|
63
63
|
end
|
64
64
|
|
65
65
|
|
@@ -81,6 +81,8 @@ module Exvo
|
|
81
81
|
def self.default_opts
|
82
82
|
{
|
83
83
|
:production => {
|
84
|
+
:auth_host => 'auth.exvo.com',
|
85
|
+
:auth_require_ssl => true,
|
84
86
|
:cdn_host => 'd33gjlr95u9pgf.cloudfront.net', # cloudfront.net so we can use https (cdn.exvo.com via https does not work properly)
|
85
87
|
:cfs_host => 'cfs.exvo.com',
|
86
88
|
:desktop_host => 'www.exvo.com',
|
@@ -93,6 +95,8 @@ module Exvo
|
|
93
95
|
:preview_host => 'preview.exvo.com'
|
94
96
|
},
|
95
97
|
:staging => {
|
98
|
+
:auth_host => 'staging.auth.exvo.com',
|
99
|
+
:auth_require_ssl => false,
|
96
100
|
:cdn_host => 'd1by559a994699.cloudfront.net',
|
97
101
|
:cfs_host => 'staging.cfs.exvo.com',
|
98
102
|
:desktop_host => 'www.exvo.co',
|
@@ -105,6 +109,8 @@ module Exvo
|
|
105
109
|
:preview_host => 'staging.preview.exvo.com'
|
106
110
|
},
|
107
111
|
:development => {
|
112
|
+
:auth_host => 'auth.exvo.local',
|
113
|
+
:auth_require_ssl => false,
|
108
114
|
:cdn_host => 'www.exvo.local',
|
109
115
|
:cfs_host => 'cfs.exvo.local',
|
110
116
|
:desktop_host => 'www.exvo.local',
|
@@ -117,6 +123,8 @@ module Exvo
|
|
117
123
|
:preview_host => 'preview.exvo.local'
|
118
124
|
},
|
119
125
|
:test => {
|
126
|
+
:auth_host => 'auth.exvo.local',
|
127
|
+
:auth_require_ssl => false,
|
120
128
|
:cdn_host => 'www.exvo.local',
|
121
129
|
:cfs_host => 'cfs.exvo.local',
|
122
130
|
:desktop_host => 'www.exvo.local',
|
data/lib/exvo_helpers/version.rb
CHANGED
@@ -21,6 +21,7 @@ describe Exvo::Helpers do
|
|
21
21
|
Exvo::Helpers.stub(:env).and_return('production')
|
22
22
|
end
|
23
23
|
|
24
|
+
specify { Exvo::Helpers.auth_uri.should match('auth.exvo.com') }
|
24
25
|
specify { Exvo::Helpers.cdn_uri.should match('d33gjlr95u9pgf.cloudfront.net') }
|
25
26
|
specify { Exvo::Helpers.cfs_uri.should match('cfs.exvo.com') }
|
26
27
|
specify { Exvo::Helpers.desktop_uri.should match('www.exvo.com') }
|
@@ -38,6 +39,7 @@ describe Exvo::Helpers do
|
|
38
39
|
Exvo::Helpers.stub(:env).and_return('production')
|
39
40
|
end
|
40
41
|
|
42
|
+
specify { Exvo::Helpers.auth_host.should match('auth.exvo.com') }
|
41
43
|
specify { Exvo::Helpers.cdn_host.should eql('d33gjlr95u9pgf.cloudfront.net') }
|
42
44
|
specify { Exvo::Helpers.cfs_host.should eql('cfs.exvo.com') }
|
43
45
|
specify { Exvo::Helpers.desktop_host.should eql('www.exvo.com') }
|
@@ -63,6 +65,10 @@ describe Exvo::Helpers do
|
|
63
65
|
end
|
64
66
|
|
65
67
|
specify { Exvo::Helpers.cdn_host.should eql(cdn_host) }
|
68
|
+
|
69
|
+
after do
|
70
|
+
ENV["CDN_HOST"] = nil
|
71
|
+
end
|
66
72
|
end
|
67
73
|
|
68
74
|
describe "setting host directly overrides the defaults" do
|
@@ -74,26 +80,22 @@ describe Exvo::Helpers do
|
|
74
80
|
end
|
75
81
|
|
76
82
|
specify { Exvo::Helpers.cdn_host.should eql(cdn_host) }
|
77
|
-
end
|
78
83
|
|
79
|
-
|
80
|
-
|
81
|
-
let(:uri) { "http://#{host}"}
|
82
|
-
|
83
|
-
it "raises an error when ExvoAuth is not available" do
|
84
|
-
expect { Exvo::Helpers.auth_uri }.to raise_error
|
85
|
-
expect { Exvo::Helpers.auth_host }.to raise_error
|
84
|
+
after do
|
85
|
+
Exvo::Helpers.cdn_host = nil
|
86
86
|
end
|
87
|
+
end
|
87
88
|
|
88
|
-
|
89
|
-
|
90
|
-
|
89
|
+
describe "setting the auth_require_ssl directly overrides the default" do
|
90
|
+
before do
|
91
|
+
Exvo::Helpers.stub(:env).and_return('production')
|
92
|
+
Exvo::Helpers.auth_require_ssl = false
|
93
|
+
end
|
91
94
|
|
92
|
-
|
93
|
-
Exvo::Helpers.auth_host.should eql(host)
|
95
|
+
specify { Exvo::Helpers.auth_uri.should match(/http:\/\//) }
|
94
96
|
|
95
|
-
|
96
|
-
Exvo::Helpers.
|
97
|
+
after do
|
98
|
+
Exvo::Helpers.auth_require_ssl = nil
|
97
99
|
end
|
98
100
|
end
|
99
101
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exvo_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,44 +9,44 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-13 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &78011280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: '2.
|
21
|
+
version: '2.8'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *78011280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: guard
|
27
|
-
requirement: &
|
27
|
+
requirement: &78011020 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.
|
32
|
+
version: 0.10.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *78011020
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: guard-rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &78010780 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 0.
|
43
|
+
version: 0.6.0
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *78010780
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rb-fsevent
|
49
|
-
requirement: &
|
49
|
+
requirement: &78010590 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *78010590
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rb-inotify
|
60
|
-
requirement: &
|
60
|
+
requirement: &78010350 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,7 +65,29 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *78010350
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: &78010110 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *78010110
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: simplecov-rcov
|
82
|
+
requirement: &78009840 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *78009840
|
69
91
|
description: Ruby gem providing helper *_uri/*_host methods for Exvo services/apps
|
70
92
|
like DESKTOP/CFS/AUTH/THEMES.
|
71
93
|
email:
|
@@ -76,6 +98,7 @@ extra_rdoc_files: []
|
|
76
98
|
files:
|
77
99
|
- .gitignore
|
78
100
|
- Gemfile
|
101
|
+
- MIT-LICENSE
|
79
102
|
- README.md
|
80
103
|
- Rakefile
|
81
104
|
- exvo_helpers.gemspec
|
@@ -112,3 +135,4 @@ signing_key:
|
|
112
135
|
specification_version: 3
|
113
136
|
summary: host/uri helper methods for various Exvo services
|
114
137
|
test_files: []
|
138
|
+
has_rdoc:
|