galakei 0.3.0 → 0.3.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,3 @@
1
+ .bundle
2
+ Gemfile.lock
3
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in galakei.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem 'rspec', '>= 2.5.0'
8
+ end
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler'
2
+ require 'rspec/core/rake_task'
3
+ Bundler::GemHelper.install_tasks
4
+
5
+ task :default => :spec
6
+ RSpec::Core::RakeTask.new
data/galakei.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "galakei/version"
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "galakei"
6
+ s.version = Galakei::VERSION
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Paul McMahon", "Michael Reinsch"]
9
+ s.email = "info@mobalean.com"
10
+ s.homepage = "http://www.mobalean.com"
11
+ s.summary = "Japanese feature phones support"
12
+ s.description = "Japanese feature phones (a.k.a., keitai, galakei) have a number of restrictions over normal web browsers. This library adds support for them"
13
+
14
+ s.files = `git ls-files`.split("\n")
15
+ s.require_path = 'lib'
16
+ s.rubyforge_project = "galakei"
17
+
18
+ s.add_dependency 'actionpack', '>= 3.0.3'
19
+ s.add_dependency 'rack', '>= 1.2.1'
20
+ s.add_dependency 'docomo_css', '~> 0.4.4'
21
+
22
+
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ end
25
+
data/lib/galakei.rb CHANGED
@@ -10,6 +10,7 @@ module Galakei
10
10
  autoload :HelperMethods, "galakei/helper_methods"
11
11
  autoload :InputMode, "galakei/input_mode"
12
12
  autoload :EmojiTable, "galakei/emoji_table"
13
+ autoload :SessionIdParameterInForm, "galakei/session_id_parameter_in_form"
13
14
  module Filter
14
15
  autoload :Base, "galakei/filter/base"
15
16
  autoload :ContentType, "galakei/filter/content_type"
@@ -6,11 +6,20 @@ class Galakei::Filter::SessionIdParameter < Galakei::Filter::Base
6
6
  def filter
7
7
  key = ::Rails.application.config.session_options[:key]
8
8
  if device_needs_session_param_in_url?
9
- session[:_dummy_param_to_force_session_init] = nil
10
- logger.debug("adding session param '#{key}' to default_url_options")
11
- default_url_options[key] = request.session_options[:id]
9
+ session_opts = env[ActionDispatch::Session::AbstractStore::ENV_SESSION_OPTIONS_KEY]
10
+ # if we don't have a session ID yet, create one
11
+ if session_opts[:id].blank?
12
+ # make sure to reset any active record session store,
13
+ # we'll have to create a new one for the new session
14
+ env[ActiveRecord::SessionStore::SESSION_RECORD_KEY] = nil
15
+ # create a new session ID
16
+ session_opts[:id] = ActiveSupport::SecureRandom.hex(8)
17
+ end
18
+ sid = session_opts[:id]
19
+ logger.debug("Galakei: adding session param '#{key}' to default_url_options")
20
+ default_url_options[key] = sid
12
21
  else
13
- # workaround for issue in rails 3.0.3: default_url_options aren't cleared
22
+ # default_url_options aren't cleared, so we need to clear them
14
23
  default_url_options.delete(key)
15
24
  end
16
25
  end
@@ -25,5 +34,4 @@ class Galakei::Filter::SessionIdParameter < Galakei::Filter::Base
25
34
  controller.send :default_url_options
26
35
  end
27
36
 
28
-
29
37
  end
@@ -13,6 +13,7 @@ module Galakei
13
13
  end
14
14
  ActiveSupport.on_load :action_view do
15
15
  include Galakei::InputMode
16
+ include Galakei::SessionIdParameterInForm
16
17
  end
17
18
  end
18
19
  end
@@ -0,0 +1,12 @@
1
+ module Galakei
2
+ module SessionIdParameterInForm
3
+ def extra_tags_for_form(html_options)
4
+ s = super
5
+ if html_options["method"] == "get"
6
+ key = ::Rails.application.config.session_options[:key]
7
+ s << tag(:input, :type => "hidden", :name => key, :value => request.session_options[:id])
8
+ end
9
+ s
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module Galakei
2
+ VERSION = "0.3.1"
3
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Galakei::Filter::ContentType do
4
+ before :each do
5
+ @filter = Galakei::Filter::ContentType.new
6
+ @filter.controller = mock("controller")
7
+ @request = mock("request")
8
+ @response = mock("response")
9
+ @filter.controller.stub!(:request).and_return(@request)
10
+ @filter.controller.stub!(:response).and_return(@response)
11
+ end
12
+ describe "from docomo" do
13
+ before { @request.should_receive(:docomo?).and_return(true) }
14
+ describe "content type is text/html" do
15
+ before { @response.should_receive(:content_type).and_return("text/html") }
16
+ it("should require xhtml content type") do
17
+ @filter.should be_condition
18
+ end
19
+ end
20
+ describe "content type is image/png" do
21
+ before { @response.should_receive(:content_type).and_return("image/png") }
22
+ it("should not change content type") do
23
+ @filter.should_not be_condition
24
+ end
25
+ end
26
+ describe "304 response" do
27
+ before { @response.should_receive(:content_type).and_return(nil) }
28
+ it("should not change content type") do
29
+ @filter.should_not be_condition
30
+ end
31
+ end
32
+ end
33
+ describe "from non docomo" do
34
+ before { @request.should_receive(:docomo?).and_return(false) }
35
+ it("should not change content type") do
36
+ @filter.should_not be_condition
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ %w[docomo au softbank].each do |carrier|
4
+ shared_examples_for "non-#{carrier} devices" do
5
+ it("should not be #{carrier}?") do
6
+ @request.should_not send("be_#{carrier}")
7
+ end
8
+ end
9
+ shared_examples_for "#{carrier} devices" do
10
+ it("should be #{carrier}?") do
11
+ @request.should send("be_#{carrier}")
12
+ end
13
+ it("should be galakei") { @request.should be_galakei }
14
+ end
15
+ end
16
+
17
+ describe Galakei::Request do
18
+ describe "from Firefox" do
19
+ before { @request = Rack::Request.new(env_for("Firefox")) }
20
+ it_should_behave_like "non-au devices"
21
+ it_should_behave_like "non-docomo devices"
22
+ it_should_behave_like "non-softbank devices"
23
+ it("should not be galakei") { @request.should_not be_galakei }
24
+ end
25
+
26
+ describe "from Docomo SH-06A" do
27
+ before { @request = Rack::Request.new(env_for("Docomo SH-06A")) }
28
+ it_should_behave_like "docomo devices"
29
+ it_should_behave_like "non-au devices"
30
+ it_should_behave_like "non-softbank devices"
31
+ end
32
+
33
+ describe "from AU W51SH" do
34
+ before { @request = Rack::Request.new(env_for("AU W51SH")) }
35
+ it_should_behave_like "non-docomo devices"
36
+ it_should_behave_like "non-softbank devices"
37
+ end
38
+
39
+ describe "from Vodafone 802N" do
40
+ before { @request = Rack::Request.new(env_for("Vodafone 802N")) }
41
+ it_should_behave_like "non-au devices"
42
+ it_should_behave_like "non-docomo devices"
43
+ it_should_behave_like "softbank devices"
44
+ end
45
+
46
+ describe "from Softbank 709SC" do
47
+ before { @request = Rack::Request.new(env_for("Softbank 709SC")) }
48
+ it_should_behave_like "non-au devices"
49
+ it_should_behave_like "non-docomo devices"
50
+ it_should_behave_like "softbank devices"
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ $:.unshift File.expand_path('../../lib', __FILE__)
2
+
3
+ require 'galakei'
4
+
5
+ def env_for(device_name)
6
+ user_agent = {
7
+ "Firefox" => "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.1.16) Gecko/20101130 Firefox/3.5.16",
8
+ "Docomo SH-06A" => "DoCoMo/2.0 SH06A3(c500;TB;W24H14)" ,
9
+ "AU W51SH" => "KDDI-SH32 UP.Browser/6.2.0.11.2.1 (GUI) MMP/2.0",
10
+ "Vodafone 802N" => "Vodafone/1.0/V802N/NJ001/SN*************** Browser/UP.Browser/7.0.2.1.307 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0",
11
+ "Softbank 709SC" => "SoftBank/1.0/709SC/SCJ001/SN*************** Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1"
12
+ }[device_name]
13
+ { "HTTP_USER_AGENT" => user_agent }
14
+ end
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: galakei
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 17
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
8
  - 3
8
- - 0
9
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Paul McMahon
@@ -15,7 +16,7 @@ autorequire:
15
16
  bindir: bin
16
17
  cert_chain: []
17
18
 
18
- date: 2011-03-04 00:00:00 +09:00
19
+ date: 2011-03-06 00:00:00 +09:00
19
20
  default_executable:
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
@@ -26,6 +27,7 @@ dependencies:
26
27
  requirements:
27
28
  - - ">="
28
29
  - !ruby/object:Gem::Version
30
+ hash: 1
29
31
  segments:
30
32
  - 3
31
33
  - 0
@@ -41,6 +43,7 @@ dependencies:
41
43
  requirements:
42
44
  - - ">="
43
45
  - !ruby/object:Gem::Version
46
+ hash: 29
44
47
  segments:
45
48
  - 1
46
49
  - 2
@@ -56,6 +59,7 @@ dependencies:
56
59
  requirements:
57
60
  - - ~>
58
61
  - !ruby/object:Gem::Version
62
+ hash: 7
59
63
  segments:
60
64
  - 0
61
65
  - 4
@@ -72,8 +76,13 @@ extensions: []
72
76
  extra_rdoc_files: []
73
77
 
74
78
  files:
79
+ - .gitignore
80
+ - Gemfile
75
81
  - LICENSE
76
82
  - README.md
83
+ - Rakefile
84
+ - galakei.gemspec
85
+ - lib/galakei.rb
77
86
  - lib/galakei/email.rb
78
87
  - lib/galakei/emoji_table.rb
79
88
  - lib/galakei/filter/base.rb
@@ -85,9 +94,13 @@ files:
85
94
  - lib/galakei/input_mode.rb
86
95
  - lib/galakei/railtie.rb
87
96
  - lib/galakei/request.rb
97
+ - lib/galakei/session_id_parameter_in_form.rb
88
98
  - lib/galakei/shoulda_macros.rb
89
99
  - lib/galakei/use_rack_request_to_extract_sid.rb
90
- - lib/galakei.rb
100
+ - lib/galakei/version.rb
101
+ - spec/galakei/filter/content_type_spec.rb
102
+ - spec/galakei/request_spec.rb
103
+ - spec/spec_helper.rb
91
104
  has_rdoc: true
92
105
  homepage: http://www.mobalean.com
93
106
  licenses: []
@@ -102,6 +115,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
102
115
  requirements:
103
116
  - - ">="
104
117
  - !ruby/object:Gem::Version
118
+ hash: 3
105
119
  segments:
106
120
  - 0
107
121
  version: "0"
@@ -110,12 +124,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
110
124
  requirements:
111
125
  - - ">="
112
126
  - !ruby/object:Gem::Version
127
+ hash: 3
113
128
  segments:
114
129
  - 0
115
130
  version: "0"
116
131
  requirements: []
117
132
 
118
- rubyforge_project: "[none]"
133
+ rubyforge_project: galakei
119
134
  rubygems_version: 1.3.7
120
135
  signing_key:
121
136
  specification_version: 3