jpmobile 5.0.0 → 5.0.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.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -3
  3. data/.rubocop.yml +123 -0
  4. data/CONTRIBUTING.md +16 -14
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +198 -0
  7. data/README.md +409 -0
  8. data/Rakefile +9 -9
  9. data/circle.yml +14 -0
  10. data/jpmobile.gemspec +9 -10
  11. data/lib/jpmobile.rb +6 -5
  12. data/lib/jpmobile/datum_conv.rb +35 -35
  13. data/lib/jpmobile/docomo_guid.rb +7 -8
  14. data/lib/jpmobile/email.rb +12 -12
  15. data/lib/jpmobile/emoticon.rb +85 -76
  16. data/lib/jpmobile/emoticon/au.rb +1284 -1284
  17. data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
  18. data/lib/jpmobile/emoticon/docomo.rb +252 -252
  19. data/lib/jpmobile/emoticon/google.rb +9 -9
  20. data/lib/jpmobile/emoticon/softbank.rb +471 -471
  21. data/lib/jpmobile/emoticon/unicode.rb +9 -9
  22. data/lib/jpmobile/emoticon/z_combine.rb +20 -23
  23. data/lib/jpmobile/encoding.rb +1 -1
  24. data/lib/jpmobile/fallback_view_selector.rb +2 -3
  25. data/lib/jpmobile/filter.rb +44 -47
  26. data/lib/jpmobile/helpers.rb +38 -38
  27. data/lib/jpmobile/hook_action_view.rb +7 -7
  28. data/lib/jpmobile/hook_test_request.rb +0 -1
  29. data/lib/jpmobile/lookup_context.rb +1 -2
  30. data/lib/jpmobile/mail.rb +156 -134
  31. data/lib/jpmobile/mailer.rb +4 -4
  32. data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
  33. data/lib/jpmobile/mobile/android.rb +0 -1
  34. data/lib/jpmobile/mobile/android_tablet.rb +0 -1
  35. data/lib/jpmobile/mobile/au.rb +40 -28
  36. data/lib/jpmobile/mobile/black_berry.rb +0 -1
  37. data/lib/jpmobile/mobile/ddipocket.rb +1 -2
  38. data/lib/jpmobile/mobile/docomo.rb +47 -36
  39. data/lib/jpmobile/mobile/emobile.rb +1 -2
  40. data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
  41. data/lib/jpmobile/mobile/ipad.rb +0 -1
  42. data/lib/jpmobile/mobile/iphone.rb +0 -1
  43. data/lib/jpmobile/mobile/smart_phone.rb +0 -1
  44. data/lib/jpmobile/mobile/softbank.rb +24 -20
  45. data/lib/jpmobile/mobile/tablet.rb +0 -1
  46. data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
  47. data/lib/jpmobile/mobile/vodafone.rb +0 -1
  48. data/lib/jpmobile/mobile/willcom.rb +7 -7
  49. data/lib/jpmobile/mobile/windows_phone.rb +0 -1
  50. data/lib/jpmobile/path_set.rb +1 -1
  51. data/lib/jpmobile/position.rb +30 -14
  52. data/lib/jpmobile/rack/filter.rb +4 -4
  53. data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
  54. data/lib/jpmobile/rack/params_filter.rb +7 -6
  55. data/lib/jpmobile/rails.rb +3 -4
  56. data/lib/jpmobile/request_with_mobile.rb +9 -6
  57. data/lib/jpmobile/resolver.rb +23 -17
  58. data/lib/jpmobile/session/active_record_store.rb +7 -9
  59. data/lib/jpmobile/session/mem_cache_store.rb +7 -9
  60. data/lib/jpmobile/sinatra.rb +1 -1
  61. data/lib/jpmobile/trans_sid.rb +15 -20
  62. data/lib/jpmobile/util.rb +61 -77
  63. data/lib/jpmobile/version.rb +1 -1
  64. data/lib/tasks/jpmobile_tasks.rake +35 -28
  65. data/spec/rack/jpmobile/android_spec.rb +5 -5
  66. data/spec/rack/jpmobile/au_spec.rb +74 -59
  67. data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
  68. data/spec/rack/jpmobile/docomo_spec.rb +77 -64
  69. data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
  70. data/spec/rack/jpmobile/filter_spec.rb +149 -128
  71. data/spec/rack/jpmobile/iphone_spec.rb +9 -8
  72. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
  73. data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
  74. data/spec/rack/jpmobile/softbank_spec.rb +49 -42
  75. data/spec/rack/jpmobile/willcom_spec.rb +22 -18
  76. data/spec/rack/jpmobile/windows_phone.rb +5 -5
  77. data/spec/rack_helper.rb +9 -8
  78. data/spec/spec_helper.rb +5 -6
  79. data/spec/unit/decorated_mail_spec.rb +8 -9
  80. data/spec/unit/email_spec.rb +44 -44
  81. data/spec/unit/emoticon_spec.rb +57 -58
  82. data/spec/unit/encoding_spec.rb +35 -36
  83. data/spec/unit/is_carrier_spec.rb +49 -49
  84. data/spec/unit/mail_spec.rb +153 -143
  85. data/spec/unit/mobile/iphone_spec.rb +6 -7
  86. data/spec/unit/receive_mail_spec.rb +172 -173
  87. data/spec/unit/spec_helper.rb +6 -6
  88. data/spec/unit/util_spec.rb +125 -46
  89. data/spec/unit/valid_ip_spec.rb +35 -35
  90. data/spec/unit/variants_spec.rb +18 -19
  91. data/test/rails/overrides/Gemfile +54 -0
  92. data/test/rails/overrides/Gemfile.jpmobile +1 -2
  93. data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
  94. data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
  95. data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
  96. data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
  97. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  98. data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
  99. data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
  100. data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
  101. data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
  102. data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
  103. data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
  104. data/test/rails/overrides/autotest/discover.rb +2 -2
  105. data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
  106. data/test/rails/overrides/config/routes.rb +95 -2
  107. data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
  108. data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
  109. data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
  110. data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
  111. data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
  112. data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
  113. data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
  114. data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
  115. data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
  116. data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
  117. data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
  118. data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
  119. data/test/rails/overrides/spec/rails_helper.rb +1 -1
  120. data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
  121. data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
  122. data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
  123. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
  124. data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
  125. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
  126. data/test/sinatra/test/filter_test.rb +10 -11
  127. data/tools/e4u_conv.rb +0 -1
  128. metadata +18 -14
  129. data/README +0 -0
  130. data/README.rdoc +0 -308
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5f668491cdbb74dbda3097c3f29cdca5ca96914
4
- data.tar.gz: 1f7e1e706fceb0454845f96dfe2fe01608b17321
3
+ metadata.gz: 0a59b2d91b6623e62be44818ffad569c1a30bb3f
4
+ data.tar.gz: a4737c7bfa0e802747202254c43162022213c3c0
5
5
  SHA512:
6
- metadata.gz: 40b8a4b05cb91e7048c288fd8d2e8dbe4a37dd4f2249cfe4695b9393492dd2db8dae05e9ca18d86791b0640e910b9771340dc2e2bf7edafcee7c80e4ce3b9318
7
- data.tar.gz: 29994a9633e0c2a97a69e1f06b7edf633623ee8b395eb633a3fd9dbceeda77bf81b20212615f7c35b718d357641ff3fec352f95c9e0378e301c24ba6aacf981c
6
+ metadata.gz: 478a46e5f1d336ad58d7cf51605cd51fe11c5e5159b507e7c602d054d2bd953d1939b713b130bae46a5f1425afd921470dcf37e133042d149269a2ec7d614776
7
+ data.tar.gz: 40699b70bfb7eeefc58dc071effa2abcafae6484ab0a59adb0f84e793313a8e15e63ef5e24b9ce6d861415f97bbda074ae908ad69e465968e4d2e3a0a100b870
data/.gitignore CHANGED
@@ -2,8 +2,6 @@ doc
2
2
  tmp
3
3
  pkg
4
4
  .bundle
5
- Gemfile
6
- Gemfile.lock
7
5
  vendor
8
6
  *.gem
9
7
  *.rbc
@@ -17,4 +15,5 @@ rdoc
17
15
  spec/reports
18
16
  test/tmp
19
17
  test/version_tmp
20
- .ruby-version
18
+ .ruby-version
19
+ .envrc
@@ -0,0 +1,123 @@
1
+ inherit_gem:
2
+ onkcop:
3
+ - "config/rubocop.yml"
4
+ # uncomment if use rails cops
5
+ # - "config/rails.yml"
6
+ # uncomment if use rspec cops
7
+ # - "config/rspec.yml"
8
+
9
+ AllCops:
10
+ TargetRubyVersion: 2.3
11
+ Exclude:
12
+ - 'bin/bundle'
13
+ - 'bin/rails'
14
+ - 'bin/rake'
15
+ - 'db/schema.rb'
16
+ - 'vendor/bundle/**/*'
17
+ - 'tools/**/*'
18
+ - 'test/rails/rails_root/**/*'
19
+ - 'vendor/jpmobile-*/**/*'
20
+
21
+ Style/StringLiterals:
22
+ EnforcedStyle: single_quotes
23
+
24
+ Style/Semicolon:
25
+ AllowAsExpressionSeparator: true
26
+
27
+ Style/BlockDelimiters:
28
+ FunctionalMethods:
29
+ - before
30
+ - let
31
+ - let!
32
+ - subject
33
+ - watch
34
+ - expect
35
+ Exclude:
36
+ # For support original style
37
+ - 'lib/jpmobile/resolver.rb'
38
+ - 'lib/jpmobile/mail.rb'
39
+ EnforcedStyle: braces_for_chaining
40
+
41
+ Style/IndentationConsistency:
42
+ EnforcedStyle: normal
43
+
44
+ Style/AccessorMethodName:
45
+ Exclude:
46
+ - 'lib/jpmobile/mail.rb'
47
+
48
+ Style/BlockComments:
49
+ Exclude:
50
+ - 'test/rails/overrides/spec/spec_helper.rb'
51
+
52
+ Metrics/AbcSize:
53
+ Exclude:
54
+ - 'lib/jpmobile/datum_conv.rb'
55
+ - 'lib/jpmobile/emoticon.rb'
56
+ - 'lib/jpmobile/helpers.rb'
57
+ - 'lib/jpmobile/mail.rb'
58
+ - 'lib/jpmobile/mobile/*'
59
+ - 'lib/jpmobile/fallback_view_selector.rb'
60
+ - 'lib/jpmobile/resolver.rb'
61
+ - 'lib/jpmobile/rack/filter.rb'
62
+
63
+ Metrics/CyclomaticComplexity:
64
+ Exclude:
65
+ - 'lib/jpmobile/emoticon.rb'
66
+ - 'lib/jpmobile/helpers.rb'
67
+ - 'lib/jpmobile/mail.rb'
68
+ - 'lib/jpmobile/mobile/au.rb'
69
+ - 'lib/jpmobile/mobile/docomo.rb'
70
+
71
+ Metrics/PerceivedComplexity:
72
+ Exclude:
73
+ - 'lib/jpmobile/emoticon.rb'
74
+ - 'lib/jpmobile/helpers.rb'
75
+ - 'lib/jpmobile/mail.rb'
76
+ - 'lib/jpmobile/mobile/au.rb'
77
+ - 'lib/jpmobile/mobile/docomo.rb'
78
+ - 'lib/jpmobile/trans_sid.rb'
79
+
80
+ Metrics/LineLength:
81
+ Exclude:
82
+ - '**/*_spec.rb'
83
+ - 'lib/jpmobile/emoticon/z_combine.rb'
84
+ - 'lib/jpmobile/hook_action_view.rb'
85
+ - 'lib/jpmobile/mobile/au.rb'
86
+ - 'lib/jpmobile/mobile/emobile.rb'
87
+
88
+ Metrics/ModuleLength:
89
+ Exclude:
90
+ - 'lib/jpmobile/emoticon.rb'
91
+ - 'lib/jpmobile/helpers.rb'
92
+ - 'lib/jpmobile/util.rb'
93
+
94
+ Metrics/BlockLength:
95
+ Exclude:
96
+ - '**/*_spec.rb'
97
+ - 'lib/jpmobile/emoticon.rb'
98
+ - 'lib/tasks/jpmobile_tasks.rake'
99
+ - 'test/rails/overrides/config/routes.rb'
100
+
101
+ Metrics/BlockNesting:
102
+ Exclude:
103
+ - 'lib/jpmobile/trans_sid.rb'
104
+
105
+ Metrics/ClassLength:
106
+ Exclude:
107
+ - 'lib/jpmobile/filter.rb'
108
+ - 'lib/jpmobile/mail.rb'
109
+ - 'lib/jpmobile/mobile/abstract_mobile.rb'
110
+ - 'lib/jpmobile/mobile/docomo.rb'
111
+
112
+ Metrics/MethodLength:
113
+ Exclude:
114
+ - 'lib/jpmobile/emoticon.rb'
115
+ - 'lib/jpmobile/helpers.rb'
116
+ - 'lib/jpmobile/mail.rb'
117
+ - 'lib/jpmobile/resolver.rb'
118
+
119
+ Lint/HandleExceptions:
120
+ Exclude:
121
+ - 'lib/jpmobile/emoticon.rb'
122
+ - 'lib/jpmobile/fallback_view_selector.rb'
123
+ - 'lib/jpmobile/position.rb'
@@ -10,19 +10,21 @@ $ git clone git@github.com:jpmobile/jpmobile-ipaddresses.git
10
10
  $ git clone git@github.com:jpmobile/jpmobile-terminfo.git
11
11
  ```
12
12
 
13
+ ## SMTPサーバの準備
14
+ SMTP通信を行うテストが含まれており、現時点では[mailtrap](https://mailtrap.io/)を利用しています。
15
+
16
+ 以下のように環境変数を設定してテストを実行してください。
17
+
18
+ ```
19
+ export MAILTRAP_USERNAME=XXXXXXXXXXXXXX
20
+ export MAILTRAP_PASSWORD=YYYYYYYYYYYYYY
21
+ ```
22
+
13
23
  ## テスト
14
- テストにはSMTP通信を行うものも含まれるため、
15
- [koseki-mocksmtpd](https://github.com/koseki/mocksmtpd)などの、
16
- smtpdのmockを利用する必要があります。
24
+ 以下のテストを通過する必要があります。
25
+
17
26
 
18
- ### 必要なgemパッケージ
19
- テストを実行するためには以下のgemパッケージが必要です。
20
- * rails (include rack)
21
- * sqlite3
22
- * nokogiri
23
- * rspec
24
- * rspec-rails
25
- * rspec-fixture
26
- * rack-test
27
- * mocha
28
- * geokit
27
+ ```
28
+ $ bundle exec rake test
29
+ $ bundle exec rubocop
30
+ ```
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jpmobile.gemspec
4
+ gemspec
5
+
6
+ gem 'onkcop', require: false
@@ -0,0 +1,198 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ jpmobile (5.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (5.0.3)
10
+ actionpack (= 5.0.3)
11
+ nio4r (>= 1.2, < 3.0)
12
+ websocket-driver (~> 0.6.1)
13
+ actionmailer (5.0.3)
14
+ actionpack (= 5.0.3)
15
+ actionview (= 5.0.3)
16
+ activejob (= 5.0.3)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 2.0)
19
+ actionpack (5.0.3)
20
+ actionview (= 5.0.3)
21
+ activesupport (= 5.0.3)
22
+ rack (~> 2.0)
23
+ rack-test (~> 0.6.3)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (5.0.3)
27
+ activesupport (= 5.0.3)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (5.0.3)
33
+ activesupport (= 5.0.3)
34
+ globalid (>= 0.3.6)
35
+ activemodel (5.0.3)
36
+ activesupport (= 5.0.3)
37
+ activerecord (5.0.3)
38
+ activemodel (= 5.0.3)
39
+ activesupport (= 5.0.3)
40
+ arel (~> 7.0)
41
+ activesupport (5.0.3)
42
+ concurrent-ruby (~> 1.0, >= 1.0.2)
43
+ i18n (~> 0.7)
44
+ minitest (~> 5.1)
45
+ tzinfo (~> 1.1)
46
+ addressable (2.5.1)
47
+ public_suffix (~> 2.0, >= 2.0.2)
48
+ arel (7.1.4)
49
+ ast (2.3.0)
50
+ builder (3.2.3)
51
+ capybara (2.13.0)
52
+ addressable
53
+ mime-types (>= 1.16)
54
+ nokogiri (>= 1.3.3)
55
+ rack (>= 1.0.0)
56
+ rack-test (>= 0.5.4)
57
+ xpath (~> 2.0)
58
+ capybara-webkit (1.14.0)
59
+ capybara (>= 2.3.0, < 2.14.0)
60
+ json
61
+ coderay (1.1.1)
62
+ concurrent-ruby (1.0.5)
63
+ diff-lcs (1.3)
64
+ erubis (2.7.0)
65
+ geokit (1.11.0)
66
+ git (1.3.0)
67
+ globalid (0.4.0)
68
+ activesupport (>= 4.2.0)
69
+ hpricot (0.8.6)
70
+ i18n (0.8.1)
71
+ json (2.1.0)
72
+ loofah (2.0.3)
73
+ nokogiri (>= 1.5.9)
74
+ mail (2.6.5)
75
+ mime-types (>= 1.16, < 4)
76
+ method_source (0.8.2)
77
+ mime-types (3.1)
78
+ mime-types-data (~> 3.2015)
79
+ mime-types-data (3.2016.0521)
80
+ mini_portile2 (2.1.0)
81
+ minitest (5.10.2)
82
+ nio4r (2.0.0)
83
+ nokogiri (1.7.2)
84
+ mini_portile2 (~> 2.1.0)
85
+ onkcop (0.48.1.1)
86
+ rubocop (~> 0.48.1)
87
+ rubocop-rspec (>= 1.15.0)
88
+ parser (2.4.0.0)
89
+ ast (~> 2.2)
90
+ powerpack (0.1.1)
91
+ pry (0.10.4)
92
+ coderay (~> 1.1.0)
93
+ method_source (~> 0.8.1)
94
+ slop (~> 3.4)
95
+ public_suffix (2.0.5)
96
+ rack (2.0.2)
97
+ rack-test (0.6.3)
98
+ rack (>= 1.0)
99
+ rails (5.0.3)
100
+ actioncable (= 5.0.3)
101
+ actionmailer (= 5.0.3)
102
+ actionpack (= 5.0.3)
103
+ actionview (= 5.0.3)
104
+ activejob (= 5.0.3)
105
+ activemodel (= 5.0.3)
106
+ activerecord (= 5.0.3)
107
+ activesupport (= 5.0.3)
108
+ bundler (>= 1.3.0, < 2.0)
109
+ railties (= 5.0.3)
110
+ sprockets-rails (>= 2.0.0)
111
+ rails-dom-testing (2.0.3)
112
+ activesupport (>= 4.2.0)
113
+ nokogiri (>= 1.6)
114
+ rails-html-sanitizer (1.0.3)
115
+ loofah (~> 2.0)
116
+ railties (5.0.3)
117
+ actionpack (= 5.0.3)
118
+ activesupport (= 5.0.3)
119
+ method_source
120
+ rake (>= 0.8.7)
121
+ thor (>= 0.18.1, < 2.0)
122
+ rainbow (2.2.2)
123
+ rake
124
+ rake (12.0.0)
125
+ rspec (3.6.0)
126
+ rspec-core (~> 3.6.0)
127
+ rspec-expectations (~> 3.6.0)
128
+ rspec-mocks (~> 3.6.0)
129
+ rspec-core (3.6.0)
130
+ rspec-support (~> 3.6.0)
131
+ rspec-expectations (3.6.0)
132
+ diff-lcs (>= 1.2.0, < 2.0)
133
+ rspec-support (~> 3.6.0)
134
+ rspec-its (1.2.0)
135
+ rspec-core (>= 3.0.0)
136
+ rspec-expectations (>= 3.0.0)
137
+ rspec-mocks (3.6.0)
138
+ diff-lcs (>= 1.2.0, < 2.0)
139
+ rspec-support (~> 3.6.0)
140
+ rspec-rails (3.6.0)
141
+ actionpack (>= 3.0)
142
+ activesupport (>= 3.0)
143
+ railties (>= 3.0)
144
+ rspec-core (~> 3.6.0)
145
+ rspec-expectations (~> 3.6.0)
146
+ rspec-mocks (~> 3.6.0)
147
+ rspec-support (~> 3.6.0)
148
+ rspec-support (3.6.0)
149
+ rubocop (0.48.1)
150
+ parser (>= 2.3.3.1, < 3.0)
151
+ powerpack (~> 0.1)
152
+ rainbow (>= 1.99.1, < 3.0)
153
+ ruby-progressbar (~> 1.7)
154
+ unicode-display_width (~> 1.0, >= 1.0.1)
155
+ rubocop-rspec (1.15.1)
156
+ rubocop (>= 0.42.0)
157
+ ruby-progressbar (1.8.1)
158
+ slop (3.6.0)
159
+ sprockets (3.7.1)
160
+ concurrent-ruby (~> 1.0)
161
+ rack (> 1, < 3)
162
+ sprockets-rails (3.2.0)
163
+ actionpack (>= 4.0)
164
+ activesupport (>= 4.0)
165
+ sprockets (>= 3.0.0)
166
+ sqlite3 (1.3.13)
167
+ sqlite3-ruby (1.3.3)
168
+ sqlite3 (>= 1.3.3)
169
+ thor (0.19.4)
170
+ thread_safe (0.3.6)
171
+ tzinfo (1.2.3)
172
+ thread_safe (~> 0.1)
173
+ unicode-display_width (1.2.1)
174
+ websocket-driver (0.6.5)
175
+ websocket-extensions (>= 0.1.0)
176
+ websocket-extensions (0.1.2)
177
+ xpath (2.0.0)
178
+ nokogiri (~> 1.3)
179
+
180
+ PLATFORMS
181
+ ruby
182
+
183
+ DEPENDENCIES
184
+ capybara-webkit
185
+ geokit
186
+ git
187
+ hpricot
188
+ jpmobile!
189
+ onkcop
190
+ pry
191
+ rails (~> 5.0.0)
192
+ rspec
193
+ rspec-its
194
+ rspec-rails
195
+ sqlite3-ruby
196
+
197
+ BUNDLED WITH
198
+ 1.14.6
@@ -0,0 +1,409 @@
1
+ [![CircleCI](https://circleci.com/gh/jpmobile/jpmobile/tree/master.svg?style=svg)](https://circleci.com/gh/jpmobile/jpmobile/tree/master)
2
+ [![Code Climate](https://codeclimate.com/github/jpmobile/jpmobile/badges/gpa.svg)](https://codeclimate.com/github/jpmobile/jpmobile)
3
+
4
+ # jpmobile: A Rails plugin for Japanese mobile-phones
5
+
6
+ ## jpmobileとは
7
+ 携帯電話特有の機能を Rails 5.0 や Rack middleware で利用するためのプラグイン。 以下の機能を備える。
8
+
9
+ * 携帯電話のキャリア判別
10
+ * 端末位置情報の取得
11
+ * [GeoKit](http://geokit.rubyforge.org) との連携
12
+
13
+ * 端末製造番号、契約者番号等の取得
14
+ * IPアドレスの検証(キャリアが公開しているIPアドレス帯域からのアクセスか判定)
15
+ * IPアドレスの検証には
16
+ [jpmobile-ipaddresses](http://github.com/jpmobile/jpmobile-ipaddresses
17
+ ) が必要です。
18
+
19
+ * ディスプレイ情報(画面サイズ、ブラウザ画面サイズ、カラー・白黒、色数)の取得
20
+ * ディスプレイ情報の取得には
21
+ [jpmobile-terminfo](http://github.com/jpmobile/jpmobile-terminfo)
22
+ が必要です。
23
+
24
+ * 文字コード変換機能/絵文字のキャリア間相互変換
25
+ * メールの送信
26
+ * 絵文字と漢字コードの変換
27
+
28
+ * メールの受信(experimental)
29
+ * 絵文字と漢字コードの変換
30
+
31
+ また Rails 5.0 に以下の機能を追加する
32
+ * ビューへの自動振分け
33
+ * 位置情報取得などのリンクヘルパーの追加
34
+ * セッションIDをフォーム/リンクに付与(Trans SID)
35
+
36
+ 他のバージョンの Rails については [Versions : Jpmobile vs
37
+ Rails](https://github.com/jpmobile/jpmobile/wiki/Version-:-Jpmobile-vs-Rails)
38
+ を参照。
39
+
40
+ ## インストール
41
+ ### Rails pluginとしてインストールする場合
42
+ ```shell
43
+ % rails plugin install git://github.com/jpmobile/jpmobile.git
44
+ ```
45
+
46
+ #### IPアドレス検証が必要な場合
47
+ ```shell
48
+ % rails plugin install git://github.com/jpmobile/jpmobile-ipaddresses.git
49
+ ```
50
+
51
+ #### ディスプレイ情報を取得する必要がある場合
52
+ ```shell
53
+ % rails plugin install git://github.com/jpmobile/jpmobile-terminfo.git
54
+ ```
55
+
56
+ ### gemでインストールする場合
57
+ ```shell
58
+ % gem install jpmobile
59
+ ```
60
+
61
+ #### IPアドレス検証が必要な場合
62
+ ```shell
63
+ % gem install jpmobile-ipaddresses
64
+ ```
65
+
66
+ #### ディスプレイ情報を取得する必要がある場合
67
+ ```shell
68
+ % gem install jpmobile-terminfo
69
+ ```
70
+
71
+ ## 使用例
72
+
73
+ ### 携帯電話の識別
74
+ 環境変数 `ENV['rack.jpmobile']` にキャリアクラスのインスタンスが格納されています。また Rack::Request#mobile
75
+ としても取得可能です。
76
+
77
+ #### キャリアの識別
78
+
79
+ ```ruby
80
+ case request.mobile
81
+ when Jpmobile::Mobile::Docomo
82
+ # for DoCoMo
83
+ when Jpmobile::Mobile::Au
84
+ # for au
85
+ when Jpmobile::Mobile::Softbank
86
+ # for SoftBank
87
+ when Jpmobile::Mobile::Willcom
88
+ # for Willcom
89
+ when Jpmobile::Mobile::Emobile
90
+ # for EMOBILE
91
+ else
92
+ # for PC
93
+ end
94
+ ```
95
+
96
+ あるいは
97
+ ```ruby
98
+ if request.mobile.is_a?(Jpmobile::Mobile::Docomo)
99
+ # for DoCoMo
100
+ end
101
+ ```
102
+
103
+ #### ビューの中で一部を切替える例
104
+ ```ruby
105
+ <% if request.mobile? %>
106
+ 携帯電話からのアクセスです。
107
+ <% else %>
108
+ 携帯電話からのアクセスではありません。
109
+ <% end %>
110
+
111
+ <% if request.smart_phone? %>
112
+ スマートフォンからのアクセスです。
113
+ <% else %>
114
+ スマートフォンからのアクセスではありません。
115
+ <% end %>
116
+
117
+ <% if request.tablet? %>
118
+ タブレットからのアクセスです。
119
+ <% else %>
120
+ タブレットからのアクセスではありません。
121
+ <% end %>
122
+ ```
123
+
124
+ #### 別に用意した携帯電話用コントローラへリダイレクトする例
125
+ ```ruby
126
+ class PcController < ApplicationController
127
+ before_action :redirect_if_mobile
128
+
129
+ def index
130
+ end
131
+
132
+ private
133
+ def redirect_if_mobile
134
+ if request.mobile?
135
+ pa = params.dup
136
+ pa[:controller] = "/mobile"
137
+ redirect_to pa
138
+ elsif request.smart_phone?
139
+ pa = params.dup
140
+ pa[:controller] = "/smart_phone"
141
+ redirect_to pa
142
+ end
143
+ end
144
+ end
145
+
146
+ class MobileController < ApplicationController
147
+ end
148
+ ```
149
+
150
+ ### 位置情報の取得
151
+ Rack::Request#mobile.position に位置情報が格納されます。
152
+
153
+ ```ruby
154
+ @latitude = request.mobile.position.lat
155
+ @longuitude = request.mobile.position.lon
156
+ ```
157
+
158
+ #### [GeoKit](http://geokit.rubyforge.org) との連携
159
+
160
+ vendor/plugins/geokit以下にGeoKitがインストールされていると、Jpmobile::PositionにGeoKit::Mappabl
161
+ eがincludeされる。したがって、
162
+
163
+ ```ruby
164
+ request.mobile.position.distance_to('札幌駅')
165
+ ```
166
+
167
+ とすることで、端末と「札幌駅」との距離を求めることができる。詳細は http://geokit.rubyforge.org/api/index.html
168
+ 参照。
169
+
170
+ ### 端末情報の取得
171
+
172
+ 端末側から通知されている場合、request.mobile.ident で 契約に固有の識別子もしくは端末の製造番号を取得できる。
173
+ 両方存在する場合は契約に固有のIDが優先される。
174
+
175
+ * 契約に固有のID (request.mobile.ident_subscriber)
176
+ * au: EZ番号(サブスクライバ番号)
177
+ * DoCoMo: FOMAカード製造番号
178
+ * EMOBILE: EMnet対応端末から通知されるユニークなユーザID
179
+
180
+ * 端末製造番号 (request.mobile.ident_device)
181
+ * DoCoMo: 端末製造番号(FOMA, MOVA)
182
+ * SoftBank: 製造番号
183
+
184
+ ### IPの検証
185
+ キャリアが公開しているIPアドレス帯域からのアクセスか判定する。
186
+ ```ruby
187
+ request.mobile.valid_ip?
188
+ ```
189
+
190
+ ただし [jpmobile-ipaddresses](http://github.com/jpmobile/jpmobile-ipaddresses)
191
+ がインストールされていないか、スマートフォンの場合は必ずfalseとなる。
192
+
193
+ ### 端末の画面サイズ
194
+ request.mobile.display で Jpmobile::Display クラスのインスタンスが返る。
195
+
196
+ ```ruby
197
+ 画面幅 <%= request.mobile.display.width %>
198
+ 画面高さ <%= request.mobile.display.height %>
199
+ ```
200
+
201
+ ただし [jpmobile-terminfo](http://github.com/jpmobile/jpmobile-terminfo)
202
+ がインストールされていない場合はエラーとなるので注意が必要。
203
+
204
+ ### 文字コード変換機能/絵文字のキャリア間相互変換
205
+
206
+ jpmobileを読み込むとDoCoMo、Au、SoftBankの絵文字を透過的に扱うことができる。
207
+
208
+ * Rails の場合は vendor/plugins に配置し、下記の設定を追加することで有効になる。
209
+ ```ruby
210
+ # Rack middleware を追加するメソッド
211
+ Rails.application.config.jpmobile.mobile_filter
212
+ or
213
+ Jpmobile.config.mobile_filter
214
+ ```
215
+
216
+ * 下記の設定を追加することで、<form> タグの accept-charset が変更される。
217
+
218
+ ```ruby
219
+ # <form accept-charset="Shift_JIS" ...> などに変更する
220
+ Rails.application.config.jpmobile.form_accept_charset_conversion = true
221
+ or
222
+ Jpmobile.config.form_accept_charset_conversion = true
223
+ ```
224
+
225
+ * Andriod/iPhone では Google 絵文字や Unicode 6.0
226
+ 絵文字が使われています。下記の設定を追加すると、互換性をもたせるために3キャリアの絵文字に変換することができます。また表示の変換も可能です。
227
+
228
+ ```ruby
229
+ Rails.application.config.jpmobile.smart_phone_emoticon_compatibility = true
230
+ or
231
+ Jpmobile.config.smart_phone_emoticon_compatibility = true
232
+ ```
233
+
234
+ 携帯電話上では特に問題とならない。PCブラウザでテストする際に問題となるためのオプション。
235
+
236
+ * Sinatra の場合は下記のように指定する。
237
+ ```ruby
238
+ $LOAD_PATH << './lib/jpmobile/lib'
239
+ require 'jpmobile'
240
+ require 'jpmobile/rack'
241
+
242
+ use Jpmobile::Rack::MobileCarrier
243
+ use Jpmobile::Rack::ParamsFilter
244
+ use Jpmobile::Rack::Filter
245
+
246
+ get '/' do
247
+ erb :index
248
+ end
249
+ ```
250
+
251
+ Rails のみ半角・全角の自動変換フィルターが用意されている。用いるには
252
+ ```ruby
253
+ class MyController
254
+ hankaku_filter
255
+ end
256
+ ```
257
+
258
+ と指定する。またtextareaやhidden/text/passwordのinputタグで半角に変換したくない場合は :input => true
259
+ を指定する。このときNokogiriが必要となるため、Gemfileに追記してインストールする必要がある。
260
+ ```ruby
261
+ class MyController
262
+ hankaku_filter :input => true
263
+ end
264
+ ```
265
+
266
+ Jpmobile内では、各キャリアの絵文字はUnicode私的領域上にマッピングされ、管理される。
267
+ このとき、DoCoMo、Auは公式サイト記載のマッピングが使用される。
268
+ ただしSoftBankはAuとの重複を避けるため、公式のマッピングに0x1000加算しU+F001以降に割り当てる。
269
+ テンプレート内ではUTF-8でエンコードするか、数値文字参照の&#xHHHH;形式で指定する。
270
+
271
+ 絵文字は送出時に内蔵の変換表に基づいて変換され、携帯電話のエンコーディングにあわせて送出される。
272
+ 携帯電話から受信した絵文字は上記マッピングに基づいてUTF-8でparamsに渡される。
273
+
274
+ * DoCoMo、Auとの通信時にはShift_JIS、SoftBankとの通信時にはUTF-8が使用される。
275
+ * :hankaku=>true指定時は、カタカナは半角カナに変換されて送出される。携帯電話から送られた半角カナは全角カナに変換される。
276
+ * 絵文字はキャリアにあわせて変換されて送出される。
277
+ * 携帯電話からの絵文字はUnicode私的領域にマップされ、UTF-8でparamsに格納される。
278
+
279
+ ### ビューの自動振り分け
280
+ ビューの自動振り分けを行うには、以下の設定が必要です。
281
+
282
+ ```ruby
283
+ class ApplicationController < ActionController::Base
284
+ include Jpmobile::ViewSelector
285
+ end
286
+ ```
287
+
288
+ DoCoMo携帯電話からアクセスすると、
289
+ * index_mobile_docomo.html.erb
290
+ * index_mobile.html.erb
291
+ * index.html.erb
292
+
293
+ の順でテンプレートを検索し、最初に見付かったテンプレートが利用される。
294
+ Auの場合は、index_mobile_au.html.erb、Softbankの場合はindex_mobile_softbank.html.erbが最初に
295
+ 検索される。
296
+
297
+ またiPhoneからアクセスすると、
298
+ * index_smart_phone_iphone.html.erb
299
+ * index_smart_phone.html.erb
300
+ * index.html.erb
301
+
302
+ の順でテンプレートを検索する。 Androidの場合はindex_smart_phone_android.html.erb、Windows
303
+ Phoneの場合はindex_smart_phone_windows_phone.html.erbが最初に検索される。
304
+
305
+ 自動振り分けを無効化するには、アクションにおいて以下のように設定する
306
+
307
+ ```ruby
308
+ def index
309
+ disable_mobile_view!
310
+ end
311
+ ```
312
+
313
+ ### 位置情報の取得用リンクの生成
314
+
315
+ 以下のようなコードで、端末に位置情報を要求するリンクを出力する。
316
+
317
+ ```ruby
318
+ <%= get_position_link_to("位置情報を取得する", :action=>:gps) %>
319
+ ```ruby
320
+
321
+ ### セッションIDの付与(Trans SID)
322
+ #### Cookie非対応携帯だけに付与する
323
+
324
+ ```ruby
325
+ class MyController
326
+ trans_sid
327
+ end
328
+ ```
329
+
330
+ #### PCにも付与する
331
+
332
+ ```ruby
333
+ class MyController
334
+ trans_sid :always
335
+ end
336
+ ```
337
+
338
+ trans_sid 機能を使う場合には、cookie session store を使用することができず、
339
+ active_record_storeのgemパッケージが必要です。 また Rails 5.0 では Cookie
340
+ が使える場合にはそちらが優先されてしまうため、:always を指定した場合に問題になる場合があります。 trans_sid を使用する際には、例えば
341
+ config/initializers/session_store.rb で
342
+
343
+ ```ruby
344
+ Rails.application.config.session_store :active_record_store
345
+ Rails.application.config.session_options = {:cookie_only => false}
346
+ ```
347
+
348
+ として active_record_store を使用するように設定し、:cookie_only => false として Cookie
349
+ を優先しないように設定します。 このとき ApplicationController において protect_from_forgery の :secret
350
+ を指定するか、 あるいは protect_from_forgery を解除する必要があるでしょう。
351
+
352
+ また、
353
+
354
+ ```ruby
355
+ link_to "hoge", "/controller/action/id"
356
+ ```ruby
357
+
358
+ のようにリンク先を直接指定するとセッションIDは付加されません。
359
+
360
+ ```ruby
361
+ link_to "hoge", :controller => "controller", :action => "action", :id => "id"
362
+ ```
363
+
364
+ のように指定する必要があります。
365
+
366
+ ### メールの送受信
367
+ メールにて絵文字や漢字コードの変換、ビューの自動振り分けを行なうには Jpmobile::Mailer::Base を使う。
368
+
369
+ ```ruby
370
+ class MobileMailer < Jpmobile::Mailer::Base
371
+ default :from => "info@jpmobile-rails.org"
372
+
373
+ def registration(to)
374
+ mail(:to => to)
375
+ end
376
+
377
+ def receive(email)
378
+ email
379
+ end
380
+ end
381
+ ```
382
+
383
+ * デフォルトで ISO-2022-JP エンコードで送信
384
+ * docomo/SoftBank には Shift_JIS で送信
385
+ * au は ISO-2022-JP エンコードで送信
386
+ * ビューやレイアウトの自動振り分け
387
+ * docomo であれば
388
+ app/views/mobile_mailer/registration_mobile_docomo.html.erb など
389
+
390
+ * 受信に関しては、docomo/SoftBank でテストできていないため、実験版とします。
391
+ * テストして問題あれば随時報告してください。
392
+
393
+ * オプションに :decorated => true を追加すると、各キャリアのデコメに適したフォーマットで送信します。
394
+ * ただし docomo/SoftBank でテスト出来ていないため、実験版とします。
395
+
396
+ ## jpmobileの開発方法
397
+
398
+ jpmobileの開発に関しては
399
+ [こちら](https://github.com/jpmobile/jpmobile/blob/master/CONTRIBUTING.md) へ
400
+
401
+ ## リンク
402
+
403
+ * http://jpmobile-rails.org
404
+
405
+ ## 作者
406
+
407
+ Copyright 2006-2012 (c) Yoji Shidara, under MIT License.
408
+
409
+ Shin-ichiro OGAWA <rust.stnard@gmail.com>, Yoji Shidara <dara@shidara.net>