rss-dcterms 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/{README.md → README.markdown} +24 -4
- data/Rakefile +11 -0
- data/lib/rss/dcterms.rb +3 -0
- data/lib/rss/dcterms/{property/1.0.rb → 1.0.rb} +0 -0
- data/lib/rss/dcterms/{property/2.0.rb → 2.0.rb} +0 -0
- data/lib/rss/dcterms/{property/atom.rb → atom.rb} +0 -0
- data/lib/rss/dcterms/property.rb +33 -37
- data/lib/rss/dcterms/version.rb +1 -1
- data/lib/rss/maker/dcterms.rb +120 -0
- data/rss-dcterms.gemspec +2 -1
- metadata +30 -17
data/.gemtest
ADDED
File without changes
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
RSS::DCTERMS
|
2
|
+
============
|
2
3
|
|
3
4
|
Enables standard bundled RSS library parse and make feeds including DCMI Metadata Terms.
|
4
5
|
|
5
|
-
|
6
|
+
Installation
|
7
|
+
------------
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
@@ -20,14 +22,32 @@ Or
|
|
20
22
|
|
21
23
|
$ ruby setup.rb
|
22
24
|
|
23
|
-
|
25
|
+
Usage
|
26
|
+
-----
|
27
|
+
|
28
|
+
### Parsing Feeds
|
24
29
|
|
25
30
|
require 'rss/dcterms'
|
26
31
|
|
27
32
|
feed = RSS::Parser.parse(feed_uri)
|
28
33
|
publisher = feed.dcterms_publisher
|
29
34
|
|
30
|
-
|
35
|
+
### Making Feeds
|
36
|
+
|
37
|
+
require 'rss/maker/dcterms'
|
38
|
+
|
39
|
+
feed = RSS::Maker.make('atom') {|maker|
|
40
|
+
maker.channel.dcterms_issued = Time.now
|
41
|
+
# ...
|
42
|
+
}
|
43
|
+
|
44
|
+
Todo
|
45
|
+
----
|
46
|
+
|
47
|
+
* Turn off DC(http://purl.org/dc/elements/1.1/) elements when making feeds
|
48
|
+
|
49
|
+
Contributing
|
50
|
+
------------
|
31
51
|
|
32
52
|
1. Fork it
|
33
53
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,2 +1,13 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/testtask'
|
5
|
+
require 'yard'
|
6
|
+
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.ruby_opts << '-I test/rss'
|
11
|
+
t.test_files = FileList['test/**/test_*.rb']
|
12
|
+
end
|
13
|
+
YARD::Rake::YardocTask.new
|
data/lib/rss/dcterms.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/rss/dcterms/property.rb
CHANGED
@@ -9,7 +9,7 @@ module RSS
|
|
9
9
|
plural = plural_name || "#{name}s"
|
10
10
|
full_name = "#{PREFIX}_#{name}"
|
11
11
|
full_plural_name = "#{PREFIX}_#{plural}"
|
12
|
-
klass_name = Utils.to_class_name(name)
|
12
|
+
klass_name = "DCTERMS#{Utils.to_class_name(name)}"
|
13
13
|
klass.install_must_call_validator(PREFIX, URI)
|
14
14
|
klass.install_have_children_element(name, URI, "*",
|
15
15
|
full_name, full_plural_name)
|
@@ -56,64 +56,64 @@ module RSS
|
|
56
56
|
|
57
57
|
TEXT_ELEMENTS = {
|
58
58
|
"contributor" => nil,
|
59
|
-
"creator"
|
59
|
+
"creator" => nil,
|
60
60
|
|
61
61
|
"coverage" => nil,
|
62
|
-
"spatial"
|
62
|
+
"spatial" => nil,
|
63
63
|
"temporal" => nil,
|
64
64
|
|
65
|
-
"description"
|
66
|
-
"abstract"
|
65
|
+
"description" => nil,
|
66
|
+
"abstract" => nil,
|
67
67
|
"tableOfContents" => "tableOfContents_list",
|
68
68
|
|
69
69
|
"format" => nil,
|
70
70
|
"extent" => nil,
|
71
71
|
"medium" => nil,
|
72
72
|
|
73
|
-
"identifier"
|
73
|
+
"identifier" => nil,
|
74
74
|
"bibliographicCitation" => nil,
|
75
75
|
|
76
76
|
"language" => nil,
|
77
77
|
|
78
78
|
"publisher" => nil,
|
79
79
|
|
80
|
-
"relation"
|
81
|
-
"source"
|
82
|
-
"conformsTo"
|
83
|
-
"hasFormat"
|
84
|
-
"hasPart"
|
85
|
-
"hasVersion"
|
86
|
-
"isFormatOf"
|
87
|
-
"isPartOf"
|
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
88
|
"isReferencedBy" => nil,
|
89
|
-
"isReplacedBy"
|
90
|
-
"isRequiredBy"
|
91
|
-
"isVersionOf"
|
92
|
-
"references"
|
93
|
-
"replaces"
|
94
|
-
"requires"
|
95
|
-
|
96
|
-
"rights"
|
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
97
|
"accessRights" => "accessRights_list",
|
98
|
-
"license"
|
98
|
+
"license" => nil,
|
99
99
|
|
100
100
|
"subject" => nil,
|
101
101
|
|
102
|
-
"title"
|
102
|
+
"title" => nil,
|
103
103
|
"alternative" => nil,
|
104
104
|
|
105
105
|
"type" => nil,
|
106
106
|
|
107
|
-
"audience"
|
107
|
+
"audience" => nil,
|
108
108
|
"educationLevel" => nil,
|
109
|
-
"mediator"
|
109
|
+
"mediator" => nil,
|
110
110
|
|
111
|
-
"accrualMethod"
|
112
|
-
"accrualPeriodicity"
|
113
|
-
"accrualPolicy"
|
111
|
+
"accrualMethod" => nil,
|
112
|
+
"accrualPeriodicity" => nil,
|
113
|
+
"accrualPolicy" => nil,
|
114
114
|
"instructionalMethod" => nil,
|
115
|
-
"provenance"
|
116
|
-
"rightsHolder"
|
115
|
+
"provenance" => nil,
|
116
|
+
"rightsHolder" => nil
|
117
117
|
}
|
118
118
|
|
119
119
|
DATE_ELEMENTS = {
|
@@ -137,7 +137,7 @@ module RSS
|
|
137
137
|
|
138
138
|
ELEMENTS.each do |name, plural_name|
|
139
139
|
module_eval(<<-EOC, *get_file_and_line_from_caller(0))
|
140
|
-
class #{Utils.to_class_name(name)} < Element
|
140
|
+
class DCTERMS#{Utils.to_class_name(name)} < Element
|
141
141
|
include RSS10
|
142
142
|
|
143
143
|
content_setup
|
@@ -184,7 +184,7 @@ module RSS
|
|
184
184
|
DATE_ELEMENTS.each do |name, type|
|
185
185
|
tag_name = "#{PREFIX}:#{name}"
|
186
186
|
module_eval(<<-EOC, *get_file_and_line_from_caller(0))
|
187
|
-
class #{Utils.to_class_name(name)} < Element
|
187
|
+
class DCTERMS#{Utils.to_class_name(name)} < Element
|
188
188
|
remove_method(:content=)
|
189
189
|
remove_method(:value=)
|
190
190
|
|
@@ -204,7 +204,3 @@ module RSS
|
|
204
204
|
DCTERMS::PropertyModel::ELEMENTS.collect! {|name| "#{PREFIX}_#{name}"}
|
205
205
|
end
|
206
206
|
end
|
207
|
-
|
208
|
-
require 'rss/dcterms/property/1.0'
|
209
|
-
require 'rss/dcterms/property/2.0'
|
210
|
-
require 'rss/dcterms/property/atom'
|
data/lib/rss/dcterms/version.rb
CHANGED
@@ -0,0 +1,120 @@
|
|
1
|
+
require 'rss/dcterms'
|
2
|
+
require 'rss/maker'
|
3
|
+
|
4
|
+
module RSS
|
5
|
+
module Maker
|
6
|
+
module DCTERMS
|
7
|
+
module PropertyModel
|
8
|
+
class << self
|
9
|
+
def append_features(klass)
|
10
|
+
super
|
11
|
+
|
12
|
+
::RSS::DCTERMS::PropertyModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
|
13
|
+
plural_name ||= "#{name}s"
|
14
|
+
full_name = "#{RSS::DCTERMS::PREFIX}_#{name}"
|
15
|
+
full_plural_name = "#{RSS::DCTERMS::PREFIX}_#{plural_name}"
|
16
|
+
plural_klass_name = "DCTERMS#{Utils.to_class_name(plural_name)}"
|
17
|
+
klass.def_classed_elements full_name, 'value', plural_klass_name,
|
18
|
+
full_plural_name, name
|
19
|
+
klass.module_eval(<<-EOC)
|
20
|
+
def new_#{full_name}(value=nil)
|
21
|
+
_#{full_name} = #{full_plural_name}.new_#{name}
|
22
|
+
_#{full_name}.value = value
|
23
|
+
if block_given?
|
24
|
+
yield _#{full_name}
|
25
|
+
else
|
26
|
+
_#{full_name}
|
27
|
+
end
|
28
|
+
end
|
29
|
+
EOC
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def install_dcterms_core(klass)
|
34
|
+
::RSS::DCTERMS::PropertyModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
|
35
|
+
plural_name ||= "#{name}s"
|
36
|
+
klass_name = Utils.to_class_name(name)
|
37
|
+
full_klass_name = "DCTERMS#{klass_name}"
|
38
|
+
plural_klass_name = "DCTERMS#{Utils.to_class_name(plural_name)}"
|
39
|
+
klass.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
40
|
+
class #{plural_klass_name} < #{plural_klass_name}Base
|
41
|
+
class #{full_klass_name} < #{full_klass_name}Base
|
42
|
+
end
|
43
|
+
#{klass_name} = #{full_klass_name}
|
44
|
+
end
|
45
|
+
EOC
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
::RSS::DCTERMS::PropertyModel::ELEMENT_NAME_INFOS.each do |name, plural_name|
|
51
|
+
plural_name ||= "#{name}s"
|
52
|
+
full_name = "#{RSS::DCTERMS::PREFIX}_#{name}"
|
53
|
+
full_plural_name = "#{RSS::DCTERMS::PREFIX}_#{plural_name}"
|
54
|
+
klass_name = Utils.to_class_name(name)
|
55
|
+
full_klass_name = "DCTERMS#{klass_name}"
|
56
|
+
plural_klass_name = "DCTERMS#{Utils.to_class_name(plural_name)}"
|
57
|
+
module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
58
|
+
class #{plural_klass_name}Base < Base
|
59
|
+
def_array_element #{name.dump}, #{full_plural_name.dump},
|
60
|
+
#{full_klass_name.dump}
|
61
|
+
|
62
|
+
class #{full_klass_name}Base < Base
|
63
|
+
attr_accessor :value
|
64
|
+
add_need_initialize_variable 'value'
|
65
|
+
alias_method :content, :value
|
66
|
+
alias_method :content=, :value=
|
67
|
+
|
68
|
+
def have_required_values?
|
69
|
+
@value
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_feed(feed, current)
|
73
|
+
if value and current.respond_to? :#{full_name}
|
74
|
+
new_item = current.class::#{full_klass_name}.new(value)
|
75
|
+
current.#{full_plural_name} << new_item
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
#{klass_name}Base = #{full_klass_name}Base
|
80
|
+
end
|
81
|
+
EOC
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
class ChannelBase
|
87
|
+
include DCTERMS::PropertyModel
|
88
|
+
end
|
89
|
+
|
90
|
+
class ImageBase; include DCTERMS::PropertyModel; end
|
91
|
+
class ItemsBase
|
92
|
+
class ItemBase
|
93
|
+
include DCTERMS::PropertyModel
|
94
|
+
end
|
95
|
+
end
|
96
|
+
class TextinputBase; include DCTERMS::PropertyModel; end
|
97
|
+
|
98
|
+
makers.each do |maker|
|
99
|
+
maker.module_eval(<<-EOC, __FILE__, __LINE__ + 1)
|
100
|
+
class Channel
|
101
|
+
DCTERMS::PropertyModel.install_dcterms_core self
|
102
|
+
end
|
103
|
+
|
104
|
+
class Image
|
105
|
+
DCTERMS::PropertyModel.install_dcterms_core self
|
106
|
+
end
|
107
|
+
|
108
|
+
class Items
|
109
|
+
class Item
|
110
|
+
DCTERMS::PropertyModel.install_dcterms_core self
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class Textinput
|
115
|
+
DCTERMS::PropertyModel.install_dcterms_core self
|
116
|
+
end
|
117
|
+
EOC
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
data/rss-dcterms.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |gem|
|
|
6
6
|
gem.email = ["KitaitiMakoto@gmail.com"]
|
7
7
|
gem.description = %q{Enable standard bundled RSS library parse and make feeds including DCMI(Dublin Core Metadata Initiative) Metadata Terms}
|
8
8
|
gem.summary = %q{DCTERMS support for standard bundled RSS library}
|
9
|
-
gem.homepage = "
|
9
|
+
gem.homepage = "http://rss-ext.rubyforge.org/"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
12
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency 'pry'
|
20
20
|
gem.add_development_dependency 'pry-doc'
|
21
21
|
gem.add_development_dependency 'yard'
|
22
|
+
gem.add_development_dependency 'redcarpet'
|
22
23
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rss-dcterms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.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: 2012-
|
12
|
+
date: 2012-10-11 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: test-unit
|
16
|
-
requirement: &
|
16
|
+
requirement: &19082920 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *19082920
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: pry
|
27
|
-
requirement: &
|
27
|
+
requirement: &19080500 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *19080500
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: pry-doc
|
38
|
-
requirement: &
|
38
|
+
requirement: &19077620 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *19077620
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: yard
|
49
|
-
requirement: &
|
49
|
+
requirement: &19075780 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,7 +54,18 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *19075780
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: redcarpet
|
60
|
+
requirement: &19088300 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *19088300
|
58
69
|
description: Enable standard bundled RSS library parse and make feeds including DCMI(Dublin
|
59
70
|
Core Metadata Initiative) Metadata Terms
|
60
71
|
email:
|
@@ -63,20 +74,22 @@ executables: []
|
|
63
74
|
extensions: []
|
64
75
|
extra_rdoc_files: []
|
65
76
|
files:
|
77
|
+
- .gemtest
|
66
78
|
- .gitignore
|
67
79
|
- Gemfile
|
68
80
|
- LICENSE
|
69
|
-
- README.
|
81
|
+
- README.markdown
|
70
82
|
- Rakefile
|
71
83
|
- lib/rss/dcterms.rb
|
84
|
+
- lib/rss/dcterms/1.0.rb
|
85
|
+
- lib/rss/dcterms/2.0.rb
|
86
|
+
- lib/rss/dcterms/atom.rb
|
72
87
|
- lib/rss/dcterms/property.rb
|
73
|
-
- lib/rss/dcterms/property/1.0.rb
|
74
|
-
- lib/rss/dcterms/property/2.0.rb
|
75
|
-
- lib/rss/dcterms/property/atom.rb
|
76
88
|
- lib/rss/dcterms/version.rb
|
89
|
+
- lib/rss/maker/dcterms.rb
|
77
90
|
- rss-dcterms.gemspec
|
78
91
|
- setup.rb
|
79
|
-
homepage:
|
92
|
+
homepage: http://rss-ext.rubyforge.org/
|
80
93
|
licenses: []
|
81
94
|
post_install_message:
|
82
95
|
rdoc_options: []
|
@@ -90,7 +103,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
90
103
|
version: '0'
|
91
104
|
segments:
|
92
105
|
- 0
|
93
|
-
hash:
|
106
|
+
hash: 1661997683346475596
|
94
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
108
|
none: false
|
96
109
|
requirements:
|
@@ -99,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
112
|
version: '0'
|
100
113
|
segments:
|
101
114
|
- 0
|
102
|
-
hash:
|
115
|
+
hash: 1661997683346475596
|
103
116
|
requirements: []
|
104
117
|
rubyforge_project:
|
105
118
|
rubygems_version: 1.8.8
|