stackmob 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,12 +10,12 @@ Add the following to your Gemfile and run `bundle install`:
10
10
 
11
11
  ## Configuring Your Application
12
12
 
13
- The gem requires a few configuration details that need to be added to the file `config/stackmob.yml`. You will need the name of the application you created, as well as your public and private keys for both development (sandbox) and production from the StackMob add-on dashboard.
13
+ The gem requires a few configuration details that need to be added to the file `config/stackmob.yml`. You will need the name of the application you created, as well as your public and private keys for both development (sandbox) and production from the StackMob add-on dashboard. When specifying your Heroku hostname, if your application is available under the herokuapp.com domain as well as heroku.com, use the herokuapp.com domain otherwise, use heroku.com.
14
14
 
15
15
  # example config/stackmob.yml
16
16
  sm_app_name: StackMob App Name
17
17
  sm_client_name: Your StackMob Client Name
18
- heroku_app_name: Heroku App Name
18
+ heroku_hostname: Full Hostname of Your Heroku Application (e.g. my-app.herokuapp.com)
19
19
 
20
20
  development:
21
21
  key: Your StackMob Sandbox Public Key
@@ -165,6 +165,14 @@ Deploying your Heroku application only requires one additional step. After you h
165
165
 
166
166
  This rake task will inform the StackMob servers that you have deployed a new version of your application as well as update any information that may be needed to proxy requests to your application.
167
167
 
168
+ Once your API & Application are deployed, you can, of course, start using it with the [StackMob iOS SDK](https://github.com/stackmob/StackMob_iOS) but if you would like to take things for a test drive, you can also use `StackMob::Client`. Create a client to use your production keys like the example below:
169
+
170
+ client = StackMob::Client.new(StackMob.dev_url, StackMob.app_name, StackMob::PRODUCTION, StackMob.config['production']['key'], StackMob.config['production']['secret'])
171
+
172
+ You can then proxy requests to your application using the `StackMob::Client#request`:
173
+
174
+ client.request(:get, :api, "heroku/proxy/path/to/proxy/to")
175
+
168
176
  ## Running your Application Locally in Development
169
177
 
170
178
  The railtie provided with this gem adds a simple oauth provider into the middleware stack. When making requests to your Rails or Sinatra application while its running locally you can either use the oauth gem, installed as a dependency to this one, with your public/private development keys in `config/stackmob.yml` or add the line `no_oauth: true` under the development section of the same config file. Adding the `no_oauth: true` line to `config/stackmob.yml` will only prevent verification of oauth keys locally. It will not turn off the middleware in production even if the option is specified under the production section of the config file.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
@@ -36,7 +36,9 @@ module StackMob
36
36
  def request(method, service, path, params = {})
37
37
  request_path, request_body = generate_path_and_body(method, service, path, params)
38
38
 
39
- response = @oauth_client.send(method, request_path, request_body)
39
+ args = [method, request_path, request_body]
40
+ args << {"Content-Type" => "application/json"} if [:post, :put].include?(method)
41
+ response = @oauth_client.send(*args)
40
42
 
41
43
  rcode = response.code.to_i
42
44
  if rcode >= 200 && rcode <= 299
@@ -40,7 +40,7 @@ module StackMob
40
40
 
41
41
  def sm_hostname_from_header_or_config(header_str)
42
42
  hostname = request.env[header_str]
43
- (hostname.nil? || hostname == "") ? StackMob.dev_url : hostname
43
+ (hostname.nil? || hostname == "") ? StackMob.dev_url : [StackMob.client_name, hostname].join(".")
44
44
  end
45
45
  private :sm_hostname_from_header_or_config
46
46
 
@@ -55,7 +55,8 @@ module StackMob
55
55
  private :sm_app_version
56
56
 
57
57
  def sm_normalize_host(host_str)
58
- "http://#{StackMob.client_name}.#{host_str}"
58
+ schemeless = host_str.gsub(/^https?:\/\//, "")
59
+ "http://#{schemeless}"
59
60
  end
60
61
  private :sm_normalize_host
61
62
 
@@ -19,11 +19,10 @@ namespace :stackmob do
19
19
  desc "Notify StackMob of a New Deploy"
20
20
  task :deploy do
21
21
 
22
- app_name = StackMob.config['heroku_app_name']
23
- exit("No Heroku App Name Found in StackMob Config") if app_name.blank?
24
- exit("No Client Name Found in StackMob Config") if StackMob.client_name.blank?
25
-
26
- hostname = "#{app_name}.herokuapp.com"
22
+ abort("No Client Name Found in StackMob Config") if StackMob.client_name.blank?
23
+ abort("No Heroku App Name or Hostname Found in StackMob Config") if StackMob.config['heroku_app_name'].to_s.blank? && StackMob.config['heroku_hostname'].to_s.blank?
24
+
25
+ hostname = StackMob.config['heroku_hostname'] || "#{StackMob.config['heroku_app_name']}.herokuapp.com"
27
26
  client = StackMob::Client.new("http://#{StackMob.client_name}.mob2.stackmob.com", StackMob.app_name, StackMob::SANDBOX, StackMob.config['development']['key'], StackMob.config['development']['key'])
28
27
  deployer = StackMob::Deployer.new(client)
29
28
 
data/stackmob.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{stackmob}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{StackMob}]
12
- s.date = %q{2011-08-24}
12
+ s.date = %q{2011-08-29}
13
13
  s.description = %q{Support Gem for StackMob Heroku Add-On}
14
14
  s.email = %q{jordan@stackmob.com}
15
15
  s.extra_rdoc_files = [
@@ -11,7 +11,7 @@ class StackMobIntegrationTest < MiniTest::Unit::TestCase
11
11
  end
12
12
 
13
13
  def sm_app_name
14
- "angrybirds3"
14
+ "ruby_test"
15
15
  end
16
16
 
17
17
  def setup
@@ -82,7 +82,7 @@ class StackmobClientTest < MiniTest::Unit::TestCase
82
82
  path = "user"
83
83
  @good_resp.stubs(:code).returns(201)
84
84
 
85
- valid_client._oauth.expects(:post).with("/#{service}/#{app_vsn}/#{app_name}/#{path}", Yajl::Encoder.encode(test_params)).returns(@good_resp)
85
+ valid_client._oauth.expects(:post).with("/#{service}/#{app_vsn}/#{app_name}/#{path}", Yajl::Encoder.encode(test_params), "Content-Type" => "application/json").returns(@good_resp)
86
86
  valid_client.request(:post, service, path, test_params)
87
87
  end
88
88
 
@@ -98,7 +98,7 @@ class StackmobClientTest < MiniTest::Unit::TestCase
98
98
  service = :some_service
99
99
  path = "abc"
100
100
 
101
- valid_client._oauth.expects(:put).with("/#{service}/#{app_vsn}/#{app_name}/#{path}", Yajl::Encoder.encode(test_params)).returns(@good_resp)
101
+ valid_client._oauth.expects(:put).with("/#{service}/#{app_vsn}/#{app_name}/#{path}", Yajl::Encoder.encode(test_params), "Content-Type" => "application/json").returns(@good_resp)
102
102
  valid_client.request(:put, service, path, test_params)
103
103
  end
104
104
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stackmob
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 0
10
- version: 0.0.0
9
+ - 1
10
+ version: 0.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - StackMob
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-08-24 00:00:00 Z
18
+ date: 2011-08-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  type: :runtime