color-scheme-validator 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d24ee60ae5d7eaa3e1caa18169f6bf4d58cf49f1
4
+ data.tar.gz: 5da5788b2f19b387d4933945ed6ae690bc286ff7
5
+ SHA512:
6
+ metadata.gz: 307067f71c600b7f9c119d589b0e4b3d4a826ec63310e753e7c62c61d189fccbca7390fddc88afb03faea6f8d6865a0553c251a64ce5e01359b86811c35e42ad
7
+ data.tar.gz: 70b15e19495cfd4dcd08c35eef31803d301cb1b4fec72cd994d07bc53fc5011cc61fe52326ce0f4c43e1e22bdef20994e0816c1ab4e4e120f84fa53113654476
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
5
+ - 2.2.2
6
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in color_scheme_validator.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 ka
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # ColorSchemeValidator
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/color-scheme-validator.svg)](http://badge.fury.io/rb/color-scheme-validator)
4
+ [![Dependency Status](https://gemnasium.com/kaosf/color-scheme-validator.svg)](https://gemnasium.com/kaosf/color-scheme-validator)
5
+ [![Build Status](https://travis-ci.org/kaosf/color-scheme-validator.svg)](https://travis-ci.org/kaosf/color-scheme-validator)
6
+ [![Code Climate](https://codeclimate.com/github/kaosf/color-scheme-validator/badges/gpa.svg)](https://codeclimate.com/github/kaosf/color-scheme-validator)
7
+
8
+ Color scheme validator for Rails.
9
+
10
+ Like `#FF0000`, `#00ff00` and `#00f` strings are allowed.
11
+
12
+ Other strings are denied.
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'color-scheme-validator'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ ## Usage
27
+
28
+ ```ruby
29
+ class Item < ActiveRecord::Base
30
+ validates :color, color_scheme: true
31
+ end
32
+ ```
33
+
34
+ ## Locales
35
+
36
+ Run
37
+
38
+ ```sh
39
+ rails g colorscheme:install
40
+ ```
41
+
42
+ to generate `config/locales/colorscheme.en.yml`.
43
+
44
+ If you want to use another language, append an argument like
45
+
46
+ ```sh
47
+ rails g colorscheme:install ja
48
+ ```
49
+
50
+ to generate `config/locales/colorscheme.ja.yml`.
51
+
52
+ ## Development
53
+
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.
55
+
56
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kaosf/color-scheme-validator.
61
+
62
+ ## References
63
+
64
+ * [shirasagi/email_validator.rb at 3e6b88b741048af6ca15e90236964b84da8c7fe6 · shirasagi/shirasagi](https://github.com/shirasagi/shirasagi/blob/3e6b88b741048af6ca15e90236964b84da8c7fe6/app/validators/email_validator.rb)
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)
69
+
70
+ ## License
71
+
72
+ [MIT](http://opensource.org/licenses/MIT)
73
+
74
+ Copyright (C) 2015 ka
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = Dir["test/**/test_*.rb"]
7
+ t.verbose = true
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "color_scheme_validator"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "color-scheme-validator"
7
+ spec.version = "0.3.0"
8
+ spec.authors = ["ka"]
9
+ spec.email = ["ka.kaosf@gmail.com"]
10
+
11
+ spec.summary = %q{Color scheme validator for Rails.}
12
+ spec.description = %q{Color scheme validator for Rails.}
13
+ spec.homepage = "https://github.com/kaosf/color-scheme-validator"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency("activemodel", "~> 4.0")
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "test-unit", "~> 3.1.3"
26
+ end
@@ -0,0 +1,4 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ invalid_color_scheme: 'Invalid color scheme (e.g. #FF0000)'
@@ -0,0 +1,4 @@
1
+ ja:
2
+ errors:
3
+ messages:
4
+ invalid_color_scheme: 'は無効な色指定です(例: #FF0000)'
@@ -0,0 +1,7 @@
1
+ class ColorSchemeValidator < ActiveModel::EachValidator
2
+ def validate_each(record, attribute, value)
3
+ unless value =~ /\A#(\h{6}|\h{3})\z/
4
+ record.errors.add(attribute, options[:message] || :invalid_color_scheme)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Colorscheme
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/colorscheme.en.yml"
13
+ when "ja"
14
+ copy_file "config/locales/ja.yml", "config/locales/colorscheme.ja.yml"
15
+ else
16
+ create_file "config/locales/colorscheme.#{lang}.yml", <<EOS
17
+ #{lang}:
18
+ errors:
19
+ messages:
20
+ invalid_color_scheme: REPLACE_WITH_YOUR_LANGUAGE
21
+ EOS
22
+ end
23
+ end
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: color-scheme-validator
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - ka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.3
69
+ description: Color scheme validator for Rails.
70
+ email:
71
+ - ka.kaosf@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".travis.yml"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - color-scheme-validator.gemspec
85
+ - config/locales/en.yml
86
+ - config/locales/ja.yml
87
+ - lib/color-scheme-validator.rb
88
+ - lib/generators/colorscheme/install_generator.rb
89
+ homepage: https://github.com/kaosf/color-scheme-validator
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.4.5.1
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Color scheme validator for Rails.
113
+ test_files: []
114
+ has_rdoc: