hurricane 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,7 +4,7 @@ Hurricane is a tiny tool to parser WordPress eXtended RSS file.
4
4
 
5
5
  == Example
6
6
 
7
- blog = Hurricane.from(WORDPRESS_FILE)
7
+ blog = Hurricane::Parse.from(WORDPRESS_FILE)
8
8
  puts "Looking for #{blog.title}"
9
9
 
10
10
  == Features
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hurricane}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Daniel Tamiosso"]
@@ -2,42 +2,46 @@ require 'rubygems'
2
2
  require 'time'
3
3
  require 'hpricot'
4
4
 
5
- class Hurricane
6
- def self.from(file)
7
- blog = Blog.new
8
- doc = Hpricot::XML(file)
9
- (doc/:channel).each do |info|
10
- blog.title = (info/:title)[0].inner_html
11
- blog.description = (info/:description).inner_html
12
- blog.link = (info/:link)[0].inner_html
13
- blog.created_at = Time.rfc2822((info/'pubDate')[0].inner_html)
5
+ module Hurricane
14
6
 
15
- (info/'wp:category'/'wp:category_nicename').each do |category|
16
- blog.categories << category.inner_html
7
+ class Parse
8
+ def self.from(file)
9
+ blog = Blog.new
10
+ doc = Hpricot::XML(file)
11
+ (doc/:channel).each do |info|
12
+ blog.title = (info/:title)[0].inner_html
13
+ blog.description = (info/:description).inner_html
14
+ blog.link = (info/:link)[0].inner_html
15
+ blog.created_at = Time.rfc2822((info/'pubDate')[0].inner_html)
16
+
17
+ (info/'wp:category'/'wp:category_nicename').each do |category|
18
+ blog.categories << category.inner_html
19
+ end
20
+
21
+ (info/:item).each do |item|
22
+ post = Post.new
23
+ post.title = (item/:title).inner_html
24
+ post.link = (item/:link).inner_html
25
+ post.created_at = (item/'pubDate').inner_html
26
+ post.description = (item/'content:encoded').inner_html.gsub('<![CDATA[', '').gsub(']]>', '')
27
+ blog.posts << post
28
+ end
29
+
17
30
  end
18
-
19
- (info/:item).each do |item|
20
- post = Post.new
21
- post.title = (item/:title).inner_html
22
- post.link = (item/:link).inner_html
23
- post.created_at = (item/'pubDate').inner_html
24
- post.description = (item/'content:encoded').inner_html.gsub('<![CDATA[', '').gsub(']]>', '')
25
- blog.posts << post
26
- end
27
-
31
+ blog
28
32
  end
29
- blog
30
- end
31
- end
32
-
33
- class Blog
34
- def initialize
35
- @categories = Array.new
36
- @posts = Array.new
37
33
  end
38
- attr_accessor :title, :link, :description, :created_at, :categories, :posts
39
- end
40
-
41
- class Post
42
- attr_accessor :title, :link, :created_at, :description
34
+
35
+ class Blog
36
+ def initialize
37
+ @categories = Array.new
38
+ @posts = Array.new
39
+ end
40
+ attr_accessor :title, :link, :description, :created_at, :categories, :posts
41
+ end
42
+
43
+ class Post
44
+ attr_accessor :title, :link, :created_at, :description
45
+ end
46
+
43
47
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe 'Hurricane' do
4
4
 
5
5
  FILE = File.open('./wordpress_file.xml', 'r')
6
- @blog = Hurricane.from(FILE)
6
+ @blog = Hurricane::Parse.from(FILE)
7
7
 
8
8
  it 'should be offer blog title' do
9
9
  @blog.title.should.equal 'Daniel Tamiosso'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hurricane
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Tamiosso