fragmented_validation 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,23 +19,30 @@ Or install it yourself as:
19
19
 
20
20
  Usage
21
21
  ============
22
+
23
+ ## Getting Started
24
+
22
25
  ### Include the FragmentedValidation module by calling the 'fragmented_validation' in your model.
23
- e.g.
24
26
 
25
- class User < ActiveRecord::Base
26
- fragmented_validation
27
- ..
28
- #### Validate single attribute
29
27
 
30
- person.email_valid?
28
+
29
+ class User < ActiveRecord::Base
30
+ fragmented_validation
31
+ end
32
+
33
+ ### Validate single attribute
34
+
35
+ person.email_valid?
31
36
 
32
37
  #### Validate multiple attributes
33
38
 
34
- person.frag_validation_on(:username, :email)
39
+
40
+
41
+ person.fragmented_validation_on(:username, :email)
35
42
 
36
43
  or
37
44
 
38
- person.frag_validation_except(:password)
45
+ person.fragmented_validation_except(:password)
39
46
 
40
47
  Contributing
41
48
  ============
@@ -45,3 +52,5 @@ Contributing
45
52
  3. Commit your changes (`git commit -am 'Added some feature'`)
46
53
  4. Push to the branch (`git push origin my-new-feature`)
47
54
  5. Create new Pull Request
55
+
56
+
@@ -11,22 +11,22 @@ module FragmentedValidation
11
11
  attributes = self.new.attributes.keys
12
12
  attributes.each do |key|
13
13
  define_method "valid_#{key}?" do
14
- frag_valid_on key
14
+ fragmented_validation_on key
15
15
  end
16
16
  end
17
17
  end
18
18
  end
19
19
 
20
20
  module InstanceMethods
21
- def frag_valid_on(*attrs)
22
- frag_validation(attrs)
21
+ def fragmented_validation_on(*attrs)
22
+ fragmented_validation(attrs)
23
23
  end
24
24
 
25
- def frag_valid_except(*attrs)
26
- frag_validation(attributes.keys - attrs.map{|att| att.to_s})
25
+ def fragmented_validation_except(*attrs)
26
+ fragmented_validation(attributes.keys - attrs.map{|att| att.to_s})
27
27
  end
28
28
 
29
- def frag_validation(*attrs)
29
+ def fragmented_validation(*attrs)
30
30
  valid?
31
31
  _errors = {}
32
32
  attrs.flatten.uniq.each do |attr|
@@ -1,3 +1,3 @@
1
1
  module FragmentedValidation
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -13,19 +13,19 @@ describe FragmentedValidation do
13
13
  person.should respond_to(:valid_username?, :valid_password?)
14
14
  end
15
15
 
16
- describe "#frag_validation" do
16
+ describe "#fragmented_validation" do
17
17
  it "should only validate the passed attribute names" do
18
18
  person.password = ""
19
19
  person.username = ""
20
20
 
21
- person.frag_validation(:username, :password).should be_false
21
+ person.fragmented_validation(:username, :password).should be_false
22
22
  person.errors[:email].should be_empty
23
23
  person.errors[:password].should_not be_empty
24
24
  person.errors[:username].should_not be_empty
25
25
  end
26
26
 
27
27
  it "should ignore unknown attributes" do
28
- person.frag_validation(:ghost_method, :bad_method).should be_true
28
+ person.fragmented_validation(:ghost_method, :bad_method).should be_true
29
29
  end
30
30
  end
31
31
 
@@ -34,7 +34,7 @@ describe FragmentedValidation do
34
34
  person.password = ""
35
35
  person.username = "myusername"
36
36
  person.email = "test@mail.com"
37
- person.frag_valid_except(:password).should be_true
37
+ person.fragmented_validation_except(:password).should be_true
38
38
  end
39
39
  end
40
40
 
@@ -45,7 +45,7 @@ describe FragmentedValidation do
45
45
  person.username = "myusername"
46
46
  person.email = ""
47
47
 
48
- person.frag_valid_on(:username, :password).should be_true
48
+ person.fragmented_validation_on(:username, :password).should be_true
49
49
  end
50
50
  end
51
51
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fragmented_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: