feedjira-opml 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -20
- data/feedjira-opml.gemspec +1 -0
- data/lib/feedjira/opml/version.rb +1 -1
- data/lib/feedjira/parser/opml_head.rb +33 -8
- data/lib/feedjira/parser/opml_outline.rb +27 -4
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 08527b867147e345f87f219b2a948b0b5c7b15ab
|
4
|
+
data.tar.gz: d937389bbc4bf1ea30ca557dae8bbda16d4917e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf06beb6bd7995d17cb3cc541c6196b4ecf3a2d2e1456e9de236d461528e507d558e56d73ae674ef45f439ee8117c17d6d7173b76dee147328032df92a9ef02c
|
7
|
+
data.tar.gz: 07d5288c8e396c3e88bc7d562fff624ec424033158e8e2047f805abcf70b979b621b4318b873495299e4af7810884dd5ad4f2a8f499f41e05a2ff151dcd1d960
|
data/README.md
CHANGED
@@ -1,39 +1,54 @@
|
|
1
1
|
# Feedjira::Opml
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/feedjira-opml.svg)](https://rubygems.org/gems/feedjira-opml)
|
4
|
+
[![Dependency Status](https://gemnasium.com/farski/feedjira-opml.svg)](https://gemnasium.com/farski/feedjira-opml)
|
5
|
+
[![Build Status](https://travis-ci.org/farski/feedjira-opml.svg)](https://travis-ci.org/farski/feedjira-opml)
|
6
|
+
[![Code Climate](https://codeclimate.com/github/farski/feedjira-opml/badges/gpa.svg)](https://codeclimate.com/github/farski/feedjira-opml)
|
7
|
+
[![Coverage Status](https://coveralls.io/repos/farski/feedjira-opml/badge.svg)](https://coveralls.io/r/farski/feedjira-opml)
|
4
8
|
|
5
|
-
|
9
|
+
This gem registers a new parser with [Feedjira](http://feedjira.com/) which provides basic support for OPML files. It is based on OPML version 2.0, but does not currently support all aspects of the specification (directories, for example, are not supported).
|
6
10
|
|
7
|
-
|
11
|
+
Beyond what is provided by [Feedjira](https://github.com/feedjira/feedjira), there is no support for converting OPML files to hashes, or generating valid OPML from other data sources.
|
8
12
|
|
9
|
-
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
Since **feedjira-opml** automatically registers its OPML parser with Feedjira, using the standard processing methods should generally yield the desired results.
|
10
16
|
|
11
17
|
```ruby
|
12
|
-
|
18
|
+
Feedjira::Feed.parse(string_of_xml)
|
13
19
|
```
|
14
20
|
|
15
|
-
|
21
|
+
The OPML parser will match on `/\<opml/`, so it won't conflict with `RSS`, `Atom`, or other native Feedjira parsers.
|
22
|
+
|
23
|
+
If its necessary to use the OPML parser explicitly:
|
16
24
|
|
17
|
-
|
25
|
+
```ruby
|
26
|
+
Feedjira::Feed.parse_with(Feedjira::Parser::OPML, string_of_xml)
|
27
|
+
```
|
18
28
|
|
19
|
-
|
29
|
+
### Output
|
20
30
|
|
21
|
-
|
31
|
+
All elements and attributes are typecast based on the OPML specification. The behavior for handling that don't adhere to the spec is undefined.
|
22
32
|
|
23
|
-
|
33
|
+
```ruby
|
34
|
+
@opml.head.title
|
35
|
+
@opml.head.owner_name
|
36
|
+
@opml.head.date_created # Returns a Time
|
37
|
+
@opml.head.expansion_state # Returns an Array
|
38
|
+
```
|
24
39
|
|
25
|
-
|
40
|
+
Working with outlines is similar.
|
26
41
|
|
27
|
-
|
42
|
+
```ruby
|
43
|
+
outline = @opml.body.outlines.first
|
28
44
|
|
29
|
-
|
45
|
+
url = outline.xml_url # Returns a URI
|
46
|
+
```
|
30
47
|
|
31
|
-
|
48
|
+
The `isComment` and `isBreakpoint` attributes are converted to booleans and accessed through convenience methods.
|
32
49
|
|
33
|
-
|
50
|
+
```ruby
|
51
|
+
is_comment = outline.comment?
|
52
|
+
```
|
34
53
|
|
35
|
-
|
36
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
-
5. Create a new Pull Request
|
54
|
+
There are certain situations where the spec requires certain values meet some criteria based on other values, (e.g. _"An outline element whose type is link must have a url attribute whose value is an http address."_). These requirements are not currently enforced by the parser.
|
data/feedjira-opml.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.8'
|
27
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
28
28
|
spec.add_development_dependency 'minitest', '~> 5.5'
|
29
|
+
spec.add_development_dependency 'coveralls'
|
29
30
|
|
30
31
|
spec.add_runtime_dependency 'feedjira', '~> 1.6'
|
31
32
|
end
|
@@ -5,18 +5,43 @@ module Feedjira
|
|
5
5
|
include FeedUtilities
|
6
6
|
|
7
7
|
element :title
|
8
|
-
|
9
|
-
element :
|
8
|
+
|
9
|
+
element :dateCreated, as: :date_created do |s|
|
10
|
+
Time.parse(s)
|
11
|
+
end
|
12
|
+
|
13
|
+
element :dateModified, as: :date_modified do |s|
|
14
|
+
Time.parse(s)
|
15
|
+
end
|
16
|
+
|
10
17
|
element :ownerName, as: :owner_name
|
11
18
|
element :ownerEmail, as: :owner_email
|
12
19
|
element :ownerId, as: :owner_id
|
13
20
|
element :docs
|
14
|
-
|
15
|
-
element :
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
element :
|
21
|
+
|
22
|
+
element :expansionState, as: :expansion_state do |s|
|
23
|
+
s.split(',').map{ |x| x.to_f }
|
24
|
+
end
|
25
|
+
|
26
|
+
element :vertScrollState, as: :vert_scroll_state do |s|
|
27
|
+
s.to_f
|
28
|
+
end
|
29
|
+
|
30
|
+
element :windowTop, as: :window_top do |s|
|
31
|
+
s.to_f
|
32
|
+
end
|
33
|
+
|
34
|
+
element :windowLeft, as: :window_left do |s|
|
35
|
+
s.to_f
|
36
|
+
end
|
37
|
+
|
38
|
+
element :windowBottom, as: :window_bottom do |s|
|
39
|
+
s.to_f
|
40
|
+
end
|
41
|
+
|
42
|
+
element :windowRight, as: :window_right do |s|
|
43
|
+
s.to_f
|
44
|
+
end
|
20
45
|
end
|
21
46
|
end
|
22
47
|
end
|
@@ -6,17 +6,40 @@ module Feedjira
|
|
6
6
|
|
7
7
|
attribute :type
|
8
8
|
attribute :text
|
9
|
-
|
9
|
+
|
10
|
+
attribute :xmlUrl, as: :xml_url do |s|
|
11
|
+
URI(s)
|
12
|
+
end
|
13
|
+
|
10
14
|
attribute :isComment, as: :is_comment
|
11
15
|
attribute :isBreakpoint, as: :is_breakpoint
|
12
|
-
|
16
|
+
|
17
|
+
attribute :created do |s|
|
18
|
+
Time.parse(s)
|
19
|
+
end
|
20
|
+
|
13
21
|
attribute :category
|
14
22
|
attribute :description
|
15
|
-
|
23
|
+
|
24
|
+
attribute :htmlUrl, as: :html_url do |s|
|
25
|
+
URI(s)
|
26
|
+
end
|
27
|
+
|
16
28
|
attribute :language
|
17
29
|
attribute :title
|
18
30
|
attribute :version
|
19
|
-
|
31
|
+
|
32
|
+
attribute :url do |s|
|
33
|
+
URI(s)
|
34
|
+
end
|
35
|
+
|
36
|
+
def comment?
|
37
|
+
!!is_comment && is_comment == 'true'
|
38
|
+
end
|
39
|
+
|
40
|
+
def breakpoint?
|
41
|
+
!!is_breakpoint && is_breakpoint == 'true'
|
42
|
+
end
|
20
43
|
end
|
21
44
|
end
|
22
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: feedjira-opml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Kalafarski
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: coveralls
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: feedjira
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|