post_haste 0.9.1 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- post_haste (0.9.1)
4
+ post_haste (0.9.2)
5
5
  json
6
6
  nokogiri
7
7
 
data/README.md CHANGED
@@ -36,7 +36,11 @@ Post Haste currently can accept a URL of a Washington Post article or blog post,
36
36
 
37
37
  @article.comments.first.author
38
38
 
39
- => "Horatio_Swaggbottom"
39
+ => "iseasygoing"
40
+
41
+ @article.comments.first.permalink(@article)
42
+
43
+ => "http://www.washingtonpost.com/blogs/the-fix/post/republicans-on-the-2012-gop-field-blah/2012/03/15/gIQAT7CSFS_comment.html?commentID=washingtonpost.com/ECHO/item/1332046095-915-174"
40
44
 
41
45
 
42
46
  ## In the Wild
@@ -6,7 +6,7 @@ module PostHaste
6
6
  class Comment
7
7
  # Represents a comment on a Washington Post story
8
8
 
9
- attr_reader :id, :article_url, :author, :content, :status, :published
9
+ attr_reader :id, :article_url, :author, :content, :status, :published , :permalink
10
10
 
11
11
  def initialize(params={})
12
12
  params.each_pair do |k,v|
@@ -17,11 +17,21 @@ module PostHaste
17
17
  def self.create_comments_from_objects(article_url, comments)
18
18
  results = []
19
19
  comments.each do |comment|
20
- c = Comment.new({:id => comment['object']['id'], :article_url => article_url, :author => comment['actor']['title'], :content => comment['object']['content'], :status => comment['object']['status'], :published => DateTime.parse(comment['object']['published'])})
20
+ c = Comment.new({:id => comment['object']['id'].gsub('http://',''), :article_url => article_url, :author => comment['actor']['title'], :content => comment['object']['content'], :status => comment['object']['status'], :published => DateTime.parse(comment['object']['published'])})
21
21
  results << c
22
22
  end
23
23
  results
24
24
  end
25
25
 
26
+ def permalink(article)
27
+ if article.type == 'BlogStory'
28
+ article_url.gsub('_blog','_comment')+'?commentID='+id
29
+ elsif article.type == 'article'
30
+ article_url.gsub('_story','_comment')+'?commentID='+id
31
+ else
32
+ article_url+'?commentID='+id
33
+ end
34
+ end
35
+
26
36
  end
27
37
  end
@@ -1,3 +1,3 @@
1
1
  module PostHaste
2
- VERSION = "0.9.1"
2
+ VERSION = "0.9.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: post_haste
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.1
4
+ version: 0.9.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-09 00:00:00.000000000 Z
12
+ date: 2013-11-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -125,7 +125,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
125
125
  version: '0'
126
126
  segments:
127
127
  - 0
128
- hash: -2475865737394952429
128
+ hash: 3728910405888285188
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  none: false
131
131
  requirements: