kattr 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +15 -19
- data/Gemfile +3 -0
- data/README.markdown +15 -7
- data/kattr.gemspec +3 -2
- data/lib/kattr/accessor.rb +1 -1
- data/lib/kattr/reader.rb +2 -2
- data/lib/kattr/writer.rb +2 -2
- data/spec/kattr_spec.rb +26 -23
- metadata +21 -6
- data/VERSION +0 -1
- data/lib/kattr/version.rb +0 -0
data/.gitignore
CHANGED
@@ -1,21 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
17
9
|
coverage
|
18
|
-
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
19
12
|
pkg
|
20
|
-
|
21
|
-
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
data/Gemfile
ADDED
data/README.markdown
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
kattr
|
2
2
|
=====
|
3
|
-
|
4
3
|
Works much like the version for rails (except it doesn't accept blocks and doesn't use eval).
|
5
|
-
It is prefered to use `kattr_*` instead of `cattr_*` so there are no confusion. If you are using
|
6
|
-
this gem outside of rails, it should be alright
|
7
4
|
|
5
|
+
I prefer to use `kattr_*` instead of `cattr_*` so there are no confusion with `cattr_*` in Rails.
|
6
|
+
Note, both `cattr_*` and `kattr_*` will work just fine.
|
7
|
+
|
8
|
+
If you are using this gem outside of Rails you should be all right
|
9
|
+
|
10
|
+
## Example
|
8
11
|
```ruby
|
12
|
+
require 'kattr'
|
13
|
+
|
9
14
|
class Moo
|
10
|
-
|
15
|
+
extend KAttr
|
16
|
+
kattr_accessor :cow
|
11
17
|
end
|
12
18
|
|
13
19
|
Moo.cow = 'animal'
|
@@ -15,15 +21,17 @@ Moo.class_variables
|
|
15
21
|
#=> [:@@cow]
|
16
22
|
```
|
17
23
|
|
24
|
+
You can either add `kattr` to your `$LOAD_PATH` or use it as in the example
|
18
25
|
|
19
26
|
## Note on Patches/Pull Requests
|
20
|
-
|
21
27
|
1. Fork it
|
22
28
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
23
29
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
24
30
|
4. Push to the branch (`git push origin my-new-feature`)
|
25
31
|
5. Create new Pull Request
|
26
32
|
|
27
|
-
##
|
33
|
+
## Thanks
|
34
|
+
[danielb2](/danielb2) for the original implementation
|
28
35
|
|
29
|
-
Copyright
|
36
|
+
## Copyright
|
37
|
+
Copyright (c) 2012 Teo Ljungberg. See LICENSE for details.
|
data/kattr.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
gem.authors = ["Teo Ljungberg"]
|
5
5
|
gem.email = ["teo.ljungberg@gmail.com"]
|
6
|
-
gem.description = %q{
|
6
|
+
gem.description = %q{kattr like attr_* but for class methods}
|
7
7
|
gem.summary = %q{attr_* for class methods}
|
8
8
|
gem.homepage = "http://github.com/metamorfos/kattr"
|
9
9
|
|
@@ -12,5 +12,6 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
13
|
gem.name = "kattr"
|
14
14
|
gem.require_paths = ["lib"]
|
15
|
-
gem.
|
15
|
+
gem.add_development_dependency('rspec')
|
16
|
+
gem.version = "0.0.2"
|
16
17
|
end
|
data/lib/kattr/accessor.rb
CHANGED
data/lib/kattr/reader.rb
CHANGED
data/lib/kattr/writer.rb
CHANGED
data/spec/kattr_spec.rb
CHANGED
@@ -1,33 +1,36 @@
|
|
1
1
|
require_relative '../lib/kattr'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
class Dog
|
4
|
+
extend KAttr
|
5
|
+
|
6
|
+
kattr_reader :teeth
|
7
|
+
kattr_writer :eye_color
|
8
|
+
kattr_accessor :size
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.eye_color
|
15
|
-
@@eye_color
|
16
|
-
end
|
17
|
-
end
|
10
|
+
def self.teeth
|
11
|
+
"sharp"
|
18
12
|
end
|
19
13
|
|
20
|
-
|
21
|
-
|
14
|
+
def self.eye_color
|
15
|
+
@@eye_color
|
22
16
|
end
|
17
|
+
end
|
23
18
|
|
24
|
-
|
25
|
-
|
26
|
-
Dog.eye_color.should eq("green")
|
27
|
-
end
|
19
|
+
describe Dog do
|
20
|
+
context 'with KAttr' do
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
it 'has sharp teeth' do
|
23
|
+
Dog.teeth.should eq 'sharp'
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'has lovely green eyes' do
|
27
|
+
Dog.eye_color = 'green'
|
28
|
+
Dog.eye_color.should eq 'green'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'is bloody humongous!' do
|
32
|
+
Dog.size = 'huge'
|
33
|
+
Dog.size.should eq 'huge'
|
34
|
+
end
|
32
35
|
end
|
33
36
|
end
|
metadata
CHANGED
@@ -2,16 +2,32 @@
|
|
2
2
|
name: kattr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Teo Ljungberg
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
13
|
-
dependencies:
|
14
|
-
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
version_requirements: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
none: false
|
21
|
+
name: rspec
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
requirement: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ! '>='
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
none: false
|
30
|
+
description: kattr like attr_* but for class methods
|
15
31
|
email:
|
16
32
|
- teo.ljungberg@gmail.com
|
17
33
|
executables: []
|
@@ -21,15 +37,14 @@ files:
|
|
21
37
|
- .gitignore
|
22
38
|
- .rbenv-version
|
23
39
|
- .rspec
|
40
|
+
- Gemfile
|
24
41
|
- LICENSE
|
25
42
|
- README.markdown
|
26
43
|
- Rakefile
|
27
|
-
- VERSION
|
28
44
|
- kattr.gemspec
|
29
45
|
- lib/kattr.rb
|
30
46
|
- lib/kattr/accessor.rb
|
31
47
|
- lib/kattr/reader.rb
|
32
|
-
- lib/kattr/version.rb
|
33
48
|
- lib/kattr/writer.rb
|
34
49
|
- spec/kattr_spec.rb
|
35
50
|
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.2
|
data/lib/kattr/version.rb
DELETED
File without changes
|