intrinsic 1.0.0 → 1.0.3
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.
- data/CHANGELOG.mdown +70 -0
- data/README.md +114 -17
- data/example/sample.rb +5 -13
- data/lib/intrinsic/version.rb +1 -1
- metadata +8 -7
data/CHANGELOG.mdown
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
1.0.3 / 2012-01-08
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Adding the previous commit log to changelog
|
5
|
+
* Refactoring into single line validators
|
6
|
+
* Removing type due to default type being string
|
7
|
+
* Writing up the README documentation
|
8
|
+
|
9
|
+
|
10
|
+
1.0.0 / 2012-01-08
|
11
|
+
==================
|
12
|
+
|
13
|
+
* Merge branch 'release/1.0.0' into develop
|
14
|
+
* Incrementing the version number.
|
15
|
+
* Assigning errors if validation result was false
|
16
|
+
* Assigning the false setter to validation_result if raised
|
17
|
+
* Attempt to evaluate the validator
|
18
|
+
* Make begin, rescue, end blocks
|
19
|
+
* Defining under private
|
20
|
+
* Adding the validate action method
|
21
|
+
* Adding the is_valid method which calls on all the validators
|
22
|
+
* If validators hash is nil, make one, then fill with proerpty/vlock
|
23
|
+
* Defining the base add_validators method
|
24
|
+
* Calling the add_validators to add to list of validators
|
25
|
+
* Raise if the property isnt a part of the list
|
26
|
+
* Calling check_for_property on property
|
27
|
+
* Defining the base validation_for method
|
28
|
+
* Redifing the included method to extend with validation
|
29
|
+
* Require in the validation library and build skeleton
|
30
|
+
* Return self for chaining
|
31
|
+
* Set each key value as property and value
|
32
|
+
* Raise if any of the keys don't belong
|
33
|
+
* On initialize check the properties of list and define private method
|
34
|
+
* If value is a proc, call the proc with self as argument
|
35
|
+
* If no value given, print out value
|
36
|
+
* Print out class name, object id, and list of properties
|
37
|
+
* Returning self, for chaining
|
38
|
+
* Setting an instance variable with the property as the name and value equal to property value
|
39
|
+
* Making the check_for_types and property block methods private
|
40
|
+
* Assigning property as key and default as value for defaults
|
41
|
+
* Assigning property symbol to list of properties for class
|
42
|
+
* Building up proc, integer, and string coercion logic
|
43
|
+
* Defining and requiring three coercion types
|
44
|
+
* Building the Coercion library
|
45
|
+
* Require the coercion library
|
46
|
+
* Convert value to type and then assign to hash
|
47
|
+
* Defining unless statement for value of value paramater
|
48
|
+
* Defining a lambda that takes a single value for property_block
|
49
|
+
* Creating the property_block method
|
50
|
+
* Defining the method name with a block of the property
|
51
|
+
* Method for checking the types of the arguments
|
52
|
+
* Merginging the properties with the class defaults
|
53
|
+
* Initializing the defaults and properties lists as attributes
|
54
|
+
* Defining the property class method
|
55
|
+
* Building up the intrinsicism module
|
56
|
+
* Building up the Extrinsicism library
|
57
|
+
* Adding a test object to play around with for testing
|
58
|
+
* Building out some sample and testable data cases
|
59
|
+
* Adding whitespace
|
60
|
+
* Modifying the to_s of the model
|
61
|
+
* Creating a custom initialize method for intrinsic models
|
62
|
+
* Modifying the module method included to concern Intrinsicism
|
63
|
+
* Adding a skeleton test helper library
|
64
|
+
* Requiring a test helper library
|
65
|
+
* Adding the skeleton intrinsicism test
|
66
|
+
* Requiring the intrinsicism library
|
67
|
+
* Requiring the extrinsicism library
|
68
|
+
* Switching to single quotes
|
69
|
+
* Updating the gemspec with proper details
|
70
|
+
* Initial commit
|
data/README.md
CHANGED
@@ -1,29 +1,126 @@
|
|
1
|
-
|
1
|
+
intrinsic
|
2
|
+
=========
|
2
3
|
|
3
|
-
|
4
|
+
The intrinsic gem is for giving your objects typed attributes, defaults, and validations.
|
4
5
|
|
5
|
-
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
usage
|
8
|
+
-----
|
8
9
|
|
9
|
-
|
10
|
+
Using the intrinsic library is pretty simple.
|
11
|
+
The basic features are:
|
10
12
|
|
11
|
-
|
13
|
+
- Getters & Setters for named properties (similar to attr_accessor)
|
14
|
+
- Default values, both in regular and Proc (ie callable lambda) form
|
15
|
+
- Easy API for dumping object attributes (similar to ostruct)
|
16
|
+
- Type and Argument errors for incorrectly supplied properties
|
17
|
+
- Type coercion for attributes, as well as easily defininable new types
|
12
18
|
|
13
|
-
$ bundle
|
14
19
|
|
15
|
-
|
20
|
+
In addition you get these cool features:
|
16
21
|
|
17
|
-
|
22
|
+
- Validate your properties with simple boolean logic, no complex Validator classes!
|
23
|
+
- Get errors when your validations don't work (simple errors for now)
|
24
|
+
-
|
18
25
|
|
19
|
-
## Usage
|
20
26
|
|
21
|
-
|
27
|
+
installing
|
28
|
+
----------
|
22
29
|
|
23
|
-
|
30
|
+
**Requirements**
|
24
31
|
|
25
|
-
1.
|
26
|
-
2.
|
27
|
-
|
28
|
-
|
29
|
-
|
32
|
+
1. Ruby MRI 1.9+
|
33
|
+
2. RubyGems 1.6+
|
34
|
+
|
35
|
+
Like any other gem, all you have to do is either use:
|
36
|
+
|
37
|
+
``` bash
|
38
|
+
$ gem install
|
39
|
+
```
|
40
|
+
|
41
|
+
Or add it to your `Gemfile`:
|
42
|
+
|
43
|
+
``` ruby
|
44
|
+
source :rubygems
|
45
|
+
|
46
|
+
gem "intrinsic", "1.0.1"
|
47
|
+
```
|
48
|
+
|
49
|
+
That's all you have to do.
|
50
|
+
|
51
|
+
**Testing**
|
52
|
+
|
53
|
+
To make sure you did everything right do the following:
|
54
|
+
|
55
|
+
``` ruby
|
56
|
+
ruby -e "p require 'intrinsic'"
|
57
|
+
true
|
58
|
+
```
|
59
|
+
|
60
|
+
|
61
|
+
issues & documentation
|
62
|
+
----------------------
|
63
|
+
|
64
|
+
* [Documentation](http://krainboltgreene.github.com/intrinsic/documentation)
|
65
|
+
* [Issues](https://github.com/krainboltgreene/intrinsic/issues)
|
66
|
+
|
67
|
+
We welcome any pull requests or commits that improve `intrinsic`.
|
68
|
+
|
69
|
+
|
70
|
+
changelog
|
71
|
+
---------
|
72
|
+
|
73
|
+
- 1.0.3:
|
74
|
+
* Adding helpful README and license, updating example script
|
75
|
+
- 1.0.0: Initial release
|
76
|
+
|
77
|
+
|
78
|
+
contributing
|
79
|
+
------------
|
80
|
+
|
81
|
+
* **Fork** the repository
|
82
|
+
* **Clone the repository** locally, or **edit via Github**
|
83
|
+
* Create a **new branch** using the [Git Flow Standard](http://yakiloo.com/getting-started-git-flow/) conventions
|
84
|
+
* Commit **often** and **when important**
|
85
|
+
* **DO NOT CHANGE** ANY OF THESE (without making a new branch for *that* change):
|
86
|
+
* `*.gemspec`
|
87
|
+
* `Rakefile`
|
88
|
+
* `.rvmrc`
|
89
|
+
* `.gitignore`
|
90
|
+
* Any part of the git history
|
91
|
+
* **Write tests** specifically for the changes you've made, if no test exist
|
92
|
+
* **Push** your feature or hotfix branch to Github.
|
93
|
+
* Make a **Pull Request**
|
94
|
+
|
95
|
+
|
96
|
+
Credits
|
97
|
+
-------
|
98
|
+
|
99
|
+
- []()
|
100
|
+
- []()
|
101
|
+
- []()
|
102
|
+
|
103
|
+
|
104
|
+
License
|
105
|
+
-------
|
106
|
+
|
107
|
+
Copyright (c) 2011 Kurtis Rainbolt-Greene
|
108
|
+
|
109
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
110
|
+
a copy of this software and associated documentation files (the
|
111
|
+
"Software"), to deal in the Software without restriction, including
|
112
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
113
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
114
|
+
permit persons to whom the Software is furnished to do so, subject to
|
115
|
+
the following conditions:
|
116
|
+
|
117
|
+
The above copyright notice and this permission notice shall be
|
118
|
+
included in all copies or substantial portions of the Software.
|
119
|
+
|
120
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
121
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
122
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
123
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
124
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
125
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
126
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/example/sample.rb
CHANGED
@@ -4,21 +4,13 @@ class Person
|
|
4
4
|
include Intrinsic
|
5
5
|
include Intrinsic::Intrinsicism::Validation
|
6
6
|
|
7
|
-
property :name
|
8
|
-
property :email
|
7
|
+
property :name
|
8
|
+
property :email
|
9
9
|
property :age, Integer, default: 13
|
10
10
|
|
11
|
-
validation_for :name
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
validation_for :age do
|
16
|
-
(13..100).include? age
|
17
|
-
end
|
18
|
-
|
19
|
-
validation_for :email do
|
20
|
-
email.count('@') == 1 and email.length < 256 and email.length > 5
|
21
|
-
end
|
11
|
+
validation_for :name { name.match /\w/ }
|
12
|
+
validation_for :age { (13..100).include? age }
|
13
|
+
validation_for :email { email.count('@') == 1 and (5..256).include? email.length }
|
22
14
|
end
|
23
15
|
|
24
16
|
|
data/lib/intrinsic/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: intrinsic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-01-08 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156056780 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - =
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.9.2.2
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156056780
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: yard
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156056260 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - =
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 0.7.4
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156056260
|
36
36
|
description: Intrinsic adds properties to your objects
|
37
37
|
email:
|
38
38
|
- kurtisrainboltgreene@gmail.com
|
@@ -41,6 +41,7 @@ extensions: []
|
|
41
41
|
extra_rdoc_files: []
|
42
42
|
files:
|
43
43
|
- .gitignore
|
44
|
+
- CHANGELOG.mdown
|
44
45
|
- Gemfile
|
45
46
|
- LICENSE
|
46
47
|
- README.md
|
@@ -73,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
74
|
version: '0'
|
74
75
|
segments:
|
75
76
|
- 0
|
76
|
-
hash:
|
77
|
+
hash: 1445375515393034073
|
77
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
79
|
none: false
|
79
80
|
requirements:
|
@@ -82,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
83
|
version: '0'
|
83
84
|
segments:
|
84
85
|
- 0
|
85
|
-
hash:
|
86
|
+
hash: 1445375515393034073
|
86
87
|
requirements: []
|
87
88
|
rubyforge_project:
|
88
89
|
rubygems_version: 1.8.10
|