Skip to content
Browse files

OpensocialWap::Config::Urlで、container_hostを指定できるよう変更

  • Loading branch information...
1 parent 7e845d2 commit b81f2b50fd4af140fc38c253e3962f0f696b5033 @bananagi bananagi committed
View
24 lib/opensocial-wap/config/url.rb
@@ -12,25 +12,43 @@ def configure(&blk)
self
end
+ def container_host(host = nil)
+ if host
+ @container_host = host
+ end
+ @container_host
+ end
+
def default(options = nil)
if options
@default = options
end
- @default
+ assure_container_host(@default)
end
def redirect(options = nil)
if options
@redirect = options
end
- @redirect || @default
+ @redirect ? assure_container_host(@redirect) : default
end
def public_path(options = nil)
if options
@public_path = options
end
- @public_path || @default
+ @public_path ? assure_container_host(@public_path) : default
+ end
+
+ private
+
+ # options の :format が :full で、かつ :container_host が
+ # 指定されていないときに、@container_host をセットする.
+ def assure_container_host(options)
+ if options[:format] == :full && options[:container_host].nil?
+ options[:container_host] = @container_host
+ end
+ options
end
end
end
View
7 lib/opensocial-wap/platform/gree.rb
@@ -22,9 +22,10 @@ def gree(config, &block)
helper_class OpensocialWap::OAuth::Helpers::BasicHelper
end
@config.opensocial_wap.url = OpensocialWap::Config::Url.configure do
- default :format => :query, :params => { :guid => 'ON' }
- redirect :format => :local
- public_path :format => :local
+ container_host container_host
+ default :format => :query, :params => { :guid => 'ON' }
+ redirect :format => :local
+ public_path :format => :local
end
@config.opensocial_wap.session_id = @session ? :parameter : :cookie
end
View
7 lib/opensocial-wap/platform/mixi.rb
@@ -22,9 +22,10 @@ def mixi(config, &block)
helper_class OpensocialWap::OAuth::Helpers::BasicHelper
end
@config.opensocial_wap.url = OpensocialWap::Config::Url.configure do
- default :format => :query, :params => { :guid => 'ON' }
- redirect :format => :full, :container_host => container_host, :params => { :guid => 'ON' }
- public_path :format => :local
+ container_host container_host
+ default :format => :query, :params => { :guid => 'ON' }
+ redirect :format => :full, :params => { :guid => 'ON' }
+ public_path :format => :local
end
@config.opensocial_wap.session_id = @session ? :parameter : :cookie
end
View
7 lib/opensocial-wap/platform/mobage.rb
@@ -24,9 +24,10 @@ def mobage(config, &block)
helper_class OpensocialWap::OAuth::Helpers::MobageHelper
end
@config.opensocial_wap.url = OpensocialWap::Config::Url.configure do
- default :format => :query, :params => { :guid => 'ON' }
- redirect :format => :local
- public_path :format => :local
+ container_host container_host
+ default :format => :query, :params => { :guid => 'ON' }
+ redirect :format => :local
+ public_path :format => :local
end
@config.opensocial_wap.session_id = @session ? :parameter : :cookie
end
View
2 spec/config/url_spec.rb
@@ -6,11 +6,13 @@ module Config
it do
config = ::OpensocialWap::Config::Url.configure do
+ container_host 'c.example.com'
default :format => :full, :container_host => 'c.example.com', :params => { :guid => 'ON' }
redirect :format => :query, :params => { :guid => 'ON' }
public_path :format => :plain
end
+ config.container_host.should == 'c.example.com'
config.default.should == {:format => :full, :container_host => 'c.example.com', :params => { :guid => 'ON' }}
config.redirect.should == { :format => :query, :params => { :guid => 'ON' }}
config.public_path.should == { :format => :plain }
View
2 spec/platform/gree_spec.rb
@@ -17,6 +17,7 @@
c.opensocial_wap.oauth.helper_class.consumer_key.should == '1234'
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://os-sb.gree.jp/api/rest/'
+ c.opensocial_wap.url.container_host == 'mgadget-sb.gree.jp'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :local}
c.opensocial_wap.url.public_path.should == {:format => :local}
@@ -37,6 +38,7 @@
c.opensocial_wap.oauth.helper_class.consumer_key.should == '1234'
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://os.gree.jp/api/rest/'
+ c.opensocial_wap.url.container_host == 'mgadget.gree.jp'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :local}
c.opensocial_wap.url.public_path.should == {:format => :local}
View
2 spec/platform/mixi_spec.rb
@@ -16,6 +16,7 @@
c.opensocial_wap.oauth.helper_class.consumer_key.should == '1234'
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://api.mixi-platform.com/os/0.8/'
+ c.opensocial_wap.url.container_host.should == 'ma.mixi.net'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :full, :container_host => 'ma.mixi.net', :params => { :guid => 'ON' } }
c.opensocial_wap.url.public_path.should == {:format => :local}
@@ -36,6 +37,7 @@
c.opensocial_wap.oauth.helper_class.consumer_key.should == '1234'
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://api.mixi-platform.com/os/0.8/'
+ c.opensocial_wap.url.container_host.should == 'ma.test.mixi.net'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :full, :container_host => 'ma.test.mixi.net', :params => { :guid => 'ON' } }
c.opensocial_wap.url.public_path.should == {:format => :local}
View
2 spec/platform/mobage_spec.rb
@@ -19,6 +19,7 @@
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://sb.app.mbga.jp/api/restful/v1/'
c.opensocial_wap.oauth.helper_class.app_id.should == '9999'
+ c.opensocial_wap.url.container_host 'sb.pf.mbga.jp'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :local}
c.opensocial_wap.url.public_path.should == {:format => :local}
@@ -41,6 +42,7 @@
c.opensocial_wap.oauth.helper_class.consumer_secret.should == 'abcd'
c.opensocial_wap.oauth.helper_class.api_endpoint.should == 'http://app.mbga.jp/api/restful/v1/'
c.opensocial_wap.oauth.helper_class.app_id.should == '9999'
+ c.opensocial_wap.url.container_host 'pf.mbga.jp'
c.opensocial_wap.url.default.should == {:format => :query, :params => { :guid => 'ON' }}
c.opensocial_wap.url.redirect.should == {:format => :local}
c.opensocial_wap.url.public_path.should == {:format => :local}
View
3 spec/rails3/app_root/config/environments/in_memory.rb
@@ -46,7 +46,8 @@
end
config.opensocial_wap.url = OpensocialWap::Config::Url.configure do
- default :format => :full, :container_host => 'container.example.com', :params => { :guid => 'ON' }
+ container_host 'container.example.com'
+ default :format => :full, :params => { :guid => 'ON' }
redirect :format => :query, :params => { :guid => 'ON' }
public_path :format => :plain
end

0 comments on commit b81f2b5

Please sign in to comment.
Something went wrong with that request. Please try again.