representable 0.13.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ h2. 1.0.0
2
+
3
+ * 1.0.0 release! Party time!
4
+
1
5
  h2. 0.13.1
2
6
 
3
7
  * Removed property :@name from @XML@ in favor of @:attribute => true@.
@@ -44,7 +44,7 @@ To use your representer include it in the matching class. Note that you could re
44
44
  class Hero
45
45
  attr_accessor :forename, :surename
46
46
 
47
- include Representable
47
+ include Representable
48
48
  include HeroRepresenter
49
49
  end
50
50
 
@@ -215,13 +215,13 @@ Representers roughly follow the {DCI}[http://en.wikipedia.org/wiki/Data,_context
215
215
 
216
216
  The only difference is that you have to define which representers to use for typed properties.
217
217
 
218
- module HeroRepresenter
219
- property :forename
220
- property :surename
221
- collection :features
222
- property :origin, :class => Location
223
- collection :friends, :class => Hero, :extend => HeroRepresenter
224
- end
218
+ module HeroRepresenter
219
+ property :forename
220
+ property :surename
221
+ collection :features
222
+ property :origin, :class => Location
223
+ collection :friends, :class => Hero, :extend => HeroRepresenter
224
+ end
225
225
 
226
226
  There's no need to specify a representer for the +origin+ property since the +Location+ class statically includes its representation. For +friends+, we can use +:extend+ to tell representable which module to mix in dynamically.
227
227
 
@@ -250,6 +250,21 @@ Representable allows declaring a document's syntax and structure while having di
250
250
 
251
251
  The #to_xml method gives us an XML representation of Peter - great!
252
252
 
253
+ === Mapping tag attributes
254
+
255
+ You can also map properties to tag attributes in representable.
256
+
257
+ class Hero
258
+ attr_accessor :name
259
+ include Representable::XML
260
+ property :name, :attribute => true
261
+ end
262
+
263
+ Hero.new(:name => "Peter Pan").to_xml
264
+ #=> <hero name="Peter Pan" />
265
+
266
+ Naturally, this works for both ways.
267
+
253
268
 
254
269
  == More
255
270
 
@@ -1,5 +1,29 @@
1
1
  require 'representable/definition'
2
2
 
3
+ # Representable can be used in two ways.
4
+ #
5
+ # == On class level
6
+ #
7
+ # To try out Representable you might include the format module into the represented class directly and then
8
+ # define the properties.
9
+ #
10
+ # class Hero < ActiveRecord::Base
11
+ # include Representable::JSON
12
+ # property :name
13
+ #
14
+ # This will give you to_/from_json for each instance. However, this approach limits your class to one representation.
15
+ #
16
+ # == On module level
17
+ #
18
+ # Modules give you much more flexibility since you can mix them into objects at runtime, roughly following the DCI
19
+ # pattern.
20
+ #
21
+ # module HeroRepresenter
22
+ # include Representable::JSON
23
+ # property :name
24
+ # end
25
+ #
26
+ # hero.extend(HeroRepresenter).to_json
3
27
  module Representable
4
28
  def self.included(base)
5
29
  base.class_eval do
@@ -1,3 +1,3 @@
1
1
  module Representable
2
- VERSION = "0.13.1"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -24,6 +24,6 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_development_dependency "rake"
26
26
  s.add_development_dependency "test_xml"
27
- s.add_development_dependency "minitest", "~>2.8"
27
+ s.add_development_dependency "minitest", "=2.8.1"
28
28
  s.add_development_dependency "mocha"
29
29
  end
metadata CHANGED
@@ -1,113 +1,91 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: representable
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 13
8
- - 1
9
- version: 0.13.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Nick Sutterer
13
9
  autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
-
17
- date: 2011-12-27 00:00:00 +01:00
18
- default_executable:
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2011-12-27 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: nokogiri
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &72760530 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- segments:
29
- - 0
30
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
31
22
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: json
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *72760530
25
+ - !ruby/object:Gem::Dependency
26
+ name: json
27
+ requirement: &72760260 !ruby/object:Gem::Requirement
37
28
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 0
43
- version: "0"
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
44
33
  type: :runtime
45
- version_requirements: *id002
46
- - !ruby/object:Gem::Dependency
47
- name: rake
48
34
  prerelease: false
49
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *72760260
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &72760000 !ruby/object:Gem::Requirement
50
39
  none: false
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- segments:
55
- - 0
56
- version: "0"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
57
44
  type: :development
58
- version_requirements: *id003
59
- - !ruby/object:Gem::Dependency
60
- name: test_xml
61
45
  prerelease: false
62
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *72760000
47
+ - !ruby/object:Gem::Dependency
48
+ name: test_xml
49
+ requirement: &72759760 !ruby/object:Gem::Requirement
63
50
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- segments:
68
- - 0
69
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
70
55
  type: :development
71
- version_requirements: *id004
72
- - !ruby/object:Gem::Dependency
73
- name: minitest
74
56
  prerelease: false
75
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *72759760
58
+ - !ruby/object:Gem::Dependency
59
+ name: minitest
60
+ requirement: &72759480 !ruby/object:Gem::Requirement
76
61
  none: false
77
- requirements:
78
- - - ~>
79
- - !ruby/object:Gem::Version
80
- segments:
81
- - 2
82
- - 8
83
- version: "2.8"
62
+ requirements:
63
+ - - =
64
+ - !ruby/object:Gem::Version
65
+ version: 2.8.1
84
66
  type: :development
85
- version_requirements: *id005
86
- - !ruby/object:Gem::Dependency
87
- name: mocha
88
67
  prerelease: false
89
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *72759480
69
+ - !ruby/object:Gem::Dependency
70
+ name: mocha
71
+ requirement: &72759220 !ruby/object:Gem::Requirement
90
72
  none: false
91
- requirements:
92
- - - ">="
93
- - !ruby/object:Gem::Version
94
- segments:
95
- - 0
96
- version: "0"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
97
77
  type: :development
98
- version_requirements: *id006
99
- description: Maps representation documents from and to Ruby objects. Includes XML and JSON support, plain properties, collections and compositions.
100
- email:
78
+ prerelease: false
79
+ version_requirements: *72759220
80
+ description: Maps representation documents from and to Ruby objects. Includes XML
81
+ and JSON support, plain properties, collections and compositions.
82
+ email:
101
83
  - apotonick@gmail.com
102
84
  executables: []
103
-
104
85
  extensions: []
105
-
106
86
  extra_rdoc_files: []
107
-
108
- files:
87
+ files:
109
88
  - .gitignore
110
- - .gitmodules
111
89
  - .rspec
112
90
  - .travis.yml
113
91
  - CHANGES.textile
@@ -130,37 +108,29 @@ files:
130
108
  - test/representable_test.rb
131
109
  - test/test_helper.rb
132
110
  - test/xml_test.rb
133
- has_rdoc: true
134
111
  homepage: http://representable.apotomo.de
135
112
  licenses: []
136
-
137
113
  post_install_message:
138
114
  rdoc_options: []
139
-
140
- require_paths:
115
+ require_paths:
141
116
  - lib
142
- required_ruby_version: !ruby/object:Gem::Requirement
117
+ required_ruby_version: !ruby/object:Gem::Requirement
143
118
  none: false
144
- requirements:
145
- - - ">="
146
- - !ruby/object:Gem::Version
147
- segments:
148
- - 0
149
- version: "0"
150
- required_rubygems_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ! '>='
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
124
  none: false
152
- requirements:
153
- - - ">="
154
- - !ruby/object:Gem::Version
155
- segments:
156
- - 0
157
- version: "0"
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
158
129
  requirements: []
159
-
160
130
  rubyforge_project:
161
- rubygems_version: 1.3.7
131
+ rubygems_version: 1.8.10
162
132
  signing_key:
163
133
  specification_version: 3
164
- summary: Maps representation documents from and to Ruby objects. Includes XML and JSON support, plain properties, collections and compositions.
134
+ summary: Maps representation documents from and to Ruby objects. Includes XML and
135
+ JSON support, plain properties, collections and compositions.
165
136
  test_files: []
166
-
@@ -1,3 +0,0 @@
1
- [submodule "vendor/override_rake_task"]
2
- path = vendor/override_rake_task
3
- url = git://github.com/Empact/override_rake_task.git