Module: StackMob
- Defined in:
- lib/stackmob/push.rb,
lib/stackmob.rb,
lib/stackmob/client.rb,
lib/stackmob/helpers.rb,
lib/stackmob/railtie.rb,
lib/stackmob/sinatra.rb,
lib/stackmob/cli/main.rb,
lib/stackmob/deployer.rb,
lib/stackmob/data_store.rb,
lib/stackmob/cli/local_server.rb,
lib/stackmob/middleware/proxy.rb,
lib/stackmob/middleware/rewrite.rb,
lib/stackmob/rack/simple_oauth_provider.rb
Overview
Copyright 2012 StackMob
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Defined Under Namespace
Modules: CLI, Helpers, Middleware, Rack
Classes: Client, ConfigurationError, DataStore, Deployer, Push, Railtie
Constant Summary
collapse
- CONFIG_FILES =
["config/stackmob.yml",".stackmob"]
- SANDBOX =
0
- PRODUCTION =
1
Class Method Summary
collapse
Class Method Details
.app_name ⇒ Object
59
60
61
|
# File 'lib/stackmob.rb', line 59
def self.app_name
ENV['STACKMOB_APP_NAME'] || StackMob.config['sm_app_name']
end
|
.client_name ⇒ Object
63
64
65
|
# File 'lib/stackmob.rb', line 63
def self.client_name
ENV['STACKMOB_CLIENT_NAME'] || StackMob.config['sm_client_name']
end
|
.config ⇒ Object
36
37
38
39
|
# File 'lib/stackmob.rb', line 36
def self.config
@config ||= load_config(CONFIG_FILES.clone)
end
|
.dev_url ⇒ Object
67
68
69
70
71
72
73
74
|
# File 'lib/stackmob.rb', line 67
def self.dev_url
if env_url = ENV['STACKMOB_DEV_URL']
env_url
else
cluster_name = (is_html5?) ? "mob1" : "mob2"
"http://#{StackMob.client_name}.#{cluster_name}.stackmob.com"
end
end
|
.env ⇒ Object
85
86
87
|
# File 'lib/stackmob.rb', line 85
def self.env
(is_production?) ? PRODUCTION : SANDBOX
end
|
.is_html5? ⇒ Boolean
93
94
95
|
# File 'lib/stackmob.rb', line 93
def self.is_html5?
config['html5']
end
|
.is_production? ⇒ Boolean
97
98
99
|
# File 'lib/stackmob.rb', line 97
def self.is_production?
ENV["RACK_ENV"] == "production"
end
|
.key ⇒ Object
55
56
57
|
# File 'lib/stackmob.rb', line 55
def self.key
ENV[sm_env_key_str(:public_key)] || StackMob.config[sm_env_str]['key']
end
|
.load_config(filenames) ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/stackmob.rb', line 41
def self.load_config(filenames)
YAML.load_file(filenames.shift)
rescue Errno::ENOENT
if !filenames.empty?
load_config(filenames)
else
raise ConfigurationError.new("Missing configuration file (#{CONFIG_FILES.join(' or ')})")
end
end
|
.plain_proxy_host ⇒ Object
76
77
78
79
80
81
82
83
|
# File 'lib/stackmob.rb', line 76
def self.plain_proxy_host
if env_url = ENV['STACKMOB_DEV_URL']
env_url.sub(/^.*:\/\//, "")
else
cluster_name = (is_html5?) ? "mob1" : "mob2"
"api.#{cluster_name}.stackmob.com"
end
end
|
.secret ⇒ Object
51
52
53
|
# File 'lib/stackmob.rb', line 51
def self.secret
ENV[sm_env_key_str(:private_key)] || StackMob.config[sm_env_str]['secret']
end
|
.sm_env_key_str(suffix) ⇒ Object
101
102
103
|
# File 'lib/stackmob.rb', line 101
def self.sm_env_key_str(suffix)
"STACKMOB_" + ((is_production?) ? "PROD" : "SAND") + "_#{suffix.to_s.upcase}"
end
|
.sm_env_str ⇒ Object
89
90
91
|
# File 'lib/stackmob.rb', line 89
def self.sm_env_str
env == PRODUCTION ? "production" : "development"
end
|