ruby-hackernews 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. data/README.rdoc +20 -15
  2. data/Rakefile +1 -1
  3. data/lib/{HNAPI → ruby-hackernews}/domain/comment/comment.rb +0 -1
  4. data/lib/{HNAPI → ruby-hackernews}/domain/entry/comments_info.rb +0 -0
  5. data/lib/{HNAPI → ruby-hackernews}/domain/entry/entry.rb +0 -0
  6. data/lib/{HNAPI → ruby-hackernews}/domain/entry/link_info.rb +0 -0
  7. data/lib/{HNAPI → ruby-hackernews}/domain/entry/time_info.rb +2 -2
  8. data/lib/{HNAPI → ruby-hackernews}/domain/entry/user_info.rb +0 -0
  9. data/lib/{HNAPI → ruby-hackernews}/domain/entry/voting_info.rb +0 -0
  10. data/lib/{HNAPI → ruby-hackernews}/domain/user.rb +0 -0
  11. data/lib/{HNAPI → ruby-hackernews}/services/comment_service.rb +0 -0
  12. data/lib/{HNAPI → ruby-hackernews}/services/configuration_service.rb +5 -1
  13. data/lib/{HNAPI → ruby-hackernews}/services/entry_service.rb +0 -0
  14. data/lib/{HNAPI → ruby-hackernews}/services/login_service.rb +0 -0
  15. data/lib/{HNAPI → ruby-hackernews}/services/mechanize_context.rb +0 -0
  16. data/lib/{HNAPI → ruby-hackernews}/services/not_authenticated_error.rb +0 -0
  17. data/lib/{HNAPI → ruby-hackernews}/services/parsers/comments_info_parser.rb +0 -0
  18. data/lib/{HNAPI → ruby-hackernews}/services/parsers/entry_page_parser.rb +0 -0
  19. data/lib/{HNAPI → ruby-hackernews}/services/parsers/entry_parser.rb +0 -0
  20. data/lib/{HNAPI → ruby-hackernews}/services/parsers/link_info_parser.rb +0 -0
  21. data/lib/{HNAPI → ruby-hackernews}/services/parsers/time_info_parser.rb +0 -0
  22. data/lib/{HNAPI → ruby-hackernews}/services/parsers/user_info_parser.rb +0 -0
  23. data/lib/{HNAPI → ruby-hackernews}/services/parsers/voting_info_parser.rb +0 -0
  24. data/lib/{HNAPI → ruby-hackernews}/services/voting_service.rb +0 -0
  25. data/lib/ruby-hackernews.rb +6 -2
  26. metadata +26 -26
data/README.rdoc CHANGED
@@ -22,40 +22,40 @@ before using it.
22
22
 
23
23
  You can get entries on the main page with:
24
24
 
25
- Entry.all # returns an array of entries
25
+ Entry.all # returns the main page's entries as an array
26
26
 
27
27
  You can provide a number of pages:
28
28
 
29
- Entry.all(3) # will return the entries on the first 3 pages
29
+ Entry.all(3) # will return the entries on the first 3 pages
30
30
 
31
31
  There are methods for getting specific entry types:
32
32
 
33
33
  Entry.questions # gets the first page of questions (ask NH)
34
- Entry.newest # get the first page of new links (new)
35
- Entry.jobs # get the forst page of job offest (jobs)
34
+ Entry.newest # gets the first page of new links (new)
35
+ Entry.jobs # gets the first page of job offerts (jobs)
36
36
 
37
37
  Each Entry instance has the following data:
38
38
 
39
- entry = Entry.all.first #get the top entry on the mainpage
39
+ entry = Entry.all.first # gets the top entry on the mainpage
40
40
 
41
- entry.number # entry's position on HN
41
+ entry.number # the entry's position on HN
42
42
 
43
43
  entry.link.title # the link's name on HN
44
44
  entry.link.href # the actual link
45
- entry.link.site # the referring's site, if any
45
+ entry.link.site # the referring site, if any
46
46
 
47
47
  entry.voting.score # the entry's score on HN
48
48
 
49
- entry.user.name # submitter's user name
49
+ entry.user.name # the submitter's user name
50
50
 
51
- entry.time # elapsed time from submission
51
+ entry.time # the elapsed time from submission
52
52
 
53
53
  After you've logged in (see below) you can do the following
54
54
 
55
- entry.upvote #votes the entry
56
- entry.write_comment("mycomment") #adds a comment to the entry
57
- Entry.submit("mytitle", "myurl") #submit a new link
58
- Entry.submit("myquestion") #submit a new question (ask HN)
55
+ entry.upvote # votes the entry
56
+ entry.write_comment("mycomment") # adds a comment to the entry
57
+ Entry.submit("mytitle", "myurl") # submit a new link
58
+ Entry.submit("myquestion") # submit a new question (ask HN)
59
59
 
60
60
  == Comments
61
61
 
@@ -66,7 +66,7 @@ You get an entry's comments with:
66
66
  You can also get the newest comments on HN with:
67
67
 
68
68
  Comments.newest
69
- Comments.newest(3) # get the first 3 pages of new comments
69
+ Comments.newest(3) # gets the first 3 pages of new comments
70
70
 
71
71
  Each Comment instance has the following data:
72
72
 
@@ -79,7 +79,7 @@ Each Comment instance has the following data:
79
79
  Comments are enumerable and threaded, so you can do like:
80
80
 
81
81
  comment[2][0] # gets the third reply to this comment, then the first reply to the reply
82
- comment.first # get the first reply to this comment
82
+ comment.first # gets the first reply to this comment
83
83
  comment.select do |c| # gets all the comment replies which text contains "test"
84
84
  text ~= /test/
85
85
  end
@@ -112,3 +112,8 @@ You have to log out before logging in with a different user.
112
112
  Get user info (submission, comments...)
113
113
  Create account
114
114
  Change user info/settings
115
+
116
+ == THANKS TO
117
+
118
+ - Mike Kelly ( https://github.com/mikekelly ) for fixing a bug in TimeInfo.time
119
+ - Marc Köhlbrugge ( http://github.com/marckohlbrugge ) fox fixing and formatting the documentation
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require 'rake/testtask'
9
9
 
10
10
  spec = Gem::Specification.new do |s|
11
11
  s.name = 'ruby-hackernews'
12
- s.version = '1.0.0'
12
+ s.version = '1.0.1'
13
13
  s.add_dependency('require_all', '>= 1.1.0')
14
14
  s.add_dependency('mechanize', '>= 1.0.0')
15
15
  s.has_rdoc = false
@@ -7,7 +7,6 @@ class Comment
7
7
  attr_reader :user
8
8
 
9
9
  attr_accessor :parent
10
- attr_reader :children
11
10
 
12
11
  def initialize(text, voting, user_info, reply_link)
13
12
  @text = text
@@ -7,7 +7,7 @@ class TimeInfo
7
7
  DAY = 24 * HOUR
8
8
 
9
9
  def time
10
- return Time.at(@unit_of_measure * @value)
10
+ return Time.now - @unit_of_measure * @value
11
11
  end
12
12
 
13
13
  def initialize(value, unit_of_measure)
@@ -17,4 +17,4 @@ class TimeInfo
17
17
  end
18
18
 
19
19
 
20
- end
20
+ end
File without changes
@@ -1,8 +1,12 @@
1
1
 
2
2
  class ConfigurationService
3
3
 
4
+ def self.base_url=(url)
5
+ @base_url = url
6
+ end
7
+
4
8
  def self.base_url
5
- return "http://news.ycombinator.com/"
9
+ return @base_url || "http://news.ycombinator.com/"
6
10
  end
7
11
 
8
12
  def self.new_url
@@ -4,5 +4,9 @@ require 'mechanize'
4
4
 
5
5
  require 'require_all'
6
6
 
7
- require_all File.join(File.dirname(__FILE__), 'HNAPI', 'domain')
8
- require_all File.join(File.dirname(__FILE__), 'HNAPI', 'services')
7
+ require_all File.join(File.dirname(__FILE__), 'ruby-hackernews', 'domain')
8
+ require_all File.join(File.dirname(__FILE__), 'ruby-hackernews', 'services')
9
+
10
+ Entry.all.first.comments.each do |comment|
11
+ p comment.text
12
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-hackernews
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 0
10
- version: 1.0.0
9
+ - 1
10
+ version: 1.0.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrea Dallera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-08 00:00:00 +02:00
18
+ date: 2010-09-10 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -61,28 +61,28 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - README.rdoc
63
63
  - Rakefile
64
- - lib/HNAPI/domain/comment/comment.rb
65
- - lib/HNAPI/domain/user.rb
66
- - lib/HNAPI/domain/entry/link_info.rb
67
- - lib/HNAPI/domain/entry/voting_info.rb
68
- - lib/HNAPI/domain/entry/time_info.rb
69
- - lib/HNAPI/domain/entry/user_info.rb
70
- - lib/HNAPI/domain/entry/entry.rb
71
- - lib/HNAPI/domain/entry/comments_info.rb
72
- - lib/HNAPI/services/parsers/link_info_parser.rb
73
- - lib/HNAPI/services/parsers/entry_parser.rb
74
- - lib/HNAPI/services/parsers/voting_info_parser.rb
75
- - lib/HNAPI/services/parsers/user_info_parser.rb
76
- - lib/HNAPI/services/parsers/time_info_parser.rb
77
- - lib/HNAPI/services/parsers/entry_page_parser.rb
78
- - lib/HNAPI/services/parsers/comments_info_parser.rb
79
- - lib/HNAPI/services/voting_service.rb
80
- - lib/HNAPI/services/mechanize_context.rb
81
- - lib/HNAPI/services/comment_service.rb
82
- - lib/HNAPI/services/login_service.rb
83
- - lib/HNAPI/services/entry_service.rb
84
- - lib/HNAPI/services/not_authenticated_error.rb
85
- - lib/HNAPI/services/configuration_service.rb
64
+ - lib/ruby-hackernews/domain/comment/comment.rb
65
+ - lib/ruby-hackernews/domain/user.rb
66
+ - lib/ruby-hackernews/domain/entry/link_info.rb
67
+ - lib/ruby-hackernews/domain/entry/voting_info.rb
68
+ - lib/ruby-hackernews/domain/entry/time_info.rb
69
+ - lib/ruby-hackernews/domain/entry/user_info.rb
70
+ - lib/ruby-hackernews/domain/entry/entry.rb
71
+ - lib/ruby-hackernews/domain/entry/comments_info.rb
72
+ - lib/ruby-hackernews/services/parsers/link_info_parser.rb
73
+ - lib/ruby-hackernews/services/parsers/entry_parser.rb
74
+ - lib/ruby-hackernews/services/parsers/voting_info_parser.rb
75
+ - lib/ruby-hackernews/services/parsers/user_info_parser.rb
76
+ - lib/ruby-hackernews/services/parsers/time_info_parser.rb
77
+ - lib/ruby-hackernews/services/parsers/entry_page_parser.rb
78
+ - lib/ruby-hackernews/services/parsers/comments_info_parser.rb
79
+ - lib/ruby-hackernews/services/voting_service.rb
80
+ - lib/ruby-hackernews/services/mechanize_context.rb
81
+ - lib/ruby-hackernews/services/comment_service.rb
82
+ - lib/ruby-hackernews/services/login_service.rb
83
+ - lib/ruby-hackernews/services/entry_service.rb
84
+ - lib/ruby-hackernews/services/not_authenticated_error.rb
85
+ - lib/ruby-hackernews/services/configuration_service.rb
86
86
  - lib/ruby-hackernews.rb
87
87
  has_rdoc: true
88
88
  homepage: http://github.com/bolthar/ruby-hackernews