jpmobile 0.1.6 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. data/README +0 -0
  2. data/README.rdoc +58 -29
  3. data/Rakefile +1 -1
  4. data/VERSION.yml +4 -4
  5. data/lib/jpmobile.rb +3 -0
  6. data/lib/jpmobile/email.rb +17 -2
  7. data/lib/jpmobile/emoticon.rb +87 -23
  8. data/lib/jpmobile/emoticon/au.rb +644 -0
  9. data/lib/jpmobile/emoticon/softbank.rb +488 -0
  10. data/lib/jpmobile/emoticon/z_combine.rb +16 -13
  11. data/lib/jpmobile/hook_action_controller.rb +1 -13
  12. data/lib/jpmobile/hook_action_view.rb +3 -62
  13. data/lib/jpmobile/mail.rb +316 -0
  14. data/lib/jpmobile/mailer.rb +31 -0
  15. data/lib/jpmobile/mobile/abstract_mobile.rb +66 -0
  16. data/lib/jpmobile/mobile/au.rb +25 -2
  17. data/lib/jpmobile/mobile/docomo.rb +23 -1
  18. data/lib/jpmobile/mobile/emobile.rb +1 -1
  19. data/lib/jpmobile/mobile/softbank.rb +33 -1
  20. data/lib/jpmobile/mobile/vodafone.rb +1 -1
  21. data/lib/jpmobile/mobile/willcom.rb +1 -1
  22. data/lib/jpmobile/path_set.rb +40 -0
  23. data/lib/jpmobile/rails.rb +24 -0
  24. data/lib/jpmobile/resolver.rb +38 -0
  25. data/lib/jpmobile/util.rb +223 -14
  26. data/lib/tasks/jpmobile_tasks.rake +41 -48
  27. data/spec/rack/jpmobile/emoticon_spec.rb +3 -8
  28. data/spec/rack/jpmobile/filter_spec.rb +1 -1
  29. data/spec/rack/jpmobile/params_filter_spec.rb +4 -4
  30. data/spec/rack_helper.rb +5 -9
  31. data/spec/unit/detect_by_email_spec.rb +29 -0
  32. data/spec/unit/emoticon_spec.rb +90 -0
  33. data/spec/unit/encoding_spec.rb +102 -0
  34. data/spec/unit/mail_spec.rb +117 -0
  35. data/spec/unit/receive_mail_spec.rb +289 -0
  36. data/spec/unit/spec_helper.rb +8 -0
  37. data/spec/unit/util_spec.rb +5 -0
  38. data/test/rails/overrides/app/controllers/application_controller.rb +3 -2
  39. data/test/rails/overrides/app/controllers/template_path_controller.rb +8 -0
  40. data/test/rails/overrides/app/models/mobile_mailer.rb +19 -0
  41. data/test/rails/overrides/app/models/normal_mailer.rb +9 -0
  42. data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +737 -0
  43. data/test/rails/overrides/spec/models/normal_mailer_spec.rb +34 -0
  44. data/test/rails/overrides/spec/requests/template_path_spec.rb +13 -7
  45. data/test/rails/overrides/spec/spec_helper.rb +6 -0
  46. data/test/rails/rails_root/app/controllers/application_controller.rb +3 -2
  47. data/test/rails/rails_root/app/controllers/template_path_controller.rb +8 -0
  48. data/test/rails/rails_root/app/models/mobile_mailer.rb +2 -1
  49. data/test/rails/rails_root/app/models/normal_mailer.rb +9 -0
  50. data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
  51. data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +73 -80
  52. data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +34 -0
  53. data/test/rails/rails_root/spec/requests/template_path_spec.rb +13 -7
  54. data/test/rails/rails_root/spec/spec_helper.rb +1 -1
  55. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +2 -1
  56. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +7 -5
  57. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +1 -13
  58. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +3 -62
  59. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +162 -111
  60. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +31 -0
  61. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +34 -3
  62. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +2 -5
  63. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +4 -5
  64. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +7 -8
  65. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +40 -0
  66. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +1 -1
  67. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +24 -0
  68. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +38 -0
  69. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +33 -23
  70. metadata +43 -14
  71. data/test/legacy/emoticon_test.rb +0 -63
  72. data/test/legacy/helper.rb +0 -8
  73. data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_mailer.rb +0 -22
@@ -1,63 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__)) + '/helper'
2
-
3
- include Jpmobile::Util
4
-
5
- class DocomoEmoticonTest < Test::Unit::TestCase
6
- def test_external_unicodecr_docomo
7
- assert_equal "&#xe63e;", Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f"))
8
- end
9
- def test_unicodecr_external_docomo
10
- assert_equal sjis("\xf8\x9f"), Jpmobile::Emoticon::unicodecr_to_external("&#xe63e;")
11
- end
12
- def test_unicodecr_external_docomo_for_string
13
- assert_equal sjis("\xf8\x9f\xf8\xa0"), Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)
14
- end
15
- def test_unicodecr_utf8_docomo
16
- assert_equal utf8("\356\230\276"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xe63e;")
17
- end
18
- def test_utf8_unicodecr_docomo
19
- assert_equal "&#xe63e;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276"))
20
- end
21
- end
22
-
23
- class AuEmoticonTest < Test::Unit::TestCase
24
- def test_au_external_unicodecr
25
- assert_equal "&#xe481;", Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59"))
26
- end
27
- def test_au_unicodecr_external
28
- assert_equal sjis("\xf6\x59"), Jpmobile::Emoticon::unicodecr_to_external("&#xe481;")
29
- end
30
- def test_au_unicodecr_utf8
31
- assert_equal utf8("\356\222\201"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xe481;")
32
- end
33
- def test_au_utf8_unicodecr
34
- assert_equal "&#xe481;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201"))
35
- end
36
- end
37
-
38
- class SoftbankEmoticonTest < Test::Unit::TestCase
39
- def test_softbank_cr
40
- assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
41
- end
42
- def test_vodafone_cr
43
- assert_equal "&#xf001;", Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U'))
44
- end
45
- def test_softbank_cr_webcode
46
- assert_equal [0xe001].pack('U'), Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")
47
- end
48
- def test_softbank_cr_utf8
49
- assert_equal utf8("\xef\x80\x81"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")
50
- end
51
- def test_softbank_utf8_cr
52
- assert_equal "&#xf001;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))
53
- end
54
- def test_unicodecr_external_softbank_for_string
55
- assert_equal [0xe04a, 0xe049].pack('U*'), Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)
56
- end
57
- end
58
-
59
- class KoukaiEmoticonTest < Test::Unit::TestCase
60
- def test_koukai_sjis
61
- assert_equal sjis("\x8c\xf6\x8a\x4a"), Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a"))
62
- end
63
- end
@@ -1,8 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'rubygems'
3
- begin
4
- gem 'test-unit', '= 1.2.3'
5
- rescue Gem::LoadError
6
- end
7
- require 'test/unit'
8
- require File.dirname(__FILE__)+'/../../lib/jpmobile'
@@ -1,22 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- require 'jpmobile/mail'
3
-
4
- module Jpmobile
5
- module Mailer
6
- class Base < ActionMailer::Base
7
- def mail(headers={}, &block)
8
- m = super(headers, &block)
9
-
10
- if m.to.size == 1
11
- # for mobile
12
- m.mobile = (Jpmobile::Email.detect(m.to.first) || Jpmobile::Mobile::AbstractMobile).new(nil, nil)
13
- else
14
- # for multi to addresses
15
- m.mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
16
- end
17
-
18
- m
19
- end
20
- end
21
- end
22
- end