representative 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  require "representative/base"
2
2
 
3
3
  module Representative
4
-
4
+
5
5
  class AbstractXml < Base
6
6
 
7
7
  def initialize(subject = nil, options = {})
@@ -14,11 +14,11 @@ module Representative
14
14
  # Generate an element.
15
15
  #
16
16
  # With two arguments, it generates an element with the specified text content.
17
- #
17
+ #
18
18
  # r.element :size, 42
19
19
  # # => <size>42</size>
20
20
  #
21
- # More commonly, though, the second argument is omitted, in which case the
21
+ # More commonly, though, the second argument is omitted, in which case the
22
22
  # element content is assumed to be the named property of the current #subject.
23
23
  #
24
24
  # r.representing my_shoe do
@@ -46,11 +46,9 @@ module Representative
46
46
  metadata = @inspector.get_metadata(current_subject, name)
47
47
  attributes = args.extract_options!.merge(metadata)
48
48
 
49
- subject_of_element = if args.empty?
50
- lambda do |subject|
51
- @inspector.get_value(current_subject, name)
52
- end
53
- else
49
+ subject_of_element = if args.empty?
50
+ @inspector.get_value(current_subject, name)
51
+ else
54
52
  args.shift
55
53
  end
56
54
 
@@ -60,7 +58,7 @@ module Representative
60
58
 
61
59
  resolved_attributes = resolve_attributes(attributes)
62
60
  content_string = content_block = nil
63
-
61
+
64
62
  unless current_subject.nil?
65
63
  if block
66
64
  unless block == Representative::EMPTY
@@ -70,7 +68,7 @@ module Representative
70
68
  content_string = current_subject.to_s
71
69
  end
72
70
  end
73
-
71
+
74
72
  generate_element(format_name(name), resolved_attributes, content_string, &content_block)
75
73
 
76
74
  end
@@ -131,8 +129,8 @@ module Representative
131
129
  end
132
130
  end
133
131
  end
134
-
132
+
135
133
  end
136
-
134
+
137
135
  end
138
-
136
+
@@ -1,18 +1,18 @@
1
1
  require "representative/object_inspector"
2
2
 
3
3
  module Representative
4
-
4
+
5
5
  class Base
6
-
6
+
7
7
  def initialize(subject = nil, options = {})
8
8
  @subjects = [subject]
9
9
  @inspector = options[:inspector] || ObjectInspector.new
10
10
  @naming_strategy = options[:naming_strategy] || :plain
11
11
  end
12
12
 
13
- # Return the current "subject" of representation.
13
+ # Return the current "subject" of representation.
14
14
  #
15
- # This object will provide element values where they haven't been
15
+ # This object will provide element values where they haven't been
16
16
  # explicitly provided.
17
17
  #
18
18
  def current_subject
@@ -20,14 +20,14 @@ module Representative
20
20
  end
21
21
 
22
22
  alias :subject :current_subject
23
-
23
+
24
24
  # Evaluate a block with a specified object as #subject.
25
25
  #
26
26
  def representing(new_subject, &block)
27
27
  with_subject(resolve_value(new_subject), &block)
28
28
  end
29
29
 
30
- protected
30
+ protected
31
31
 
32
32
  def with_subject(subject)
33
33
  @subjects.push(subject)
@@ -49,7 +49,7 @@ module Representative
49
49
  value_generator
50
50
  end
51
51
  end
52
-
52
+
53
53
  def format_name(name)
54
54
  name = name.to_s
55
55
  case @naming_strategy
@@ -63,7 +63,7 @@ module Representative
63
63
  @naming_strategy.to_proc.call(name)
64
64
  end
65
65
  end
66
-
66
+
67
67
  end
68
-
68
+
69
69
  end
@@ -25,9 +25,7 @@ module Representative
25
25
  attributes = args.extract_options!.merge(metadata)
26
26
 
27
27
  subject_of_element = if args.empty?
28
- lambda do |subject|
29
- @inspector.get_value(current_subject, name)
30
- end
28
+ @inspector.get_value(current_subject, name)
31
29
  else
32
30
  args.shift
33
31
  end
@@ -1,3 +1,3 @@
1
1
  module Representative
2
- VERSION = "1.0.3".freeze
2
+ VERSION = "1.0.4".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: representative
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-10-28 00:00:00.000000000Z
12
+ date: 2011-11-05 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70306840912340 !ruby/object:Gem::Requirement
16
+ requirement: &70110341854200 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.2.2
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70306840912340
24
+ version_requirements: *70110341854200
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &70306841362100 !ruby/object:Gem::Requirement
27
+ requirement: &70110341852520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 0.4.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70306841362100
35
+ version_requirements: *70110341852520
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: builder
38
- requirement: &70306841799820 !ruby/object:Gem::Requirement
38
+ requirement: &70110341851600 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.1.2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70306841799820
46
+ version_requirements: *70110341851600
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: nokogiri
49
- requirement: &70306842178620 !ruby/object:Gem::Requirement
49
+ requirement: &70110341850920 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.4.2
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70306842178620
57
+ version_requirements: *70110341850920
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70306842185980 !ruby/object:Gem::Requirement
60
+ requirement: &70110341850100 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.8.7
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70306842185980
68
+ version_requirements: *70110341850100
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70306842545580 !ruby/object:Gem::Requirement
71
+ requirement: &70110341848720 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 2.5.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70306842545580
79
+ version_requirements: *70110341848720
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: tilt
82
- requirement: &70306843766040 !ruby/object:Gem::Requirement
82
+ requirement: &70110341841560 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0.9'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70306843766040
90
+ version_requirements: *70110341841560
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: diff-lcs
93
- requirement: &70306844090200 !ruby/object:Gem::Requirement
93
+ requirement: &70110341840580 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70306844090200
101
+ version_requirements: *70110341840580
102
102
  description:
103
103
  email: mdub@dogbiscuit.org
104
104
  executables: []
@@ -139,7 +139,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  segments:
141
141
  - 0
142
- hash: 1947364240128206184
142
+ hash: 156870103319875874
143
143
  required_rubygems_version: !ruby/object:Gem::Requirement
144
144
  none: false
145
145
  requirements:
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
148
  version: '0'
149
149
  segments:
150
150
  - 0
151
- hash: 1947364240128206184
151
+ hash: 156870103319875874
152
152
  requirements: []
153
153
  rubyforge_project:
154
154
  rubygems_version: 1.8.10