module StackMob

Copyright 2011 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.

Copyright 2011 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.

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.

Copyright 2011 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.

Constants

CONFIG_FILES
PRODUCTION
SANDBOX

Public Class Methods

app_name() click to toggle source
# File lib/stackmob.rb, line 59
def self.app_name
  ENV['STACKMOB_APP_NAME'] || StackMob.config['sm_app_name']
end
client_name() click to toggle source
# File lib/stackmob.rb, line 63
def self.client_name
  ENV['STACKMOB_CLIENT_NAME'] || StackMob.config['sm_client_name']
end
config() click to toggle source
# File lib/stackmob.rb, line 36
def self.config
  @config ||= load_config(CONFIG_FILES.clone)

end
dev_url() click to toggle source
# 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() click to toggle source
# File lib/stackmob.rb, line 85
def self.env
  (is_production?) ? PRODUCTION : SANDBOX
end
is_html5?() click to toggle source
# File lib/stackmob.rb, line 93
def self.is_html5?
  config['html5']
end
is_production?() click to toggle source
# File lib/stackmob.rb, line 97
def self.is_production?
  ENV["RACK_ENV"] == "production"
end
key() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# 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() click to toggle source
# 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) click to toggle source
# 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() click to toggle source
# File lib/stackmob.rb, line 89
def self.sm_env_str
  env == PRODUCTION ? "production" : "development"
end