attribeautiful 0.0.6 → 0.0.7

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.
@@ -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.1'
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
- add_method_matcher do |mm|
25
- mm.matcher = Proc.new do
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.to_s
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
- end
29
+ return Regexp.last_match
30
+ }
32
31
 
33
- mm.new_method_code_maker = Proc.new do
32
+ mh.handle = lambda {
34
33
  %Q{
35
- def #{missing_method_name}
36
- @#{@elem_name}_element ||= Attribeautiful::Element.new
34
+ def #{context.missing_method_name}
35
+ @#{context.elem_name}_element ||= Attribeautiful::Element.new
37
36
  end
38
37
  }
39
- end
38
+ }
40
39
  end
41
40
 
42
41
  ## handle <elem_name>_<attr_name>_attr methods
43
- add_method_matcher do |mm|
44
- mm.matcher = Proc.new do
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 "#{original_caller.class.html_element_names}"
47
- original_caller.class.html_element_names.detect{ |elem_name|
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.to_s
48
+ /\A(#{elem_name})_(\w+)_attr\z/ =~ context.missing_method_name
50
49
  }
51
- @elem_name = Regexp.last_match ? Regexp.last_match[1] : nil
52
- @attr_name = Regexp.last_match ? Regexp.last_match[2] : nil
50
+ context.elem_name = $1
51
+ context.attr_name = $2
53
52
  #puts "MATCHING: #{Regexp.last_match ? 'SUCESS' : 'FAILURE'}"
54
- Regexp.last_match
55
- end
53
+ return Regexp.last_match
54
+ }
56
55
 
57
- mm.new_method_code_maker = Proc.new do
56
+ mh.handle = lambda {
58
57
  %Q{
59
- def #{missing_method_name}
60
- #{@elem_name}_element.#{@attr_name}_attr ||= Attribeautiful::Attribute.new("#{@attr_name}")
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
- end
62
+ }
64
63
  end
65
64
 
66
65
  ## handle <elem_name>_<attr_name>_<attr_action> methods
67
- add_method_matcher do |mm|
68
- mm.matcher = Proc.new do
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 "#{original_caller.class.html_element_names}"
71
- original_caller.class.html_element_names.detect{ |elem_name|
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.to_s
74
+ /\A(#{elem_name})_(\w+)_(#{attr_action})\z/ =~ context.missing_method_name
76
75
  end
77
- }
78
- @elem_name = Regexp.last_match ? Regexp.last_match[1] : nil
79
- @attr_name = Regexp.last_match ? Regexp.last_match[2] : nil
80
- @attr_action = Regexp.last_match ? Regexp.last_match[3] : nil
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
- end
82
+ return Regexp.last_match
83
+ }
84
84
 
85
- mm.new_method_code_maker = Proc.new do
85
+ mh.handle = lambda {
86
86
  %Q{
87
- def #{@elem_name}_#{@attr_name}_#{@attr_action}(*args, &block)
88
- #{@elem_name}_#{@attr_name}_attr.#{@attr_action}(*args, &block)
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
- end
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
- add_method_matcher do |mm|
11
- mm.matcher = Proc.new do
12
- /\A(\w+)_attr/ =~ missing_method_name
13
- @attr_name = Regexp.last_match ? Regexp.last_match[1] : nil
14
- end
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
- mm.new_method_code_maker = Proc.new do
17
+ mh.handle = lambda {
17
18
  %Q{
18
- def #{missing_method_name}
19
- @#{@attr_name}_attr ||= Attribeautiful::Attribute.new("#{@attr_name}")
19
+ def #{context.missing_method_name}
20
+ @#{context.attr_name}_attr ||= Attribeautiful::Attribute.new("#{context.attr_name}")
20
21
  end
21
22
  }
22
- end
23
+ }
23
24
  end
24
25
  end
25
26
 
@@ -1,3 +1,3 @@
1
1
  module Attribeautiful
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
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.6
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-18 00:00:00.000000000 Z
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.1
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.1
29
+ version: 0.0.4
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: activesupport
32
32
  requirement: !ruby/object:Gem::Requirement