rss 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +6 -0
  4. data/Gemfile +6 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +88 -0
  7. data/Rakefile +10 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +8 -0
  10. data/lib/rss.rb +92 -0
  11. data/lib/rss/0.9.rb +462 -0
  12. data/lib/rss/1.0.rb +485 -0
  13. data/lib/rss/2.0.rb +143 -0
  14. data/lib/rss/atom.rb +1025 -0
  15. data/lib/rss/content.rb +34 -0
  16. data/lib/rss/content/1.0.rb +10 -0
  17. data/lib/rss/content/2.0.rb +12 -0
  18. data/lib/rss/converter.rb +171 -0
  19. data/lib/rss/dublincore.rb +164 -0
  20. data/lib/rss/dublincore/1.0.rb +13 -0
  21. data/lib/rss/dublincore/2.0.rb +13 -0
  22. data/lib/rss/dublincore/atom.rb +17 -0
  23. data/lib/rss/image.rb +198 -0
  24. data/lib/rss/itunes.rb +413 -0
  25. data/lib/rss/maker.rb +79 -0
  26. data/lib/rss/maker/0.9.rb +509 -0
  27. data/lib/rss/maker/1.0.rb +436 -0
  28. data/lib/rss/maker/2.0.rb +224 -0
  29. data/lib/rss/maker/atom.rb +173 -0
  30. data/lib/rss/maker/base.rb +945 -0
  31. data/lib/rss/maker/content.rb +22 -0
  32. data/lib/rss/maker/dublincore.rb +122 -0
  33. data/lib/rss/maker/entry.rb +164 -0
  34. data/lib/rss/maker/feed.rb +427 -0
  35. data/lib/rss/maker/image.rb +112 -0
  36. data/lib/rss/maker/itunes.rb +243 -0
  37. data/lib/rss/maker/slash.rb +34 -0
  38. data/lib/rss/maker/syndication.rb +19 -0
  39. data/lib/rss/maker/taxonomy.rb +119 -0
  40. data/lib/rss/maker/trackback.rb +62 -0
  41. data/lib/rss/parser.rb +589 -0
  42. data/lib/rss/rexmlparser.rb +50 -0
  43. data/lib/rss/rss.rb +1346 -0
  44. data/lib/rss/slash.rb +52 -0
  45. data/lib/rss/syndication.rb +69 -0
  46. data/lib/rss/taxonomy.rb +148 -0
  47. data/lib/rss/trackback.rb +291 -0
  48. data/lib/rss/utils.rb +200 -0
  49. data/lib/rss/xml-stylesheet.rb +106 -0
  50. data/lib/rss/xml.rb +72 -0
  51. data/lib/rss/xmlparser.rb +95 -0
  52. data/lib/rss/xmlscanner.rb +122 -0
  53. data/rss.gemspec +38 -0
  54. metadata +138 -0
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: false
2
+ require 'xmlscan/scanner'
3
+ require 'stringio'
4
+
5
+ module RSS
6
+
7
+ class XMLScanParser < BaseParser
8
+
9
+ class << self
10
+ def listener
11
+ XMLScanListener
12
+ end
13
+ end
14
+
15
+ private
16
+ def _parse
17
+ begin
18
+ if @rss.is_a?(String)
19
+ input = StringIO.new(@rss)
20
+ else
21
+ input = @rss
22
+ end
23
+ scanner = XMLScan::XMLScanner.new(@listener)
24
+ scanner.parse(input)
25
+ rescue XMLScan::Error => e
26
+ lineno = e.lineno || scanner.lineno || input.lineno
27
+ raise NotWellFormedError.new(lineno){e.message}
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ class XMLScanListener < BaseListener
34
+
35
+ include XMLScan::Visitor
36
+ include ListenerMixin
37
+
38
+ ENTITIES = {
39
+ 'lt' => '<',
40
+ 'gt' => '>',
41
+ 'amp' => '&',
42
+ 'quot' => '"',
43
+ 'apos' => '\''
44
+ }
45
+
46
+ def on_xmldecl_version(str)
47
+ @version = str
48
+ end
49
+
50
+ def on_xmldecl_encoding(str)
51
+ @encoding = str
52
+ end
53
+
54
+ def on_xmldecl_standalone(str)
55
+ @standalone = str
56
+ end
57
+
58
+ def on_xmldecl_end
59
+ xmldecl(@version, @encoding, @standalone == "yes")
60
+ end
61
+
62
+ alias_method(:on_pi, :instruction)
63
+ alias_method(:on_chardata, :text)
64
+ alias_method(:on_cdata, :text)
65
+
66
+ def on_etag(name)
67
+ tag_end(name)
68
+ end
69
+
70
+ def on_entityref(ref)
71
+ text(entity(ref))
72
+ end
73
+
74
+ def on_charref(code)
75
+ text([code].pack('U'))
76
+ end
77
+
78
+ alias_method(:on_charref_hex, :on_charref)
79
+
80
+ def on_stag(name)
81
+ @attrs = {}
82
+ end
83
+
84
+ def on_attribute(name)
85
+ @attrs[name] = @current_attr = ''
86
+ end
87
+
88
+ def on_attr_value(str)
89
+ @current_attr << str
90
+ end
91
+
92
+ def on_attr_entityref(ref)
93
+ @current_attr << entity(ref)
94
+ end
95
+
96
+ def on_attr_charref(code)
97
+ @current_attr << [code].pack('U')
98
+ end
99
+
100
+ alias_method(:on_attr_charref_hex, :on_attr_charref)
101
+
102
+ def on_stag_end(name)
103
+ tag_start(name, @attrs)
104
+ end
105
+
106
+ def on_stag_end_empty(name)
107
+ tag_start(name, @attrs)
108
+ tag_end(name)
109
+ end
110
+
111
+ private
112
+ def entity(ref)
113
+ ent = ENTITIES[ref]
114
+ if ent
115
+ ent
116
+ else
117
+ wellformed_error("undefined entity: #{ref}")
118
+ end
119
+ end
120
+ end
121
+
122
+ end
@@ -0,0 +1,38 @@
1
+ begin
2
+ require_relative "lib/rss"
3
+ rescue LoadError
4
+ # for Ruby core repository
5
+ require_relative "rss"
6
+ end
7
+
8
+ Gem::Specification.new do |spec|
9
+ spec.name = "rss"
10
+ spec.version = RSS::VERSION
11
+ spec.authors = ["Kouhei Sutou"]
12
+ spec.email = ["kou@cozmixng.org"]
13
+
14
+ spec.summary = %q{Family of libraries that support various formats of XML "feeds".}
15
+ spec.description = %q{Family of libraries that support various formats of XML "feeds".}
16
+ spec.homepage = "https://github.com/ruby/rss"
17
+ spec.license = "BSD-2-Clause"
18
+
19
+ spec.files = [".gitignore", ".travis.yml", "Gemfile", "LICENSE.txt", "README.md", "Rakefile",
20
+ "bin/console", "bin/setup", "lib/rss.rb", "lib/rss/0.9.rb", "lib/rss/1.0.rb", "lib/rss/2.0.rb",
21
+ "lib/rss/atom.rb", "lib/rss/content.rb", "lib/rss/content/1.0.rb", "lib/rss/content/2.0.rb",
22
+ "lib/rss/converter.rb", "lib/rss/dublincore.rb", "lib/rss/dublincore/1.0.rb", "lib/rss/dublincore/2.0.rb",
23
+ "lib/rss/dublincore/atom.rb", "lib/rss/image.rb", "lib/rss/itunes.rb", "lib/rss/maker.rb",
24
+ "lib/rss/maker/0.9.rb", "lib/rss/maker/1.0.rb", "lib/rss/maker/2.0.rb", "lib/rss/maker/atom.rb",
25
+ "lib/rss/maker/base.rb", "lib/rss/maker/content.rb", "lib/rss/maker/dublincore.rb", "lib/rss/maker/entry.rb",
26
+ "lib/rss/maker/feed.rb", "lib/rss/maker/image.rb", "lib/rss/maker/itunes.rb", "lib/rss/maker/slash.rb",
27
+ "lib/rss/maker/syndication.rb", "lib/rss/maker/taxonomy.rb", "lib/rss/maker/trackback.rb",
28
+ "lib/rss/parser.rb", "lib/rss/rexmlparser.rb", "lib/rss/rss.rb", "lib/rss/slash.rb", "lib/rss/syndication.rb",
29
+ "lib/rss/taxonomy.rb", "lib/rss/trackback.rb", "lib/rss/utils.rb", "lib/rss/xml-stylesheet.rb",
30
+ "lib/rss/xml.rb", "lib/rss/xmlparser.rb", "lib/rss/xmlscanner.rb", "rss.gemspec"]
31
+ spec.bindir = "exe"
32
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
33
+ spec.require_paths = ["lib"]
34
+
35
+ spec.add_development_dependency "bundler"
36
+ spec.add_development_dependency "rake"
37
+ spec.add_development_dependency "test-unit"
38
+ end
metadata ADDED
@@ -0,0 +1,138 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rss
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.7
5
+ platform: ruby
6
+ authors:
7
+ - Kouhei Sutou
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-12-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Family of libraries that support various formats of XML "feeds".
56
+ email:
57
+ - kou@cozmixng.org
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".travis.yml"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - lib/rss.rb
71
+ - lib/rss/0.9.rb
72
+ - lib/rss/1.0.rb
73
+ - lib/rss/2.0.rb
74
+ - lib/rss/atom.rb
75
+ - lib/rss/content.rb
76
+ - lib/rss/content/1.0.rb
77
+ - lib/rss/content/2.0.rb
78
+ - lib/rss/converter.rb
79
+ - lib/rss/dublincore.rb
80
+ - lib/rss/dublincore/1.0.rb
81
+ - lib/rss/dublincore/2.0.rb
82
+ - lib/rss/dublincore/atom.rb
83
+ - lib/rss/image.rb
84
+ - lib/rss/itunes.rb
85
+ - lib/rss/maker.rb
86
+ - lib/rss/maker/0.9.rb
87
+ - lib/rss/maker/1.0.rb
88
+ - lib/rss/maker/2.0.rb
89
+ - lib/rss/maker/atom.rb
90
+ - lib/rss/maker/base.rb
91
+ - lib/rss/maker/content.rb
92
+ - lib/rss/maker/dublincore.rb
93
+ - lib/rss/maker/entry.rb
94
+ - lib/rss/maker/feed.rb
95
+ - lib/rss/maker/image.rb
96
+ - lib/rss/maker/itunes.rb
97
+ - lib/rss/maker/slash.rb
98
+ - lib/rss/maker/syndication.rb
99
+ - lib/rss/maker/taxonomy.rb
100
+ - lib/rss/maker/trackback.rb
101
+ - lib/rss/parser.rb
102
+ - lib/rss/rexmlparser.rb
103
+ - lib/rss/rss.rb
104
+ - lib/rss/slash.rb
105
+ - lib/rss/syndication.rb
106
+ - lib/rss/taxonomy.rb
107
+ - lib/rss/trackback.rb
108
+ - lib/rss/utils.rb
109
+ - lib/rss/xml-stylesheet.rb
110
+ - lib/rss/xml.rb
111
+ - lib/rss/xmlparser.rb
112
+ - lib/rss/xmlscanner.rb
113
+ - rss.gemspec
114
+ homepage: https://github.com/ruby/rss
115
+ licenses:
116
+ - BSD-2-Clause
117
+ metadata: {}
118
+ post_install_message:
119
+ rdoc_options: []
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ requirements: []
133
+ rubyforge_project:
134
+ rubygems_version: 2.7.6
135
+ signing_key:
136
+ specification_version: 4
137
+ summary: Family of libraries that support various formats of XML "feeds".
138
+ test_files: []