kangal 0.1.2

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: eb2722a5dfceae4f70173853595ce1b8fb27b55e
4
+ data.tar.gz: 084a51fdb1e192a443c33816d32eba501c8ce7ce
5
+ SHA512:
6
+ metadata.gz: ab0b9b64d7f2fe4e575668a2df96775c5dba7cf3861f6a809159b9b9d8955c59f84f1437524d26198a097e59db3804b82898a79ea8ee5fd45876265c69fcf912
7
+ data.tar.gz: ced4d242ee9f6331a1eea02b333ecbb668ea4743bd659b2cd8e4c1bd7d839318088bb4984f49188ba52ad7ac400a530a4dc43d18f266f79b66df5183eb5b1f60
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
19
+ .swp
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,19 @@
1
+
2
+ #### [Current]
3
+
4
+ ####
5
+ * [bca3a4c](bca3a4c) add CHANGELOG.md __(Onur Ozgur OZKAN)__
6
+ * [8a5dd69](8a5dd69) #7 add travis-ci flag to README.md __(Onur Ozgur OZKAN)__
7
+ * [5a48bab](5a48bab) #2 fixed email format for spec __(Onur Ozgur OZKAN)__
8
+ * [382d3d1](382d3d1) #7 add travis-ci service __(Onur Ozgur OZKAN)__
9
+ * [85ad341](85ad341) Improve README.md __(Onur Ozgur OZKAN)__
10
+ * [4a986b9](4a986b9) #5 add locale system and files __(Onur Ozgur OZKAN)__
11
+ * [80f0aea](80f0aea) #2 add email validation __(Onur Ozgur OZKAN)__
12
+ * [189bbba](189bbba) #2 add spec for email __(Onur Ozgur OZKAN)__
13
+ * [42b68b5](42b68b5) #4 setup rspec and rake __(Onur Ozgur OZKAN)__
14
+ * [34cc03a](34cc03a) #4 set rspec and rake __(Onur Ozgur OZKAN)__
15
+ * [3d0b486](3d0b486) #1 fix license.txt __(Onur Ozgur OZKAN)__
16
+ * [cd9ed2e](cd9ed2e) #1 convert double quotes to single quotes __(Onur Ozgur OZKAN)__
17
+ * [c9896cb](c9896cb) #1 setup Code Climate and Gemnasium __(Onur Ozgur OZKAN)__
18
+ * [8ef9ff8](8ef9ff8) #1 setup gem __(Onur Ozgur OZKAN)__
19
+ * [29e3e1e](29e3e1e) #1 setup gem __(Onur Ozgur OZKAN)__
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kangal.gemspec
4
+ gemspec
5
+
6
+ gem 'rspec'
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 lab2023 - internet technologies
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,77 @@
1
+ # Kangal
2
+
3
+ [![Code Climate](https://codeclimate.com/github/kebab-project/kangal.png)](https://codeclimate.com/github/kebab-project/kangal)
4
+ [![Dependency Status](https://gemnasium.com/kebab-project/kangal.png)](https://gemnasium.com/kebab-project/kangal)
5
+ [![Build Status](https://travis-ci.org/kebab-project/kangal.png?branch=develop)](https://travis-ci.org/kebab-project/kangal)
6
+
7
+ NOTE: Don't use this gem until v1.0.0
8
+
9
+ **Kangal**
10
+
11
+ ## Requirements
12
+
13
+ Before generating your application, you will need:
14
+
15
+ * Ruby ~> 2.0
16
+ * Rails ~> 4.0
17
+
18
+ ## Usage
19
+
20
+ In your Gemfile
21
+
22
+ ```ruby
23
+ gem 'kangal'
24
+ ```
25
+
26
+
27
+ In your code
28
+
29
+ ```ruby
30
+ require 'kangal'
31
+ class User
32
+ include ActiveModel::Validations
33
+ attr_accessor :email
34
+
35
+ validates :email, presence: :true, email: :true
36
+ end
37
+
38
+
39
+ p = User.new
40
+ p.email = "info@lab2023.com"
41
+ p.valid? # => true
42
+
43
+ p.email = "info@lab"
44
+ p.valid? # => false
45
+
46
+ p.email = "Onur Ozgur <info@lab2023.com>"
47
+ p.valid? # => false
48
+ ```
49
+
50
+
51
+ ## Bugs and Feedback
52
+
53
+ If you discover any bugs or want to drop a line, feel free to create an issue on GitHub.
54
+
55
+ http://github.com/kebab-project/kangal
56
+
57
+ ## Contributing
58
+
59
+ Kangal uses [TomDoc](http://tomdoc.org/), [rDoc](http://rubydoc.info/gems/kangal) and [SemVer](http://semver.org/), and takes it seriously.
60
+
61
+ Once you've made your great commits:
62
+
63
+ 1. Fork Template
64
+ 2. Create a topic branch - `git checkout -b my_branch`
65
+ 3. Push to your branch - `git push origin my_branch`
66
+ 4. Create a Pull Request from your branch
67
+ 5. That's it!
68
+
69
+ ## Credits
70
+
71
+ - Kangal is maintained and funded by [lab2023 - internet technologies](http://lab2023.com/)
72
+ - Thank you to all the [contributors!](https://github.com/kebab-project/kangal/graphs/contributors)
73
+ - The names and logos for lab2023 are trademarks of lab2023, inc.
74
+
75
+ ## License
76
+
77
+ Copyright 2012 lab2023 – internet technologies
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -0,0 +1,5 @@
1
+ en:
2
+ kangal:
3
+ validations:
4
+ email:
5
+ invalid: 'is invalid'
@@ -0,0 +1,5 @@
1
+ tr:
2
+ kangal:
3
+ validations:
4
+ email:
5
+ invalid: 'geçersizdir.'
data/kangal.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kangal/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'kangal'
8
+ spec.version = Kangal::VERSION
9
+ spec.authors = ['lab2023', 'Onur Özgür ÖZKAN']
10
+ spec.email = %w(info@lab2023.com onur.ozgur.ozkan@lab2023.com)
11
+ spec.description = %q{Kangal brings you a nice set of custom validators for Rails 4.}
12
+ spec.summary = %q{Kangal brings you a nice set of custom validators for Rails 4.}
13
+ spec.homepage = 'https://github.com/kebab-project/kangal'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.require_paths = %w(lib)
18
+
19
+ spec.add_development_dependency 'bundler', '~> 1.3'
20
+ spec.add_development_dependency 'rspec'
21
+ spec.add_development_dependency 'rake'
22
+
23
+ spec.add_runtime_dependency 'mail'
24
+ spec.add_runtime_dependency 'activemodel', '>= 0'
25
+ end
data/lib/kangal.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'kangal/version'
2
+ require 'kangal/email'
3
+
4
+ I18n.load_path += Dir.glob(File.expand_path('../../config/locales/**/*',__FILE__))
@@ -0,0 +1,27 @@
1
+ require 'active_model'
2
+ require 'active_model/validations'
3
+ require 'mail'
4
+
5
+ class EmailValidator < ActiveModel::EachValidator
6
+
7
+ def validate_each(record, attribute, value)
8
+ # takes from https://github.com/hallelujah/valid_email/blob/master/lib/valid_email/email_validator.rb
9
+ begin
10
+ m = Mail::Address.new(value)
11
+ # We must check that value contains a domain and that value is an email address
12
+ r = m.domain && m.address == value
13
+ t = m.__send__(:tree)
14
+ # We need to dig into treetop
15
+ # A valid domain must have dot_atom_text elements size > 1
16
+ # user@localhost is excluded
17
+ # treetop must respond to domain
18
+ # We exclude valid email values like <user@localhost.com>
19
+ # Hence we use m.__send__(tree).domain
20
+ r &&= (t.domain.dot_atom_text.elements.size > 1)
21
+ rescue Exception => e
22
+ r = false
23
+ end
24
+ record.errors.add attribute, (options[:message] || I18n.t(:invalid, :scope => 'kangal.validations.email')) unless r
25
+ end
26
+
27
+ end
@@ -0,0 +1,3 @@
1
+ module Kangal
2
+ VERSION = '0.1.2'
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ class User < SpecModel
4
+ validates :email, email: true
5
+ end
6
+
7
+ describe 'Email format' do
8
+
9
+ let(:invalid_emails) do
10
+ %w(invalid email)
11
+ end
12
+
13
+ let(:valid_emails) do
14
+ %w(info@lab2023.com abc@ab.com)
15
+ end
16
+
17
+ it 'should be invalid' do
18
+ invalid_emails.each { |email| User.new(email: email).valid?.should be_false }
19
+ end
20
+
21
+ it 'should be valid' do
22
+ valid_emails.each { |email| User.new(email: email).valid?.should be_true }
23
+ end
24
+
25
+ end
@@ -0,0 +1,22 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'active_model'
4
+ require 'kangal'
5
+
6
+ class SpecModel
7
+
8
+ include ActiveModel::Validations
9
+
10
+ def initialize(attributes = {})
11
+ @attributes = attributes
12
+ end
13
+
14
+ def read_attribute_for_validation(key)
15
+ @attributes[key]
16
+ end
17
+
18
+ end
19
+
20
+ #RSpec.configure do |config|
21
+ #
22
+ #end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kangal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - lab2023
8
+ - Onur Özgür ÖZKAN
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-25 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rspec
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: mail
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: activemodel
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :runtime
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description: Kangal brings you a nice set of custom validators for Rails 4.
85
+ email:
86
+ - info@lab2023.com
87
+ - onur.ozgur.ozkan@lab2023.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - .gitignore
93
+ - .travis.yml
94
+ - CHANGELOG.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - config/locales/en.yml
100
+ - config/locales/tr.yml
101
+ - kangal.gemspec
102
+ - lib/kangal.rb
103
+ - lib/kangal/email.rb
104
+ - lib/kangal/version.rb
105
+ - spec/email_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: https://github.com/kebab-project/kangal
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.0.5
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Kangal brings you a nice set of custom validators for Rails 4.
131
+ test_files: []