validation_contract 0.1.7 → 0.1.8

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: a71c88ac926337c42b08a5b767321b6b3c49346e
4
- data.tar.gz: 4698ef0f6118e325672c0e0816f17a0b282022e6
3
+ metadata.gz: c004bfbb9a6040860c61e86523746ab12a0e72b4
4
+ data.tar.gz: a3bbebda32b72facf3835f09c8d7ac0ac608b821
5
5
  SHA512:
6
- metadata.gz: 63486f2592b3509fa1e91ea96c0d008ad6f3b5e9f68b3156c3093bb9d84d54ac37c9d621acd5798204cfa5c9bd5cb0fb0071583a4e26f6be22d9fa7ac6a3e673
7
- data.tar.gz: aea838a1e4adeb6dc144acc213f94173782256e43ac1cebb1ca9302ca78891eb8f25a63a7cd770da6c55d2dcacdefdb700916005669206c444fd92c5801cfc14
6
+ metadata.gz: 46953df67654b70adf2bdde4cc2bd18839aa362774718f16ecb5d28c64e7a90102daa4ee106beb9d575b623642ae8a1d4fcc6781fe035dd3f0939ea569f28710
7
+ data.tar.gz: 23ee36ef6a911e1957767c2d84a3abc779ba557be69fbf50fa909b0204e08a02c979a91e415c4f482b0c92a6b1bec3e2dc3bcd64c75dd234a3e51d8588e3a41d
data/.byebug_history ADDED
@@ -0,0 +1,8 @@
1
+ exit
2
+ @validation_contract.erros[0][:message].to_s =
3
+ @validation_contract.erros[0][:message]
4
+ expect(@validation_contract.erros[0][:message]).to_s
5
+ exit
6
+ @result.to_s
7
+ @result.to
8
+ @result
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.rspec_status ADDED
@@ -0,0 +1,23 @@
1
+ example_id | status | run_time |
2
+ ------------------------------------------ | ------ | --------------- |
3
+ ./spec/validation_contract_spec.rb[1:1] | passed | 0.00056 seconds |
4
+ ./spec/validation_contract_spec.rb[1:2] | passed | 0.00012 seconds |
5
+ ./spec/validation_contract_spec.rb[1:3:1] | passed | 0.00008 seconds |
6
+ ./spec/validation_contract_spec.rb[1:4:1] | passed | 0.00008 seconds |
7
+ ./spec/validation_contract_spec.rb[1:4:2] | passed | 0.00041 seconds |
8
+ ./spec/validation_contract_spec.rb[1:5:1] | passed | 0.00038 seconds |
9
+ ./spec/validation_contract_spec.rb[1:5:2] | passed | 0.00008 seconds |
10
+ ./spec/validation_contract_spec.rb[1:5:3] | passed | 0.00007 seconds |
11
+ ./spec/validation_contract_spec.rb[1:6:1] | passed | 0.00007 seconds |
12
+ ./spec/validation_contract_spec.rb[1:6:2] | passed | 0.00007 seconds |
13
+ ./spec/validation_contract_spec.rb[1:6:3] | passed | 0.0001 seconds |
14
+ ./spec/validation_contract_spec.rb[1:7:1] | passed | 0.00008 seconds |
15
+ ./spec/validation_contract_spec.rb[1:7:2] | passed | 0.00007 seconds |
16
+ ./spec/validation_contract_spec.rb[1:8:1] | passed | 0.0001 seconds |
17
+ ./spec/validation_contract_spec.rb[1:8:2] | passed | 0.00007 seconds |
18
+ ./spec/validation_contract_spec.rb[1:9:1] | passed | 0.00009 seconds |
19
+ ./spec/validation_contract_spec.rb[1:9:2] | passed | 0.00006 seconds |
20
+ ./spec/validation_contract_spec.rb[1:10:1] | passed | 0.00012 seconds |
21
+ ./spec/validation_contract_spec.rb[1:10:2] | passed | 0.00007 seconds |
22
+ ./spec/validation_contract_spec.rb[1:11:1] | passed | 0.00007 seconds |
23
+ ./spec/validation_contract_spec.rb[1:11:2] | passed | 0.00011 seconds |
data/Gemfile CHANGED
@@ -4,3 +4,4 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in validation_contract.gemspec
6
6
  gemspec
7
+ gem 'byebug'
data/README.md CHANGED
@@ -62,7 +62,7 @@ This will check if there is any invalid field, if there is an arry returned with
62
62
  4. Push to the branch (git push origin my-new-feature)
63
63
  5. Create new Pull Request
64
64
 
65
- ## Contributors
65
+ ## Contributor
66
66
 
67
67
  [Ricardo Grassi](https://github.com/grassiricardo).
68
68
 
data/Rakefile CHANGED
@@ -1,2 +1,6 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
2
6
  task :default => :spec
data/bin/console CHANGED
@@ -1,7 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
1
  require "bundler/setup"
4
- require "validation_contract"
2
+ require "translate_yandex"
5
3
 
6
4
  # You can add fixtures and/or initialization code here to make experimenting
7
5
  # with your gem easier. You can also use a different console, if you like.
@@ -1,3 +1,3 @@
1
1
  module ValidationContract
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -1,49 +1,53 @@
1
- class ValidationContract
1
+ require "validation_contract/version"
2
2
 
3
- def initialize
4
- @errors = []
5
- end
3
+ module ValidationContract
4
+ class Validations
6
5
 
7
- def is_required value, message
8
- if !value || value.length() <= 0
9
- @errors.push({message: message})
6
+ def initialize
7
+ @errors = []
10
8
  end
11
- end
12
9
 
13
- def has_min_len value, min, message
14
- if !value || value.length() < min
15
- @errors.push({message: message})
10
+ def is_required value, message
11
+ if !value || value.length() <= 0
12
+ @errors.push({message: message})
13
+ end
16
14
  end
17
- end
18
15
 
19
- def has_max_len value, max, message
20
- if !value || value.length() > max
21
- @errors.push({message: message})
16
+ def has_min_len value, min, message
17
+ if !value || value.length() < min
18
+ @errors.push({message: message})
19
+ end
22
20
  end
23
- end
24
21
 
25
- def is_fixed_len value, len, message
26
- if value.length() != len
27
- @errors.push({message: message})
22
+ def has_max_len value, max, message
23
+ if !value || value.length() > max
24
+ @errors.push({message: message})
25
+ end
28
26
  end
29
- end
30
27
 
31
- def is_email value, message
32
- if !value.match(/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i)
33
- @errors.push({message: message})
28
+ def is_fixed_len value, len, message
29
+ if value.length() != len
30
+ @errors.push({message: message})
31
+ end
34
32
  end
35
- end
36
33
 
37
- def erros
38
- return @errors
39
- end
34
+ def is_email value, message
35
+ if !value.match(/\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i)
36
+ @errors.push({message: message})
37
+ end
38
+ end
40
39
 
41
- def clear
42
- return @errors = []
43
- end
40
+ def erros
41
+ return @errors
42
+ end
44
43
 
45
- def is_valid
46
- return @errors.length == 0
47
- end
44
+ def clear
45
+ return @errors = []
46
+ end
48
47
 
48
+ def is_valid
49
+ return @errors.length == 0
50
+ end
51
+
52
+ end
49
53
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.15"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: validation_contract
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - grassiricardo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-05 00:00:00.000000000 Z
11
+ date: 2017-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
41
55
  description: With this gem you will have several validations that are common on day
42
56
  day and that will make life much easier for dev. Validations can be returned in
43
57
  a simple and standardized way..
@@ -47,7 +61,10 @@ executables: []
47
61
  extensions: []
48
62
  extra_rdoc_files: []
49
63
  files:
64
+ - ".byebug_history"
50
65
  - ".gitignore"
66
+ - ".rspec"
67
+ - ".rspec_status"
51
68
  - Gemfile
52
69
  - README.md
53
70
  - Rakefile