feedjira-opml 1.0.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 201ffda52b0713dc676b59f0670b8cb06d1047a8
4
- data.tar.gz: 0404f07ac3fe2dfd6c50b0797994983507034b8b
3
+ metadata.gz: 08527b867147e345f87f219b2a948b0b5c7b15ab
4
+ data.tar.gz: d937389bbc4bf1ea30ca557dae8bbda16d4917e2
5
5
  SHA512:
6
- metadata.gz: 21bd60a38ef3f0ba63a05f7cad2b0bb4f20f33e1f0981cd38f98b5138ca9aa301f8eb554b87b7149502ac87798ad3ee369cfb8f5be40e3819340c88bee62ac1b
7
- data.tar.gz: 7338d989446d8211db7ea16fc8a15be453f0a7d7f435dea5b880b0b65d741a0d4fc30caf52ff275ef42b53bd134738fdaff80bedd548550f58d74a9e6d838bf5
6
+ metadata.gz: cf06beb6bd7995d17cb3cc541c6196b4ecf3a2d2e1456e9de236d461528e507d558e56d73ae674ef45f439ee8117c17d6d7173b76dee147328032df92a9ef02c
7
+ data.tar.gz: 07d5288c8e396c3e88bc7d562fff624ec424033158e8e2047f805abcf70b979b621b4318b873495299e4af7810884dd5ad4f2a8f499f41e05a2ff151dcd1d960
data/README.md CHANGED
@@ -1,39 +1,54 @@
1
1
  # Feedjira::Opml
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/feedjira/opml`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
- ## Installation
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
- Add this line to your application's Gemfile:
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
- gem 'feedjira-opml'
18
+ Feedjira::Feed.parse(string_of_xml)
13
19
  ```
14
20
 
15
- And then execute:
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
- $ bundle
25
+ ```ruby
26
+ Feedjira::Feed.parse_with(Feedjira::Parser::OPML, string_of_xml)
27
+ ```
18
28
 
19
- Or install it yourself as:
29
+ ### Output
20
30
 
21
- $ gem install feedjira-opml
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
- ## Usage
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
- TODO: Write usage instructions here
40
+ Working with outlines is similar.
26
41
 
27
- ## Development
42
+ ```ruby
43
+ outline = @opml.body.outlines.first
28
44
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ url = outline.xml_url # Returns a URI
46
+ ```
30
47
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
48
+ The `isComment` and `isBreakpoint` attributes are converted to booleans and accessed through convenience methods.
32
49
 
33
- ## Contributing
50
+ ```ruby
51
+ is_comment = outline.comment?
52
+ ```
34
53
 
35
- 1. Fork it ( https://github.com/[my-github-username]/feedjira-opml/fork )
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.
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Feedjira
2
2
  module OPML
3
- VERSION = '1.0.3'
3
+ VERSION = '2.0.0'
4
4
  end
5
5
  end
@@ -5,18 +5,43 @@ module Feedjira
5
5
  include FeedUtilities
6
6
 
7
7
  element :title
8
- element :dateCreated, as: :date_created
9
- element :dateModified, as: :date_modified
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
- element :expansionState, as: :expansion_state
15
- element :vertScrollState, as: :vert_scroll_state
16
- element :windowTop, as: :window_top
17
- element :windowLeft, as: :window_left
18
- element :windowBottom, as: :window_bottom
19
- element :windowRight, as: :window_right
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
- attribute :xmlUrl, as: :xml_url
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
- attribute :created
16
+
17
+ attribute :created do |s|
18
+ Time.parse(s)
19
+ end
20
+
13
21
  attribute :category
14
22
  attribute :description
15
- attribute :htmlUrl, as: :html_url
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
- attribute :url
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: 1.0.3
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