rss-dcterms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
19
+ vendor/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in rss-dcterms.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 KITAITI Makoto
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # RSS::DCTERMS
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rss-dcterms'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rss-dcterms
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
@@ -0,0 +1,10 @@
1
+ require 'rss'
2
+
3
+ module RSS
4
+ module DCTERMS
5
+ PREFIX = 'dcterms'
6
+ URI = "http://purl.org/dc/terms/"
7
+ end
8
+ end
9
+
10
+ require 'rss/dcterms/property'
@@ -0,0 +1,229 @@
1
+ module RSS
2
+ module DCTERMS
3
+ module BasePropertyModel
4
+ def append_features(klass)
5
+ super
6
+
7
+ return if klass.instance_of?(Module)
8
+ PropertyModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
9
+ plural = plural_name || "#{name}s"
10
+ full_name = "#{PREFIX}_#{name}"
11
+ full_plural_name = "#{PREFIX}_#{plural}"
12
+ klass_name = "DCTERMS#{Utils.to_class_name(name)}"
13
+ klass.install_must_call_validator(PREFIX, URI)
14
+ klass.install_have_children_element(name, URI, "*",
15
+ full_name, full_plural_name)
16
+ klass.module_eval(<<-EOC, *get_file_and_line_from_caller(0))
17
+ remove_method :#{full_name}
18
+ remove_method :#{full_name}=
19
+ remove_method :set_#{full_name}
20
+
21
+ def #{full_name}
22
+ @#{full_name}.first and @#{full_name}.first.value
23
+ end
24
+ alias #{to_attr_name(full_name)} #{full_name}
25
+
26
+ def #{full_name}=(new_value)
27
+ @#{full_name}[0] = Utils.new_with_value_if_need(#{klass_name}, new_value)
28
+ end
29
+ alias set_#{full_name} #{full_name}=
30
+ alias #{to_attr_name(full_name)}= #{full_name}=
31
+ alias set_#{to_attr_name(full_name)} #{full_name}=
32
+
33
+ alias #{to_attr_name(full_plural_name)} #{full_plural_name}
34
+ EOC
35
+ end
36
+ klass.module_eval(<<-EOC, *get_file_and_line_from_caller(0))
37
+ if method_defined?(:date)
38
+ alias date_without_#{PREFIX}_date= date=
39
+
40
+ def date=(value)
41
+ self.date_without_#{PREFIX}_date = value
42
+ self.#{PREFIX}_date = value
43
+ end
44
+ else
45
+ alias date #{PREFIX}_date
46
+ alias date= #{PREFIX}_date=
47
+ end
48
+ EOC
49
+ end
50
+ end
51
+
52
+ module PropertyModel
53
+
54
+ extend BaseModel
55
+ extend BasePropertyModel
56
+
57
+ TEXT_ELEMENTS = {
58
+ "contributor" => nil,
59
+ "creator" => nil,
60
+
61
+ "coverage" => nil,
62
+ "spatial" => nil,
63
+ "temporal" => nil,
64
+
65
+ "description" => nil,
66
+ "abstract" => nil,
67
+ "tableOfContents" => "tableOfContents_list",
68
+
69
+ "format" => nil,
70
+ "extent" => nil,
71
+ "medium" => nil,
72
+
73
+ "identifier" => nil,
74
+ "bibliographicCitation" => nil,
75
+
76
+ "language" => nil,
77
+
78
+ "publisher" => nil,
79
+
80
+ "relation" => nil,
81
+ "source" => nil,
82
+ "conformsTo" => nil,
83
+ "hasFormat" => nil,
84
+ "hasPart" => nil,
85
+ "hasVersion" => nil,
86
+ "isFormatOf" => nil,
87
+ "isPartOf" => nil,
88
+ "isReferencedBy" => nil,
89
+ "isReplacedBy" => nil,
90
+ "isRequiredBy" => nil,
91
+ "isVersionOf" => nil,
92
+ "references" => "references_list",
93
+ "replaces" => "replaces_list",
94
+ "requires" => "requires_list",
95
+
96
+ "rights" => "rights_list",
97
+ "accessRights" => "accessRights_list",
98
+ "license" => nil,
99
+
100
+ "subject" => nil,
101
+
102
+ "title" => nil,
103
+ "alternative" => nil,
104
+
105
+ "type" => nil,
106
+
107
+ "audience" => nil,
108
+ "educationLevel" => nil,
109
+ "mediator" => nil,
110
+
111
+ "accrualMethod" => nil,
112
+ "accrualPeriodicity" => nil,
113
+ "accrualPolicy" => nil,
114
+ "instructionalMethod" => nil,
115
+ "provenance" => nil,
116
+ "rightsHolder" => nil
117
+ }
118
+
119
+ DATE_ELEMENTS = {
120
+ "date" => "w3cdtf",
121
+ "available" => "w3cdtf",
122
+ "created" => "w3cdtf",
123
+ "dateAccepted" => "w3cdtf",
124
+ "dateCopyrighted" => "w3cdtf",
125
+ "dateSubmitted" => "w3cdtf",
126
+ "issued" => "w3cdtf",
127
+ "modified" => "w3cdtf",
128
+ "valid" => "w3cdtf"
129
+ }
130
+
131
+ ELEMENT_NAME_INFOS = PropertyModel::TEXT_ELEMENTS.to_a
132
+ PropertyModel::DATE_ELEMENTS.each do |name, |
133
+ ELEMENT_NAME_INFOS << [name, nil]
134
+ end
135
+
136
+ ELEMENTS = TEXT_ELEMENTS.keys + DATE_ELEMENTS.keys
137
+
138
+ ELEMENTS.each do |name, plural_name|
139
+ module_eval(<<-EOC, *get_file_and_line_from_caller(0))
140
+ class DCTERMS#{Utils.to_class_name(name)} < Element
141
+ include RSS10
142
+
143
+ content_setup
144
+
145
+ class << self
146
+ def required_prefix
147
+ PREFIX
148
+ end
149
+
150
+ def required_uri
151
+ URI
152
+ end
153
+ end
154
+
155
+ @tag_name = #{name.dump}
156
+
157
+ alias_method(:value, :content)
158
+ alias_method(:value=, :content=)
159
+
160
+ def initialize(*args)
161
+ if Utils.element_initialize_arguments?(args)
162
+ super
163
+ else
164
+ super()
165
+ self.content = args[0]
166
+ end
167
+ end
168
+
169
+ def full_name
170
+ tag_name_with_prefix(PREFIX)
171
+ end
172
+
173
+ def maker_target(target)
174
+ target.new_#{name}
175
+ end
176
+
177
+ def setup_maker_attributes(#{name})
178
+ #{name}.content = content
179
+ end
180
+ end
181
+ EOC
182
+ end
183
+
184
+ DATE_ELEMENTS.each do |name, type|
185
+ tag_name = "#{PREFIX}:#{name}"
186
+ module_eval(<<-EOC, *get_file_and_line_from_caller(0))
187
+ class DCTERMS#{Utils.to_class_name(name)} < Element
188
+ remove_method(:content=)
189
+ remove_method(:value=)
190
+
191
+ date_writer("content", #{type.dump}, #{tag_name.dump})
192
+
193
+ alias_method(:value=, :content=)
194
+ end
195
+ EOC
196
+ end
197
+ end
198
+
199
+ DCTERMS::PropertyModel::ELEMENTS.each do |name|
200
+ class_name = Utils.to_class_name(name)
201
+ BaseListener.install_class_name(URI, name, "DCTERMS#{class_name}")
202
+ end
203
+
204
+ DCTERMS::PropertyModel::ELEMENTS.collect! {|name| "#{PREFIX}_#{name}"}
205
+ end
206
+ end
207
+
208
+ module RSS
209
+ module Utils
210
+ module_function
211
+
212
+ def to_attr_name(name)
213
+ name.gsub(/([A-Z])/) {'_' + $1.downcase}
214
+ end
215
+ end
216
+
217
+ module Atom
218
+ Feed.install_ns(DCTERMS::PREFIX, DCTERMS::URI)
219
+
220
+ class Feed
221
+ include DCTERMS::PropertyModel
222
+ class Entry; include DCTERMS::PropertyModel; end
223
+ end
224
+
225
+ class Entry
226
+ include DCTERMS::PropertyModel
227
+ end
228
+ end
229
+ end
@@ -0,0 +1,18 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |gem|
3
+ gem.authors = ["KITAITI Makoto"]
4
+ gem.email = ["KitaitiMakoto@gmail.com"]
5
+ gem.description = %q{Enable standard bundled RSS library parse and make using DCMI Metadata Terms}
6
+ gem.summary = %q{DCTERMS support for standard bundled RSS library}
7
+ gem.homepage = "https://gitorious.org/rss/dcterms"
8
+
9
+ gem.files = `git ls-files`.split($\)
10
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
11
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
12
+ gem.name = "rss-dcterms"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = '0.0.1'
15
+
16
+ gem.add_development_dependency 'pry'
17
+ gem.add_development_dependency 'pry-doc'
18
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rss-dcterms
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - KITAITI Makoto
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-01 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ requirement: &22446500 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *22446500
25
+ - !ruby/object:Gem::Dependency
26
+ name: pry-doc
27
+ requirement: &22446020 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *22446020
36
+ description: Enable standard bundled RSS library parse and make using DCMI Metadata
37
+ Terms
38
+ email:
39
+ - KitaitiMakoto@gmail.com
40
+ executables: []
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - LICENSE
47
+ - README.md
48
+ - Rakefile
49
+ - lib/rss/dcterms.rb
50
+ - lib/rss/dcterms/property.rb
51
+ - rss-dcterms.gemspec
52
+ homepage: https://gitorious.org/rss/dcterms
53
+ licenses: []
54
+ post_install_message:
55
+ rdoc_options: []
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ! '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ segments:
65
+ - 0
66
+ hash: -4198529532967653785
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ segments:
74
+ - 0
75
+ hash: -4198529532967653785
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 1.8.8
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: DCTERMS support for standard bundled RSS library
82
+ test_files: []
83
+ has_rdoc: