kortype 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5e71fc6003d8296cb9c5e0ec28e7834ad6588d9f
4
- data.tar.gz: 2904f338ad8198feb3ab7a784aa1f4e01bbb0130
3
+ metadata.gz: 639c2724b37fd7da3ee21433a8eda9079aab4272
4
+ data.tar.gz: c8a6796bf8feea71b9b9047fec2860ef66df540a
5
5
  SHA512:
6
- metadata.gz: a079d538d89f7220e3dd7564739d335e2b38d202b89c9be9c8378eb1c9b521c0754737dba221bc9a1876cc07c0bad91dceeb578ba806a1c247f2ebcd1401ed39
7
- data.tar.gz: 04db08787f33fe41e18c141a91f7e07f9d3a371c411519f6554490a0e273c1487d1627f19ad81f2bcf316960ec187dc7e133821399bde042fa1bf1ec47dff63f
6
+ metadata.gz: e9413bca99e2bb44253f28289b3647e07de6a2f074417d645b77f69b7c50c6dce1a6af8f38d0b081fab528ba81cd0789f62628a56de8f6fab9b3317f85cb8ad6
7
+ data.tar.gz: 6b94e15d950b3ede325b12d79d76859fd235b72332eba66d153edfc3e34a4b9a30dd2f8624e612b262f2837fd8213a0473d5608a75fe1375860115c66a5bc18f
data/.travis.yml CHANGED
@@ -1,6 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 2.2.3
4
- - 1.8.7
5
4
  script:
6
5
  - bundle exec rspec
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Kortype
2
2
  [![Build
3
- Status](https://travis-ci.org/arnkorty/kortype.svg?branch=master)](https://travis-ci.org/arnkorty/kortype) [![Code Climate](https://codeclimate.com/github/arnkorty/kortype/badges/gpa.svg)](https://codeclimate.com/github/arnkorty/kortype) [![Dependency Status](https://gemnasium.com/arnkorty/kortype.svg)](https://gemnasium.com/arnkorty/kortype)
3
+ Status](https://travis-ci.org/arnkorty/kortype.svg?branch=master)](https://travis-ci.org/arnkorty/kortype) [![Code Climate](https://codeclimate.com/github/arnkorty/kortype/badges/gpa.svg)](https://codeclimate.com/github/arnkorty/kortype) [![Dependency Status](https://gemnasium.com/arnkorty/kortype.svg)](https://gemnasium.com/arnkorty/kortype) [![Test Coverage](https://codeclimate.com/github/arnkorty/kortype/badges/coverage.svg)](https://codeclimate.com/github/arnkorty/kortype/coverage)
4
4
 
5
- a ruby type force for class.
5
+ a simple ruby type force for class.
6
6
 
7
7
  ## Installation
8
8
 
@@ -52,13 +52,13 @@ b.file = 'Gemfile' # = File.new 'Gemfile'
52
52
 
53
53
  ## Development
54
54
 
55
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
55
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
56
56
 
57
57
  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).
58
58
 
59
59
  ## Contributing
60
60
 
61
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/kortype. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
61
+ Bug reports and pull requests are welcome on GitHub at https://github.com/arnkorty/kortype. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://github.com/arnkorty/kortype/graphs/contributors) code of conduct.
62
62
 
63
63
 
64
64
  ## License
data/lib/kortype.rb CHANGED
@@ -2,6 +2,7 @@ require "kortype/version"
2
2
  require 'kortype/type_error'
3
3
  require 'kortype/parse'
4
4
  require 'kortype/type'
5
+ require 'pry'
5
6
 
6
7
  #require 'active_support/concern'
7
8
  #require 'active_support/hash_with_indifferent_access'
@@ -22,6 +23,24 @@ module Kortype
22
23
  end
23
24
  end
24
25
 
26
+ def valid?
27
+ !kortype_columns.values.any?{|s| !s.valid?}
28
+ end
29
+
30
+ def errors
31
+ kortype_columns.values.select{|s| !s.valid?}
32
+ end
33
+
34
+ def valid_for?(col)
35
+ kortype_columns[col.to_sym].valid?
36
+ end
37
+
38
+ def error_msg_for(col)
39
+ if !valid_for?(col)
40
+ kortype_columns[col.to_sym].options[:error_msg]
41
+ end
42
+ end
43
+
25
44
  module ClassMethods
26
45
  def kortype_columns
27
46
  @kortype_columns ||= {}
data/lib/kortype/type.rb CHANGED
@@ -46,6 +46,18 @@ module Kortype
46
46
  @value
47
47
  end
48
48
 
49
+ def valid?
50
+ return false if !@value && @options[:required]
51
+ if @value && @options[:validate]
52
+ if Regexp === @options[:validate]
53
+ return !!(@value =~ @options[:validate])
54
+ elsif Proc === @options[:validate]
55
+ return @options[:validate].call(@value)
56
+ end
57
+ end
58
+ true
59
+ end
60
+
49
61
  # def dup
50
62
  #Kortype::Type.new @name, @type, @options
51
63
  #end
@@ -1,3 +1,3 @@
1
1
  module Kortype
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kortype
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - arnkorty