color-schema-validator 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 037da6d6e7b62198a739c4b9bc9d4d4174bed1b7
4
- data.tar.gz: b9fcbc7ad17077cf646724349ff31aab9b94e62a
3
+ metadata.gz: df94956a472e7273f1be5e4e7d7fa30efdaf42fe
4
+ data.tar.gz: f4f3966c7a5b991b972e9337edb4d5c2a5581eb3
5
5
  SHA512:
6
- metadata.gz: 7e028f267cdf7dc2462d5c3b05b7e38608ea2433e590261c8daa20afa0c29fba5edce3dc53f34d050326ea91db2470fb0a615d166e43d5329f2e0d8540511be9
7
- data.tar.gz: 0e6dade994288a7d13a75d264c5c72d8b646c09af14970880d71055ce9b48b15522f77b66e2218be1c8ddfe4e3312e7bbb76f2dacf4557087470463921745789
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
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "color-schema-validator"
7
- spec.version = "0.1.1"
7
+ spec.version = "0.2.0"
8
8
  spec.authors = ["ka"]
9
9
  spec.email = ["ka.kaosf@gmail.com"]
10
10
 
@@ -0,0 +1,4 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ invalid_color_schema: 'Invalid color schema (e.g. #FF0000)'
@@ -0,0 +1,4 @@
1
+ ja:
2
+ errors:
3
+ messages:
4
+ invalid_color_schema: 'は無効な色指定です(例: #FF0000)'
@@ -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] || :invalid)
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.1.1
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 00:00:00.000000000 Z
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