exvo_helpers 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,20 +7,20 @@ 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.cfs_host => 'cfs.exvo.local'
11
- Exvo.desktop_host => 'www.exvo.local'
12
- Exvo.themes_host => 'themes.exvo.local'
10
+ Exvo::Helpers.cfs_host => 'cfs.exvo.local'
11
+ Exvo::Helpers.desktop_host => 'www.exvo.local'
12
+ Exvo::Helpers.themes_host => 'themes.exvo.local'
13
13
 
14
- Exvo.cfs_uri => 'http://cfs.exvo.local'
15
- Exvo.desktop_uri => 'http://www.exvo.local'
16
- Exvo.themes_uri => 'http://themes.exvo.local'
14
+ Exvo::Helpers.cfs_uri => 'http://cfs.exvo.local'
15
+ Exvo::Helpers.desktop_uri => 'http://www.exvo.local'
16
+ Exvo::Helpers.themes_uri => 'http://themes.exvo.local'
17
17
  ```
18
18
 
19
- For consistency, there are also read-only `auth_host/auth_uri` methods, that just pass execution to the [exvo-auth](https://github.com/Exvo/Auth) gem (so it's required this gem is available when using them):
19
+ For consistency, there are also read-only `auth_host/auth_uri` methods, that just pass execution to the [exvo-auth](https://github.com/Exvo/Auth) gem (so it's required that exvo-auth gem is available when using them):
20
20
 
21
21
  ```ruby
22
- Exvo.auth_host => 'exvo.auth.local'
23
- Exvo.auth_uri => 'http://exvo.auth.local'
22
+ Exvo::Helpers.auth_host => 'exvo.auth.local'
23
+ Exvo::Helpers.auth_uri => 'http://exvo.auth.local'
24
24
  ```
25
25
 
26
26
 
@@ -37,9 +37,9 @@ ENV['THEMES_HOST'] = 'test.themes.exvo.com'
37
37
  The other one is to set it in the application's config file:
38
38
 
39
39
  ```ruby
40
- Exvo.cfs_host = 'test.cfs.exvo.com'
41
- Exvo.desktop_host = 'test.exvo.com'
42
- Exvo.themes_host = 'test.themes.exvo.com'
40
+ Exvo::Helpers.cfs_host = 'test.cfs.exvo.com'
41
+ Exvo::Helpers.desktop_host = 'test.exvo.com'
42
+ Exvo::Helpers.themes_host = 'test.themes.exvo.com'
43
43
  ```
44
44
 
45
45
 
@@ -1,107 +1,112 @@
1
1
  module Exvo
2
2
 
3
- # CFS
3
+ module Helpers
4
4
 
5
- def self.cfs_uri
6
- "http://#{cfs_host}"
7
- end
5
+ # CFS
8
6
 
9
- def self.cfs_host
10
- @@cfs_host ||= ENV['CFS_HOST'] || default_opts[env.to_sym][:cfs_host]
11
- end
7
+ def self.cfs_uri
8
+ "http://#{cfs_host}"
9
+ end
12
10
 
13
- def self.cfs_host=(host)
14
- @@cfs_host = host
15
- end
11
+ def self.cfs_host
12
+ @@cfs_host ||= ENV['CFS_HOST'] || default_opts[env.to_sym][:cfs_host]
13
+ end
16
14
 
15
+ def self.cfs_host=(host)
16
+ @@cfs_host = host
17
+ end
17
18
 
18
- # DESKTOP
19
19
 
20
- def self.desktop_uri
21
- "http://#{desktop_host}"
22
- end
20
+ # DESKTOP
23
21
 
24
- def self.desktop_host
25
- @@desktop_host ||= ENV['DESKTOP_HOST'] || default_opts[env.to_sym][:desktop_host]
26
- end
22
+ def self.desktop_uri
23
+ "http://#{desktop_host}"
24
+ end
27
25
 
28
- def self.desktop_host=(host)
29
- @@desktop_host = host
30
- end
26
+ def self.desktop_host
27
+ @@desktop_host ||= ENV['DESKTOP_HOST'] || default_opts[env.to_sym][:desktop_host]
28
+ end
31
29
 
30
+ def self.desktop_host=(host)
31
+ @@desktop_host = host
32
+ end
32
33
 
33
- # THEMES
34
34
 
35
- def self.themes_uri
36
- "http://#{themes_host}"
37
- end
35
+ # THEMES
38
36
 
39
- def self.themes_host
40
- @@themes_host ||= ENV['THEMES_HOST'] || default_opts[env.to_sym][:themes_host]
41
- end
37
+ def self.themes_uri
38
+ "http://#{themes_host}"
39
+ end
42
40
 
43
- def self.themes_host=(host)
44
- @@themes_host = host
45
- end
41
+ def self.themes_host
42
+ @@themes_host ||= ENV['THEMES_HOST'] || default_opts[env.to_sym][:themes_host]
43
+ end
46
44
 
45
+ def self.themes_host=(host)
46
+ @@themes_host = host
47
+ end
47
48
 
48
- # AUTH
49
49
 
50
- # pass-in to the ExvoAuth gem
51
- def self.auth_uri
52
- if defined?(ExvoAuth::Config) and ExvoAuth::Config.respond_to?('uri')
53
- ExvoAuth::Config.uri
54
- else
55
- raise "Exvo.auth_uri method is available only when exvo-auth gem is available"
50
+ # AUTH
51
+
52
+ # pass-in to the ExvoAuth gem
53
+ def self.auth_uri
54
+ if defined?(ExvoAuth::Config) and ExvoAuth::Config.respond_to?('uri')
55
+ ExvoAuth::Config.uri
56
+ else
57
+ raise "Exvo.auth_uri method is available only when exvo-auth gem is available"
58
+ end
56
59
  end
57
- end
58
60
 
59
- def self.auth_host
60
- if defined?(ExvoAuth::Config) and ExvoAuth::Config.respond_to?('host')
61
- ExvoAuth::Config.host
62
- else
63
- raise "Exvo.auth_host method is available only when exvo-auth gem is available"
61
+ def self.auth_host
62
+ if defined?(ExvoAuth::Config) and ExvoAuth::Config.respond_to?('host')
63
+ ExvoAuth::Config.host
64
+ else
65
+ raise "Exvo.auth_host method is available only when exvo-auth gem is available"
66
+ end
64
67
  end
65
- end
66
68
 
67
69
 
68
- # ENV
70
+ # ENV
69
71
 
70
- def self.env
71
- @@env ||= Rails.env if defined?(Rails)
72
- @@env ||= Merb.env if defined?(Merb)
73
- @@env
74
- end
72
+ def self.env
73
+ @@env ||= Rails.env if defined?(Rails)
74
+ @@env ||= Merb.env if defined?(Merb)
75
+ @@env
76
+ end
75
77
 
76
- def self.env=(env)
77
- @@env = env
78
- end
78
+ def self.env=(env)
79
+ @@env = env
80
+ end
79
81
 
80
82
 
81
- private
82
-
83
- def self.default_opts
84
- {
85
- :production => {
86
- :cfs_host => 'cfs.exvo.com',
87
- :desktop_host => 'www.exvo.com',
88
- :themes_host => 'themes.exvo.com'
89
- },
90
- :staging => {
91
- :cfs_host => 'staging.cfs.exvo.com',
92
- :desktop_host => 'www.exvo.co',
93
- :themes_host => 'staging.themes.exvo.com'
94
- },
95
- :development => {
96
- :cfs_host => 'cfs.exvo.local',
97
- :desktop_host => 'www.exvo.local',
98
- :themes_host => 'themes.exvo.local'
99
- },
100
- :test => {
101
- :cfs_host => 'cfs.exvo.local',
102
- :desktop_host => 'www.exvo.local',
103
- :themes_host => 'themes.exvo.local'
83
+ private
84
+
85
+ def self.default_opts
86
+ {
87
+ :production => {
88
+ :cfs_host => 'cfs.exvo.com',
89
+ :desktop_host => 'www.exvo.com',
90
+ :themes_host => 'themes.exvo.com'
91
+ },
92
+ :staging => {
93
+ :cfs_host => 'staging.cfs.exvo.com',
94
+ :desktop_host => 'www.exvo.co',
95
+ :themes_host => 'staging.themes.exvo.com'
96
+ },
97
+ :development => {
98
+ :cfs_host => 'cfs.exvo.local',
99
+ :desktop_host => 'www.exvo.local',
100
+ :themes_host => 'themes.exvo.local'
101
+ },
102
+ :test => {
103
+ :cfs_host => 'cfs.exvo.local',
104
+ :desktop_host => 'www.exvo.local',
105
+ :themes_host => 'themes.exvo.local'
106
+ }
104
107
  }
105
- }
108
+ end
109
+
106
110
  end
111
+
107
112
  end
@@ -1,3 +1,3 @@
1
1
  module ExvoHelpers
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -6,24 +6,24 @@ describe Exvo do
6
6
  it "returns 'production' when Rails.env is set to 'production'" do
7
7
  Kernel.const_set(:Rails, Module)
8
8
  Rails.should_receive(:env).and_return('production')
9
- Exvo.env.should eql('production')
9
+ Exvo::Helpers.env.should eql('production')
10
10
  end
11
11
 
12
12
  it "allows setting env" do
13
- Exvo.env = 'test'
14
- Exvo.env.should eql('test')
15
- Exvo.env = nil
13
+ Exvo::Helpers.env = 'test'
14
+ Exvo::Helpers.env.should eql('test')
15
+ Exvo::Helpers.env = nil
16
16
  end
17
17
  end
18
18
 
19
19
  describe "host methods in production environment" do
20
20
  before do
21
- Exvo.should_receive(:env).and_return('production')
21
+ Exvo::Helpers.should_receive(:env).and_return('production')
22
22
  end
23
23
 
24
- specify { Exvo.themes_host.should eql('themes.exvo.com') }
25
- specify { Exvo.cfs_host.should eql('cfs.exvo.com') }
26
- specify { Exvo.desktop_host.should eql('www.exvo.com') }
24
+ specify { Exvo::Helpers.themes_host.should eql('themes.exvo.com') }
25
+ specify { Exvo::Helpers.cfs_host.should eql('cfs.exvo.com') }
26
+ specify { Exvo::Helpers.desktop_host.should eql('www.exvo.com') }
27
27
  end
28
28
 
29
29
  describe "ENV setting overrides the defaults" do
@@ -33,9 +33,9 @@ describe Exvo do
33
33
 
34
34
  before do
35
35
  # clear any previous memoization
36
- Exvo.cfs_host = nil
37
- Exvo.desktop_host = nil
38
- Exvo.themes_host = nil
36
+ Exvo::Helpers.cfs_host = nil
37
+ Exvo::Helpers.desktop_host = nil
38
+ Exvo::Helpers.themes_host = nil
39
39
 
40
40
  # set ENV
41
41
  ENV["CFS_HOST"] = cfs_host
@@ -43,9 +43,9 @@ describe Exvo do
43
43
  ENV["THEMES_HOST"] = themes_host
44
44
  end
45
45
 
46
- specify { Exvo.cfs_host.should eql(cfs_host) }
47
- specify { Exvo.desktop_host.should eql(desktop_host) }
48
- specify { Exvo.themes_host.should eql(themes_host) }
46
+ specify { Exvo::Helpers.cfs_host.should eql(cfs_host) }
47
+ specify { Exvo::Helpers.desktop_host.should eql(desktop_host) }
48
+ specify { Exvo::Helpers.themes_host.should eql(themes_host) }
49
49
  end
50
50
 
51
51
  describe "setting host directly overrides the defaults" do
@@ -54,14 +54,14 @@ describe Exvo do
54
54
  let(:themes_host) { "new.themes.exvo.com" }
55
55
 
56
56
  before do
57
- Exvo.cfs_host = cfs_host
58
- Exvo.desktop_host = desktop_host
59
- Exvo.themes_host = themes_host
57
+ Exvo::Helpers.cfs_host = cfs_host
58
+ Exvo::Helpers.desktop_host = desktop_host
59
+ Exvo::Helpers.themes_host = themes_host
60
60
  end
61
61
 
62
- specify { Exvo.cfs_host.should eql(cfs_host) }
63
- specify { Exvo.desktop_host.should eql(desktop_host) }
64
- specify { Exvo.themes_host.should eql(themes_host) }
62
+ specify { Exvo::Helpers.cfs_host.should eql(cfs_host) }
63
+ specify { Exvo::Helpers.desktop_host.should eql(desktop_host) }
64
+ specify { Exvo::Helpers.themes_host.should eql(themes_host) }
65
65
  end
66
66
 
67
67
  describe "auth_host/auth_uri methods which pass to the ExvoAuth gem" do
@@ -69,8 +69,8 @@ describe Exvo do
69
69
  let(:uri) { "http://#{host}"}
70
70
 
71
71
  it "raises an error when ExvoAuth is not available" do
72
- expect { Exvo.auth_uri }.to raise_error
73
- expect { Exvo.auth_host }.to raise_error
72
+ expect { Exvo::Helpers.auth_uri }.to raise_error
73
+ expect { Exvo::Helpers.auth_host }.to raise_error
74
74
  end
75
75
 
76
76
  it "passes to the ExvoAuth when it is available" do
@@ -78,10 +78,10 @@ describe Exvo do
78
78
  ExvoAuth.const_set(:Config, Module)
79
79
 
80
80
  ExvoAuth::Config.should_receive(:host).and_return(host)
81
- Exvo.auth_host.should eql(host)
81
+ Exvo::Helpers.auth_host.should eql(host)
82
82
 
83
83
  ExvoAuth::Config.should_receive(:uri).and_return(uri)
84
- Exvo.auth_uri.should eql(uri)
84
+ Exvo::Helpers.auth_uri.should eql(uri)
85
85
  end
86
86
  end
87
87
 
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.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-26 00:00:00.000000000Z
12
+ date: 2011-10-27 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &79383900 !ruby/object:Gem::Requirement
16
+ requirement: &79583560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '2.7'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *79383900
24
+ version_requirements: *79583560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard
27
- requirement: &79383640 !ruby/object:Gem::Requirement
27
+ requirement: &79583300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.8.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *79383640
35
+ version_requirements: *79583300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: guard-rspec
38
- requirement: &79383400 !ruby/object:Gem::Requirement
38
+ requirement: &79583060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 0.4.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *79383400
46
+ version_requirements: *79583060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rb-fsevent
49
- requirement: &79383210 !ruby/object:Gem::Requirement
49
+ requirement: &79582870 !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: *79383210
57
+ version_requirements: *79582870
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rb-inotify
60
- requirement: &79382980 !ruby/object:Gem::Requirement
60
+ requirement: &79582640 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *79382980
68
+ version_requirements: *79582640
69
69
  description: Ruby gem providing helper *_uri/*_host methods for Exvo services/apps
70
70
  like DESKTOP/CFS/AUTH/THEMES.
71
71
  email: