redd 0.4.0 → 0.4.1

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: 4800088050748f4a32d520ba72815bab9e2d8f1b
4
- data.tar.gz: 55e9d64b88930bbf42480efa232f7fd65d585f79
3
+ metadata.gz: dbf5efd8e87b68f78da263ecb19dd9ee403eb06c
4
+ data.tar.gz: ee5a23284444562f4eb2160e700793e3af3b6f33
5
5
  SHA512:
6
- metadata.gz: e3b67ad7805af912e63c42754312a3cf7f1d9a7cfcc6199d74077b182ce2b9d750052773535b99e3752b422f741d445cc696d212fbdd7b39f66730102877d421
7
- data.tar.gz: 0b100bc3f6986435e10160c14c72e3cf8b0df8c8c8222a2c24902ee3a97ec90d4c050532a4cb19c3b8c69b03dfbfbe2c7ebf0a3ebf5e323a7dd47ec23ac80ab7
6
+ metadata.gz: bf79a0705655e2b559984a1cdcc0ef59bdbf78aa46515b14dc2a3aee06090e7d4193993e68264ed6e8994f9fded9dc7ce72814da4a86beca17509e356733a1f8
7
+ data.tar.gz: 9eb1cf158dc96a0258315072b25c7c456ee3f36e241db6b31f0de8f67b03a6aa534915fd3619f662fd604e1959d01ef741a8736ee1a2f56d9aaf7b66758a9fc1
@@ -16,7 +16,6 @@ module Redd
16
16
  include Redd::Thing::Reportable
17
17
  include Redd::Thing::Voteable
18
18
 
19
- attr_reader :created_utc
20
19
  attr_reader :author
21
20
 
22
21
  attr_reader :edited
@@ -53,7 +52,7 @@ module Redd
53
52
  end
54
53
 
55
54
  def created
56
- @created ||= Time.at(@attributes[:created])
55
+ @created ||= Time.at(@attributes[:created_utc])
57
56
  end
58
57
 
59
58
  def root?
@@ -7,7 +7,6 @@ module Redd
7
7
 
8
8
  include Redd::Thing::Inboxable
9
9
 
10
- attr_reader :created_utc
11
10
  attr_reader :body
12
11
  attr_reader :body_html
13
12
  attr_reader :subreddit
@@ -24,7 +23,7 @@ module Redd
24
23
  alias_method :to, :author
25
24
 
26
25
  def created
27
- @created ||= Time.at(@attributes[:created])
26
+ @created ||= Time.at(@attributes[:created_utc])
28
27
  end
29
28
 
30
29
  def replies
@@ -17,7 +17,6 @@ module Redd
17
17
  include Redd::Thing::Saveable
18
18
  include Redd::Thing::Voteable
19
19
 
20
- attr_reader :created_utc
21
20
  attr_reader :author
22
21
 
23
22
  attr_reader :edited
@@ -70,7 +69,7 @@ module Redd
70
69
  end
71
70
 
72
71
  def created
73
- @created ||= Time.at(@attributes[:created])
72
+ @created ||= Time.at(@attributes[:created_utc])
74
73
  end
75
74
 
76
75
  def permalink
@@ -33,7 +33,6 @@ module Redd
33
33
  attr_reader :accounts_active
34
34
  attr_reader :public_traffic
35
35
  attr_reader :subscribers
36
- attr_reader :created_utc
37
36
  attr_reader :comment_score_hide_mins
38
37
  attr_reader :subreddit_type
39
38
  attr_reader :submission_type
@@ -44,7 +43,7 @@ module Redd
44
43
  alias_method :type, :subreddit_type
45
44
 
46
45
  def created
47
- @created ||= Time.at(@attributes[:created])
46
+ @created ||= Time.at(@attributes[:created_utc])
48
47
  end
49
48
 
50
49
  def url
@@ -7,7 +7,6 @@ module Redd
7
7
 
8
8
  include Redd::Thing::Messageable
9
9
 
10
- attr_reader :created_utc
11
10
  attr_reader :name
12
11
  attr_reader :is_friend
13
12
  attr_reader :link_karma
@@ -23,7 +22,7 @@ module Redd
23
22
  alias_method :has_gold, :is_gold
24
23
 
25
24
  def created
26
- @created ||= Time.at(@attributes[:created])
25
+ @created ||= Time.at(@attributes[:created_utc])
27
26
  end
28
27
 
29
28
  def fullname
@@ -1,5 +1,5 @@
1
1
  # The main Redd module.
2
2
  module Redd
3
3
  # The semantic version number for Redd.
4
- VERSION = "0.4.0"
4
+ VERSION = "0.4.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avinash Dwarapu
@@ -204,7 +204,6 @@ files:
204
204
  - lib/redd/object/private_message.rb
205
205
  - lib/redd/object/submission.rb
206
206
  - lib/redd/object/subreddit.rb
207
- - lib/redd/object/unauthenticated.rb
208
207
  - lib/redd/object/user.rb
209
208
  - lib/redd/object/wiki_page.rb
210
209
  - lib/redd/rate_limit.rb
@@ -1,116 +0,0 @@
1
- require "faraday"
2
- require "redd/version"
3
- require "redd/rate_limit"
4
- require "redd/response/parse_json"
5
- require "redd/response/raise_error"
6
-
7
- module Redd
8
- module Client
9
- # The Client used to connect without needing login credentials.
10
- class Unauthenticated
11
- require "redd/client/unauthenticated/account"
12
- require "redd/client/unauthenticated/captcha"
13
- require "redd/client/unauthenticated/links_comments"
14
- require "redd/client/unauthenticated/listing"
15
- require "redd/client/unauthenticated/live"
16
- require "redd/client/unauthenticated/moderation"
17
- require "redd/client/unauthenticated/subreddits"
18
- require "redd/client/unauthenticated/utilities"
19
- require "redd/client/unauthenticated/wiki"
20
-
21
- include Redd::Client::Unauthenticated::Account
22
- include Redd::Client::Unauthenticated::Captcha
23
- include Redd::Client::Unauthenticated::LinksComments
24
- include Redd::Client::Unauthenticated::Listing
25
- include Redd::Client::Unauthenticated::Live
26
- include Redd::Client::Unauthenticated::Moderation
27
- include Redd::Client::Unauthenticated::Subreddits
28
- include Redd::Client::Unauthenticated::Utilities
29
- include Redd::Client::Unauthenticated::Wiki
30
-
31
- # @!attribute [r] api_endpoint
32
- # @return [String] The site to connect to.
33
- attr_accessor :api_endpoint
34
-
35
- # @!attribute [r] user_agent
36
- # @return [String] The user-agent used to communicate with reddit.
37
- attr_accessor :user_agent
38
-
39
- # @!attribute [r] rate_limit
40
- # @return [#after_limit] The handler that takes care of rate limiting.
41
- attr_accessor :rate_limit
42
-
43
- # Set up an unauthenticated connection to reddit.
44
- #
45
- # @param [Hash] options A hash of options to connect using.
46
- # @option options [#after_limit] :rate_limit The handler that takes care
47
- # of rate limiting.
48
- # @option options [String] :user_agent The User-Agent string to use in the
49
- # header of every request.
50
- # @option options [String] :api_endpoint The main domain to connect
51
- # to, in this case, the URL for reddit.
52
- def initialize(options = {})
53
- @rate_limit = options[:rate_limit] || Redd::RateLimit.new
54
- @user_agent = options[:user_agent] || "Redd/Ruby, v#{Redd::VERSION}"
55
- @api_endpoint = options[:api_endpoint] || "http://www.reddit.com/"
56
- end
57
-
58
- private
59
-
60
- # @return [Hash] The headers that are sent with every request.
61
- def headers
62
- @headers ||= {"User-Agent" => @user_agent}
63
- end
64
-
65
- # Gets the Faraday connection or creates one if it doesn't exist yet.
66
- #
67
- # @return [Faraday] A new Faraday connection.
68
- def connection
69
- @connection ||= Faraday.new(url: api_endpoint) do |faraday|
70
- faraday.use Faraday::Request::UrlEncoded
71
- faraday.use Redd::Response::RaiseError
72
- faraday.use Redd::Response::ParseJson
73
- faraday.adapter Faraday.default_adapter
74
-
75
- faraday.headers = headers
76
- end
77
- end
78
-
79
- # Send a request to the given path.
80
- #
81
- # @param [#to_sym] method The HTTP verb to use.
82
- # @param [String] path The path under the api endpoint to request from.
83
- # @param [Hash] params The additional parameters to send (defualt: {}).
84
- # @return [String] The response body.
85
- def request(method, path, params = {})
86
- rate_limit.after_limit do
87
- connection.send(method.to_sym, path, params).body
88
- end
89
- end
90
-
91
- # Performs a GET request via {#request}.
92
- # @see #request
93
- def get(*args)
94
- request(:get, *args)
95
- end
96
-
97
- # Performs a POST request via {#request}.
98
- # @see #request
99
- def post(*args)
100
- request(:post, *args)
101
- end
102
-
103
- # Performs a PUT request via {#request}.
104
- # @see #request
105
- def put(*args)
106
- request(:put, *args)
107
- end
108
-
109
- # Performs a DELETE request via {#request}.
110
- # @see #request
111
- def delete(*args)
112
- request(:delete, *args)
113
- end
114
- end
115
- end
116
- end