color-schema-validator 0.1.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/color-schema-validator.gemspec +1 -1
- data/config/locales/en.yml +4 -0
- data/config/locales/ja.yml +4 -0
- data/lib/color-schema-validator.rb +1 -1
- data/lib/generators/colorschema/install_generator.rb +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df94956a472e7273f1be5e4e7d7fa30efdaf42fe
|
4
|
+
data.tar.gz: f4f3966c7a5b991b972e9337edb4d5c2a5581eb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16148ff493b2308290bcc93411b8d73aafde025f1909a808f895cc584469419c21bfe6482fe87dec6d05d4ff03fb2d99583921255cc413c7f38a4c4fba585d5e
|
7
|
+
data.tar.gz: ae7f03169df42bab8881e26631b3b60e12ad2a8d8b1abe12f864286c87fa82495c3e5f0df5023e5078287a27567db5b404ba2a417f6c87ec78a86a7ecbcee86d
|
data/README.md
CHANGED
@@ -31,6 +31,24 @@ class Item < ActiveRecord::Base
|
|
31
31
|
end
|
32
32
|
```
|
33
33
|
|
34
|
+
## Locales
|
35
|
+
|
36
|
+
Run
|
37
|
+
|
38
|
+
```sh
|
39
|
+
rails g colorschema:install
|
40
|
+
```
|
41
|
+
|
42
|
+
to generate `config/locales/colorschema.en.yml`.
|
43
|
+
|
44
|
+
If you want to use another language, append an argument like
|
45
|
+
|
46
|
+
```sh
|
47
|
+
rails g colorschema:install ja
|
48
|
+
```
|
49
|
+
|
50
|
+
to generate `config/locales/colorschema.ja.yml`.
|
51
|
+
|
34
52
|
## Development
|
35
53
|
|
36
54
|
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -45,6 +63,9 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/kaosf/
|
|
45
63
|
|
46
64
|
* [shirasagi/email_validator.rb at 3e6b88b741048af6ca15e90236964b84da8c7fe6 · shirasagi/shirasagi](https://github.com/shirasagi/shirasagi/blob/3e6b88b741048af6ca15e90236964b84da8c7fe6/app/validators/email_validator.rb)
|
47
65
|
* [balexand/email_validator](https://github.com/balexand/email_validator)
|
66
|
+
* [Railsのi18nの基本的な使い方まとめ - Rails Webook](http://ruby-rails.hatenadiary.com/entry/20150226/1424937175)
|
67
|
+
* [Creating and Customizing Rails Generators & Templates — Ruby on Rails Guides](http://guides.rubyonrails.org/generators.html)
|
68
|
+
* [plataformatec/devise](https://github.com/plataformatec/devise)
|
48
69
|
|
49
70
|
## License
|
50
71
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class ColorSchemaValidator < ActiveModel::EachValidator
|
2
2
|
def validate_each(record, attribute, value)
|
3
3
|
unless value =~ /\A#(\h{6}|\h{3})\z/
|
4
|
-
record.errors.add(attribute, options[:message] || :
|
4
|
+
record.errors.add(attribute, options[:message] || :invalid_color_schema)
|
5
5
|
end
|
6
6
|
end
|
7
7
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Colorschema
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path("../../../../", __FILE__)
|
6
|
+
|
7
|
+
argument :lang, type: :string, default: "en", banner: "[ja|de|ru| ... ]"
|
8
|
+
|
9
|
+
def copy_locale
|
10
|
+
case lang
|
11
|
+
when "en"
|
12
|
+
copy_file "config/locales/en.yml", "config/locales/colorschema.en.yml"
|
13
|
+
when "ja"
|
14
|
+
copy_file "config/locales/ja.yml", "config/locales/colorschema.ja.yml"
|
15
|
+
else
|
16
|
+
create_file "config/locales/colorschema.#{lang}.yml", <<EOS
|
17
|
+
#{lang}:
|
18
|
+
errors:
|
19
|
+
messages:
|
20
|
+
invalid_color_schema: REPLACE_WITH_YOUR_LANGUAGE
|
21
|
+
EOS
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: color-schema-validator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ka
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -82,7 +82,10 @@ files:
|
|
82
82
|
- bin/console
|
83
83
|
- bin/setup
|
84
84
|
- color-schema-validator.gemspec
|
85
|
+
- config/locales/en.yml
|
86
|
+
- config/locales/ja.yml
|
85
87
|
- lib/color-schema-validator.rb
|
88
|
+
- lib/generators/colorschema/install_generator.rb
|
86
89
|
homepage: https://github.com/kaosf/color-schema-validator
|
87
90
|
licenses:
|
88
91
|
- MIT
|