exvo_helpers 0.0.1

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 ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in exvo_helpers.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Exvo Helpers
2
+
3
+ Ruby gem providing helper methods for various Exvo apps/services. It takes into account the Rails.env (or Merb.env). Also allows overwriting of the defaults by ENV variables (and directly too, see below).
4
+
5
+ ## Examples
6
+
7
+ Results are from the 'development' Rails environment:
8
+
9
+ ```ruby
10
+ Exvo.cfs_host => 'cfs.exvo.local'
11
+ Exvo.desktop_host => 'www.exvo.local'
12
+ Exvo.themes_host => 'themes.exvo.local'
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'
17
+ ```
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):
20
+
21
+ ```ruby
22
+ Exvo.auth_host => 'exvo.auth.local'
23
+ Exvo.auth_uri => 'http://exvo.auth.local'
24
+ ```
25
+
26
+
27
+ ## Overwriting
28
+
29
+ There are two ways to do it. One is by the means of ENV variables (preferred one):
30
+
31
+ ```ruby
32
+ ENV['CFS_HOST'] = 'test.cfs.exvo.com'
33
+ ENV['DESKTOP_HOST'] = 'test.exvo.com'
34
+ ENV['THEMES_HOST'] = 'test.themes.exvo.com'
35
+ ```
36
+
37
+ The other one is to set it in the application's config file:
38
+
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'
43
+ ```
44
+
45
+
46
+
47
+ Copyright © 2011 Exvo.com Development BV
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "exvo_helpers/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "exvo_helpers"
7
+ s.version = ExvoHelpers::VERSION
8
+ s.authors = ["Paweł Gościcki"]
9
+ s.email = ["pawel.goscicki@gmail.com"]
10
+ s.homepage = "https://github.com/Exvo/exvo_helpers/"
11
+ s.summary = %q{host/uri helper methods for various Exvo services}
12
+ s.description = %q{Ruby gem providing helper *_uri/*_host methods for Exvo services/apps like DESKTOP/CFS/AUTH/THEMES.}
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
16
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
+ s.require_paths = ["lib"]
18
+
19
+ s.add_development_dependency 'rspec', ['>= 2.7']
20
+ s.add_development_dependency 'guard', ['>= 0.8.0']
21
+ s.add_development_dependency 'guard-rspec', ['>= 0.4.0']
22
+ s.add_development_dependency "rb-fsevent"
23
+ s.add_development_dependency "rb-inotify"
24
+ end
@@ -0,0 +1,107 @@
1
+ module Exvo
2
+
3
+ # CFS
4
+
5
+ def self.cfs_uri
6
+ "http://#{cfs_host}"
7
+ end
8
+
9
+ def self.cfs_host
10
+ @@cfs_host ||= ENV['CFS_HOST'] || default_opts[env.to_sym][:cfs_host]
11
+ end
12
+
13
+ def self.cfs_host=(host)
14
+ @@cfs_host = host
15
+ end
16
+
17
+
18
+ # DESKTOP
19
+
20
+ def self.desktop_uri
21
+ "http://#{desktop_host}"
22
+ end
23
+
24
+ def self.desktop_host
25
+ @@desktop_host ||= ENV['DESKTOP_HOST'] || default_opts[env.to_sym][:desktop_host]
26
+ end
27
+
28
+ def self.desktop_host=(host)
29
+ @@desktop_host = host
30
+ end
31
+
32
+
33
+ # THEMES
34
+
35
+ def self.themes_uri
36
+ "http://#{themes_host}"
37
+ end
38
+
39
+ def self.themes_host
40
+ @@themes_host ||= ENV['THEMES_HOST'] || default_opts[env.to_sym][:themes_host]
41
+ end
42
+
43
+ def self.themes_host=(host)
44
+ @@themes_host = host
45
+ end
46
+
47
+
48
+ # AUTH
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"
56
+ end
57
+ end
58
+
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"
64
+ end
65
+ end
66
+
67
+
68
+ # ENV
69
+
70
+ def self.env
71
+ @@env ||= Rails.env if defined?(Rails)
72
+ @@env ||= Merb.env if defined?(Merb)
73
+ @@env
74
+ end
75
+
76
+ def self.env=(env)
77
+ @@env = env
78
+ end
79
+
80
+
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'
104
+ }
105
+ }
106
+ end
107
+ end
@@ -0,0 +1,3 @@
1
+ module ExvoHelpers
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,2 @@
1
+ require "exvo_helpers/version"
2
+ require "exvo_helpers/helpers"
@@ -0,0 +1,88 @@
1
+ require 'spec_helper'
2
+
3
+ describe Exvo do
4
+
5
+ describe ".env class method" do
6
+ it "returns 'production' when Rails.env is set to 'production'" do
7
+ Kernel.const_set(:Rails, Module)
8
+ Rails.should_receive(:env).and_return('production')
9
+ Exvo.env.should eql('production')
10
+ end
11
+
12
+ it "allows setting env" do
13
+ Exvo.env = 'test'
14
+ Exvo.env.should eql('test')
15
+ Exvo.env = nil
16
+ end
17
+ end
18
+
19
+ describe "host methods in production environment" do
20
+ before do
21
+ Exvo.should_receive(:env).and_return('production')
22
+ end
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') }
27
+ end
28
+
29
+ describe "ENV setting overrides the defaults" do
30
+ let(:cfs_host) { "test.cfs.exvo.com" }
31
+ let(:desktop_host) { "test.exvo.com" }
32
+ let(:themes_host) { "test.themes.exvo.com" }
33
+
34
+ before do
35
+ # clear any previous memoization
36
+ Exvo.cfs_host = nil
37
+ Exvo.desktop_host = nil
38
+ Exvo.themes_host = nil
39
+
40
+ # set ENV
41
+ ENV["CFS_HOST"] = cfs_host
42
+ ENV["DESKTOP_HOST"] = desktop_host
43
+ ENV["THEMES_HOST"] = themes_host
44
+ end
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) }
49
+ end
50
+
51
+ describe "setting host directly overrides the defaults" do
52
+ let(:cfs_host) { "new.cfs.exvo.com" }
53
+ let(:desktop_host) { "new.exvo.com" }
54
+ let(:themes_host) { "new.themes.exvo.com" }
55
+
56
+ before do
57
+ Exvo.cfs_host = cfs_host
58
+ Exvo.desktop_host = desktop_host
59
+ Exvo.themes_host = themes_host
60
+ end
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) }
65
+ end
66
+
67
+ describe "auth_host/auth_uri methods which pass to the ExvoAuth gem" do
68
+ let(:host) { 'new.auth.exvo.com' }
69
+ let(:uri) { "http://#{host}"}
70
+
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
74
+ end
75
+
76
+ it "passes to the ExvoAuth when it is available" do
77
+ Kernel.const_set(:ExvoAuth, Module)
78
+ ExvoAuth.const_set(:Config, Module)
79
+
80
+ ExvoAuth::Config.should_receive(:host).and_return(host)
81
+ Exvo.auth_host.should eql(host)
82
+
83
+ ExvoAuth::Config.should_receive(:uri).and_return(uri)
84
+ Exvo.auth_uri.should eql(uri)
85
+ end
86
+ end
87
+
88
+ end
@@ -0,0 +1,8 @@
1
+ $:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $:.unshift(File.dirname(__FILE__))
3
+
4
+ require 'exvo_helpers'
5
+
6
+ RSpec.configure do |config|
7
+ config.mock_with :rspec
8
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: exvo_helpers
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Paweł Gościcki
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-26 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: &79383900 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '2.7'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *79383900
25
+ - !ruby/object:Gem::Dependency
26
+ name: guard
27
+ requirement: &79383640 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.8.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *79383640
36
+ - !ruby/object:Gem::Dependency
37
+ name: guard-rspec
38
+ requirement: &79383400 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 0.4.0
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *79383400
47
+ - !ruby/object:Gem::Dependency
48
+ name: rb-fsevent
49
+ requirement: &79383210 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *79383210
58
+ - !ruby/object:Gem::Dependency
59
+ name: rb-inotify
60
+ requirement: &79382980 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *79382980
69
+ description: Ruby gem providing helper *_uri/*_host methods for Exvo services/apps
70
+ like DESKTOP/CFS/AUTH/THEMES.
71
+ email:
72
+ - pawel.goscicki@gmail.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - README.md
80
+ - Rakefile
81
+ - exvo_helpers.gemspec
82
+ - lib/exvo_helpers.rb
83
+ - lib/exvo_helpers/helpers.rb
84
+ - lib/exvo_helpers/version.rb
85
+ - spec/exvo_helpers/helpers_spec.rb
86
+ - spec/spec_helper.rb
87
+ homepage: https://github.com/Exvo/exvo_helpers/
88
+ licenses: []
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ required_rubygems_version: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubyforge_project:
107
+ rubygems_version: 1.8.10
108
+ signing_key:
109
+ specification_version: 3
110
+ summary: host/uri helper methods for various Exvo services
111
+ test_files: []