error_message_for_mobile 0.1.0
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/Gemfile +7 -0
- data/Gemfile.lock +77 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +21 -0
- data/Rakefile +37 -0
- data/VERSION +1 -0
- data/error_message_for_mobile.gemspec +42 -0
- data/init.rb +3 -0
- data/lib/action_view/helpers/error_message_for_mobile.rb +47 -0
- data/lib/error_message_for_mobile.rb +35 -0
- metadata +100 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
abstract (1.0.0)
|
5
|
+
actionmailer (3.0.4)
|
6
|
+
actionpack (= 3.0.4)
|
7
|
+
mail (~> 2.2.15)
|
8
|
+
actionpack (3.0.4)
|
9
|
+
activemodel (= 3.0.4)
|
10
|
+
activesupport (= 3.0.4)
|
11
|
+
builder (~> 2.1.2)
|
12
|
+
erubis (~> 2.6.6)
|
13
|
+
i18n (~> 0.4)
|
14
|
+
rack (~> 1.2.1)
|
15
|
+
rack-mount (~> 0.6.13)
|
16
|
+
rack-test (~> 0.5.7)
|
17
|
+
tzinfo (~> 0.3.23)
|
18
|
+
activemodel (3.0.4)
|
19
|
+
activesupport (= 3.0.4)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
i18n (~> 0.4)
|
22
|
+
activerecord (3.0.4)
|
23
|
+
activemodel (= 3.0.4)
|
24
|
+
activesupport (= 3.0.4)
|
25
|
+
arel (~> 2.0.2)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activeresource (3.0.4)
|
28
|
+
activemodel (= 3.0.4)
|
29
|
+
activesupport (= 3.0.4)
|
30
|
+
activesupport (3.0.4)
|
31
|
+
arel (2.0.8)
|
32
|
+
builder (2.1.2)
|
33
|
+
erubis (2.6.6)
|
34
|
+
abstract (>= 1.0.0)
|
35
|
+
git (1.2.5)
|
36
|
+
i18n (0.5.0)
|
37
|
+
jeweler (1.5.2)
|
38
|
+
bundler (~> 1.0.0)
|
39
|
+
git (>= 1.2.5)
|
40
|
+
rake
|
41
|
+
mail (2.2.15)
|
42
|
+
activesupport (>= 2.3.6)
|
43
|
+
i18n (>= 0.4.0)
|
44
|
+
mime-types (~> 1.16)
|
45
|
+
treetop (~> 1.4.8)
|
46
|
+
mime-types (1.16)
|
47
|
+
polyglot (0.3.1)
|
48
|
+
rack (1.2.1)
|
49
|
+
rack-mount (0.6.13)
|
50
|
+
rack (>= 1.0.0)
|
51
|
+
rack-test (0.5.7)
|
52
|
+
rack (>= 1.0)
|
53
|
+
rails (3.0.4)
|
54
|
+
actionmailer (= 3.0.4)
|
55
|
+
actionpack (= 3.0.4)
|
56
|
+
activerecord (= 3.0.4)
|
57
|
+
activeresource (= 3.0.4)
|
58
|
+
activesupport (= 3.0.4)
|
59
|
+
bundler (~> 1.0)
|
60
|
+
railties (= 3.0.4)
|
61
|
+
railties (3.0.4)
|
62
|
+
actionpack (= 3.0.4)
|
63
|
+
activesupport (= 3.0.4)
|
64
|
+
rake (>= 0.8.7)
|
65
|
+
thor (~> 0.14.4)
|
66
|
+
rake (0.8.7)
|
67
|
+
thor (0.14.6)
|
68
|
+
treetop (1.4.9)
|
69
|
+
polyglot (>= 0.3.1)
|
70
|
+
tzinfo (0.3.24)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
jeweler
|
77
|
+
rails (>= 3.0.0)
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 [name of plugin creator]
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
= error_message_for_mobile
|
2
|
+
ActiveRecord, ActiveModelのエラー表示をガラパゴス携帯に適した感じにしてくれるRails3プラグインです。
|
3
|
+
|
4
|
+
== インストール
|
5
|
+
|
6
|
+
gem install error_message_for_mobile
|
7
|
+
|
8
|
+
== 使用方法
|
9
|
+
|
10
|
+
<%= form_for @hoge do |f| %>
|
11
|
+
<%= f.error_message_for_mobile :title, :append_text => t(), :prepend_text => t(), :color => "#ff0000" %>
|
12
|
+
<%= end %>
|
13
|
+
|
14
|
+
* :append_text, :prepend_text, :colorは省略可能です。
|
15
|
+
* :colorを指定するとエラーメッセージの色を変更出来ます。
|
16
|
+
|
17
|
+
出力されるHTMLは下記のようになります。
|
18
|
+
|
19
|
+
<span style="color:#ff0000;">エラーメッセージ</span>
|
20
|
+
|
21
|
+
Copyright (c) 2011 Dai Akatsuka, released under the MIT license
|
data/Rakefile
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the error_message_for_mobile plugin.'
|
9
|
+
Rake::TestTask.new(:test) do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.libs << 'test'
|
12
|
+
t.pattern = 'test/**/*_test.rb'
|
13
|
+
t.verbose = true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc 'Generate documentation for the error_message_for_mobile plugin.'
|
17
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'ErrorMessageForMobile'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'jeweler'
|
27
|
+
Jeweler::Tasks.new do |gemspec|
|
28
|
+
gemspec.name = "error_message_for_mobile"
|
29
|
+
gemspec.summary = "error_message_on for japanese mobile-phone"
|
30
|
+
gemspec.email = "d.akatsuka@gmail.com"
|
31
|
+
gemspec.homepage = "https://github.com/dakatsuka/error_message_for_mobile"
|
32
|
+
gemspec.description = "error_message_on for japanese mobile-phone"
|
33
|
+
gemspec.authors = ["Dai Akatsuka"]
|
34
|
+
end
|
35
|
+
rescue LoadError
|
36
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
37
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{error_message_for_mobile}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Dai Akatsuka"]
|
12
|
+
s.date = %q{2011-02-09}
|
13
|
+
s.description = %q{error_message_on for japanese mobile-phone}
|
14
|
+
s.email = %q{d.akatsuka@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"VERSION"
|
20
|
+
]
|
21
|
+
s.homepage = %q{https://github.com/dakatsuka/error_message_for_mobile}
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
s.rubygems_version = %q{1.3.7}
|
24
|
+
s.summary = %q{error_message_on for japanese mobile-phone}
|
25
|
+
|
26
|
+
if s.respond_to? :specification_version then
|
27
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
28
|
+
s.specification_version = 3
|
29
|
+
|
30
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
31
|
+
s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
|
32
|
+
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
33
|
+
else
|
34
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
35
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
36
|
+
end
|
37
|
+
else
|
38
|
+
s.add_dependency(%q<rails>, [">= 3.0.0"])
|
39
|
+
s.add_dependency(%q<jeweler>, [">= 0"])
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
data/init.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'action_view/helpers'
|
3
|
+
require 'active_support/core_ext/class/attribute_accessors'
|
4
|
+
require 'active_support/core_ext/enumerable'
|
5
|
+
require 'active_support/core_ext/object/blank'
|
6
|
+
|
7
|
+
module ActionView
|
8
|
+
module Helpers
|
9
|
+
module ErrorMessageForMobile
|
10
|
+
def error_message_for_mobile(object, method, *args)
|
11
|
+
options = args.extract_options!
|
12
|
+
unless args.empty?
|
13
|
+
ActiveSupport::Deprecation.warn('error_message_for_mobile takes an option hash instead of separate ' +
|
14
|
+
'prepend_text, append_text, and color arguments', caller)
|
15
|
+
|
16
|
+
options[:prepend_text] = args[0] || ''
|
17
|
+
options[:append_text] = args[1] || ''
|
18
|
+
options[:color] = args[2] || '#ff0000'
|
19
|
+
end
|
20
|
+
options.reverse_merge!(:prepend_text => '', :append_text => '', :color => '#ff0000')
|
21
|
+
|
22
|
+
object = convert_to_model(object)
|
23
|
+
|
24
|
+
if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) &&
|
25
|
+
(errors = obj.errors[method]).presence
|
26
|
+
html = content_tag("span",
|
27
|
+
(options[:prepend_text].html_safe << errors.first).safe_concat(options[:append_text]),
|
28
|
+
:style => "color:#{options[:color]};"
|
29
|
+
)
|
30
|
+
html << '<br />'
|
31
|
+
else
|
32
|
+
''
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module FormBuilderMethods
|
37
|
+
def error_message_for_mobile(method, *args)
|
38
|
+
@template.error_message_for_mobile(@object || @object_name, method, *args)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class FormBuilder
|
44
|
+
include ErrorMessageForMobile::FormBuilderMethods
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
ActionView::Helpers::ActiveModelHelper.module_eval do
|
4
|
+
def error_message_for_mobile(object, method, *args)
|
5
|
+
options = args.extract_options!
|
6
|
+
unless args.empty?
|
7
|
+
ActiveSupport::Deprecation.warn('error_message_for_mobile takes an option hash instead of separate ' +
|
8
|
+
'prepend_text, append_text, and color arguments', caller)
|
9
|
+
|
10
|
+
options[:prepend_text] = args[0] || ''
|
11
|
+
options[:append_text] = args[1] || ''
|
12
|
+
options[:color] = args[2] || '#ff0000'
|
13
|
+
end
|
14
|
+
options.reverse_merge!(:prepend_text => '', :append_text => '', :color => '#ff0000')
|
15
|
+
|
16
|
+
object = convert_to_model(object)
|
17
|
+
|
18
|
+
if (obj = (object.respond_to?(:errors) ? object : instance_variable_get("@#{object}"))) &&
|
19
|
+
(errors = obj.errors[method]).presence
|
20
|
+
html = content_tag("span",
|
21
|
+
(options[:prepend_text].html_safe << errors.first).safe_concat(options[:append_text]),
|
22
|
+
:style => "color:#{options[:color]};"
|
23
|
+
)
|
24
|
+
html << content_tag("br")
|
25
|
+
else
|
26
|
+
''
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
ActionView::Helpers::FormBuilder.class_eval do
|
32
|
+
def error_message_for_mobile(method, *args)
|
33
|
+
@template.error_message_for_mobile(@object || @object_name, method, *args)
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: error_message_for_mobile
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Dai Akatsuka
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-02-09 00:00:00 +09:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rails
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 3
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
version: 3.0.0
|
32
|
+
type: :runtime
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: jeweler
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
prerelease: false
|
47
|
+
version_requirements: *id002
|
48
|
+
description: error_message_on for japanese mobile-phone
|
49
|
+
email: d.akatsuka@gmail.com
|
50
|
+
executables: []
|
51
|
+
|
52
|
+
extensions: []
|
53
|
+
|
54
|
+
extra_rdoc_files:
|
55
|
+
- README.rdoc
|
56
|
+
files:
|
57
|
+
- Gemfile
|
58
|
+
- Gemfile.lock
|
59
|
+
- MIT-LICENSE
|
60
|
+
- README.rdoc
|
61
|
+
- Rakefile
|
62
|
+
- VERSION
|
63
|
+
- error_message_for_mobile.gemspec
|
64
|
+
- init.rb
|
65
|
+
- lib/action_view/helpers/error_message_for_mobile.rb
|
66
|
+
- lib/error_message_for_mobile.rb
|
67
|
+
has_rdoc: true
|
68
|
+
homepage: https://github.com/dakatsuka/error_message_for_mobile
|
69
|
+
licenses: []
|
70
|
+
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
|
74
|
+
require_paths:
|
75
|
+
- lib
|
76
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
segments:
|
82
|
+
- 0
|
83
|
+
version: "0"
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
segments:
|
90
|
+
- 0
|
91
|
+
version: "0"
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.3.7
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: error_message_on for japanese mobile-phone
|
99
|
+
test_files: []
|
100
|
+
|