attribeautiful 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/attribeautiful.gemspec +1 -1
- data/lib/attribeautiful/container.rb +38 -38
- data/lib/attribeautiful/element.rb +10 -9
- data/lib/attribeautiful/version.rb +1 -1
- metadata +6 -6
data/attribeautiful.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
|
|
10
10
|
value.}
|
11
11
|
gem.homepage = "http://github.com/kevinburleigh75/attribeautiful"
|
12
12
|
|
13
|
-
gem.add_dependency "eager_beaver", '0.0.
|
13
|
+
gem.add_dependency "eager_beaver", '~> 0.0.4'
|
14
14
|
gem.add_dependency "activesupport", '~> 3.0'
|
15
15
|
|
16
16
|
gem.files = `git ls-files`.split($\)
|
@@ -21,74 +21,74 @@ module Attribeautiful
|
|
21
21
|
html_element_names << elem_name
|
22
22
|
|
23
23
|
## handle <elem_name>_element methods
|
24
|
-
|
25
|
-
|
24
|
+
add_method_handler do |mh|
|
25
|
+
mh.match = lambda {
|
26
26
|
#puts "MATCHING: <elem_name>_element against #{missing_method_name}"
|
27
|
-
/\A(\w+)_element\z/ =~ missing_method_name
|
28
|
-
@elem_name = Regexp.last_match ? Regexp.last_match[1] : nil
|
27
|
+
context.elem_name = $1 if /\A(\w+)_element\z/ =~ context.missing_method_name
|
29
28
|
#puts "MATCHING: #{Regexp.last_match ? 'SUCESS' : 'FAILURE'}"
|
30
|
-
Regexp.last_match
|
31
|
-
|
29
|
+
return Regexp.last_match
|
30
|
+
}
|
32
31
|
|
33
|
-
|
32
|
+
mh.handle = lambda {
|
34
33
|
%Q{
|
35
|
-
def #{missing_method_name}
|
36
|
-
@#{
|
34
|
+
def #{context.missing_method_name}
|
35
|
+
@#{context.elem_name}_element ||= Attribeautiful::Element.new
|
37
36
|
end
|
38
37
|
}
|
39
|
-
|
38
|
+
}
|
40
39
|
end
|
41
40
|
|
42
41
|
## handle <elem_name>_<attr_name>_attr methods
|
43
|
-
|
44
|
-
|
42
|
+
add_method_handler do |mh|
|
43
|
+
mh.match = lambda {
|
45
44
|
#puts "MATCHING: <elem_name>_<attr_name>_attr against #{missing_method_name}"
|
46
|
-
#puts "#{
|
47
|
-
|
45
|
+
#puts "#{original_receiver.class.html_element_names}"
|
46
|
+
context.original_receiver.class.html_element_names.detect{ |elem_name|
|
48
47
|
#puts "#{elem_name}"
|
49
|
-
/\A(#{elem_name})_(\w+)_attr\z/ =~ missing_method_name
|
48
|
+
/\A(#{elem_name})_(\w+)_attr\z/ =~ context.missing_method_name
|
50
49
|
}
|
51
|
-
|
52
|
-
|
50
|
+
context.elem_name = $1
|
51
|
+
context.attr_name = $2
|
53
52
|
#puts "MATCHING: #{Regexp.last_match ? 'SUCESS' : 'FAILURE'}"
|
54
|
-
Regexp.last_match
|
55
|
-
|
53
|
+
return Regexp.last_match
|
54
|
+
}
|
56
55
|
|
57
|
-
|
56
|
+
mh.handle = lambda {
|
58
57
|
%Q{
|
59
|
-
def #{missing_method_name}
|
60
|
-
#{
|
58
|
+
def #{context.missing_method_name}
|
59
|
+
#{context.elem_name}_element.#{context.attr_name}_attr ||= Attribeautiful::Attribute.new("#{context.attr_name}")
|
61
60
|
end
|
62
61
|
}
|
63
|
-
|
62
|
+
}
|
64
63
|
end
|
65
64
|
|
66
65
|
## handle <elem_name>_<attr_name>_<attr_action> methods
|
67
|
-
|
68
|
-
|
66
|
+
add_method_handler do |mh|
|
67
|
+
mh.match = lambda {
|
69
68
|
#puts "MATCHING: <elem_name>_<attr_name>_<attr_action> against #{missing_method_name}"
|
70
|
-
#puts "#{
|
71
|
-
|
69
|
+
#puts "#{original_receiver.class.html_element_names}"
|
70
|
+
context.original_receiver.class.html_element_names.detect do |elem_name|
|
72
71
|
#puts "#{elem_name}"
|
73
72
|
Attribeautiful::Attribute.instance_methods.detect do |attr_action|
|
74
73
|
#puts " #{attr_action}"
|
75
|
-
/\A(#{elem_name})_(\w+)_(#{attr_action})\z/ =~ missing_method_name
|
74
|
+
/\A(#{elem_name})_(\w+)_(#{attr_action})\z/ =~ context.missing_method_name
|
76
75
|
end
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
76
|
+
end
|
77
|
+
|
78
|
+
context.elem_name = $1
|
79
|
+
context.attr_name = $2
|
80
|
+
context.attr_action = $3
|
81
81
|
#puts "MATCHING: #{Regexp.last_match ? 'SUCESS' : 'FAILURE'}"
|
82
|
-
Regexp.last_match
|
83
|
-
|
82
|
+
return Regexp.last_match
|
83
|
+
}
|
84
84
|
|
85
|
-
|
85
|
+
mh.handle = lambda {
|
86
86
|
%Q{
|
87
|
-
def #{
|
88
|
-
#{
|
87
|
+
def #{context.missing_method_name}(*args, &block)
|
88
|
+
#{context.elem_name}_#{context.attr_name}_attr.#{context.attr_action}(*args, &block)
|
89
89
|
end
|
90
90
|
}
|
91
|
-
|
91
|
+
}
|
92
92
|
end
|
93
93
|
|
94
94
|
end
|
@@ -7,19 +7,20 @@ module Attribeautiful
|
|
7
7
|
include EagerBeaver
|
8
8
|
|
9
9
|
## handle <attr_name>_attr methods
|
10
|
-
|
11
|
-
|
12
|
-
/\A(\w+)_attr/ =~ missing_method_name
|
13
|
-
|
14
|
-
|
10
|
+
add_method_handler do |mh|
|
11
|
+
mh.match = lambda {
|
12
|
+
/\A(\w+)_attr/ =~ context.missing_method_name
|
13
|
+
context.attr_name = $1
|
14
|
+
return Regexp.last_match
|
15
|
+
}
|
15
16
|
|
16
|
-
|
17
|
+
mh.handle = lambda {
|
17
18
|
%Q{
|
18
|
-
def #{missing_method_name}
|
19
|
-
@#{
|
19
|
+
def #{context.missing_method_name}
|
20
|
+
@#{context.attr_name}_attr ||= Attribeautiful::Attribute.new("#{context.attr_name}")
|
20
21
|
end
|
21
22
|
}
|
22
|
-
|
23
|
+
}
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attribeautiful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eager_beaver
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0.0.
|
21
|
+
version: 0.0.4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.0.
|
29
|
+
version: 0.0.4
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: activesupport
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|