redd 0.6.4 → 0.6.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d9b725f4c257d4b0ce3119e81c7395253399290
4
- data.tar.gz: d6078a42f2bca04fae6497d8cfa935085e581cc8
3
+ metadata.gz: 4b91c525bcbdf6cce167f9b10b7594ded27166e8
4
+ data.tar.gz: 12e3c3465de9fe14cde03786135b2ee2dc23c17f
5
5
  SHA512:
6
- metadata.gz: 08ed7d7fb94496d5307df3cd54d1eca7bf2211773353c51ecddce04234f6fb898e63016feb4c85e10ead5d75bf86eda72d720a3350bc79fb599a78ff027167c6
7
- data.tar.gz: 29015295ac9d449230f2c4785e450c66dd1bbe7cd86aea3dc29763be51cc61385151d4eb60383817c5fb0ce72b26aa396b3a6d72fde253834a6a2def8a3c6b1b
6
+ metadata.gz: de0d1c5627d77bc6b22df8f9f85dd93ecda6f6bb1ec17894c21fea24dfa4ab7b04da47014d3eeba0e106ecc6a34d71ae3ef6b5333d0f81671cccb79a8147a59e
7
+ data.tar.gz: 7d292d8bb1c6adb22a2b9fc9031cadbd59a9eb8cd2d8b0d8e7d04704052aeee7d38c8cde9e7e42e4c575a081fa92a2285aa65f1a282d1af139f8725c9ffefe14
@@ -52,6 +52,7 @@ module Redd
52
52
  def set_flair(subreddit, user_or_link, text = "", css_class = "")
53
53
  name = extract_attribute(subreddit, :display_name)
54
54
  path = "/r/#{name}/api/flair"
55
+ params = {api_type: "json", text: text, css_class: css_class}
55
56
 
56
57
  case user_or_link
57
58
  when Redd::Object::User
@@ -62,7 +63,7 @@ module Redd
62
63
  fail "You should provide a User or Submission object."
63
64
  end
64
65
 
65
- post path, api_type: "json", text: text, css_class: css_class
66
+ post path, params
66
67
  end
67
68
  end
68
69
  end
@@ -23,18 +23,10 @@ module Redd
23
23
  # @param identifier [String] The identifier for the captcha if one
24
24
  # is required.
25
25
  def compose_message(to, subject, text, captcha = nil, identifier = nil)
26
- params[:to] =
27
- case to
28
- when Redd::Object::User
29
- to.name
30
- when Redd::Object::Subreddit
31
- to.display_name
32
- when String
33
- to
34
- end
35
-
36
26
  params = {api_type: "json", subject: subject, text: text}
37
27
  params << {captcha: captcha, iden: identifier} if captcha
28
+ params[:to] = extract_attribute(to, :name) ||
29
+ extract_attribute(to, :display_name)
38
30
 
39
31
  post "/api/compose", params
40
32
  end
@@ -71,6 +71,14 @@ module Redd
71
71
  Redd::Object::Listing.new(data: {children: things})
72
72
  end
73
73
 
74
+ # Edit Subreddit's stylesheet
75
+ #
76
+ # @param subreddit [Redd::Object::Subreddit, String] The subreddit to
77
+ # submit.
78
+ # @param contents [String] css
79
+ # @param reason [String]
80
+ # @note https://www.reddit.com/r/***/about/stylesheet/ is good place
81
+ # to test if you have an error
74
82
  def edit_stylesheet(subreddit, contents, reason = nil)
75
83
  name = extract_attribute(subreddit, :display_name)
76
84
  path = "/r/#{name}/api/subreddit_stylesheet"
@@ -83,6 +91,70 @@ module Redd
83
91
  post path, params
84
92
  end
85
93
 
94
+ # Edit Subreddit's settings
95
+ #
96
+ # @param attrs [Hash] Settings for subrredit
97
+ # @note these links might useful: https://www.reddit.com/dev/api and
98
+ # https://github.com/alaycock/MeetCal-bot/blob/master/serverInfo.conf
99
+ def site_admin(attrs)
100
+ path = "/api/site_admin"
101
+ params = {
102
+ allow_top: nil, # boolean
103
+ api_type: "json", # always "json"
104
+ collapse_deleted_comments: nil, # boolean
105
+ comment_score_hide_mins: nil, # int 0..1440 def: 0
106
+ css_on_cname: nil, # boolean
107
+ description: nil, # markdown string
108
+ exclude_banned_modqueue: nil, # boolean
109
+ lang: nil, # valid IETF lang tag, eg: en
110
+ link_type: nil, # string [any, link, self]
111
+ name: nil, # string subreddit name
112
+ over_18: nil, # boolean
113
+ public_description: nil, # markdown string
114
+ public_traffic: nil, # boolean
115
+ show_cname_sidebar: nil, # boolean
116
+ show_media: nil, # boolean
117
+ spam_comments: nil, # string [low, high, all]
118
+ spam_links: nil, # string [low, high, all]
119
+ spam_selfposts: nil, # string [low, high, all]
120
+ sr: nil, # string, for subreddit it should start like "t5_"
121
+ submit_link_label: nil, # string max 60 chars
122
+ submit_text: nil, # markdown string
123
+ submit_text_label: nil, # string max 60 chars
124
+ title: nil, # string max 100 chars
125
+ type: nil, # string [public, private, restricted, gold_restricted, archived]
126
+ wiki_edit_age: nil, # int 0+, def: 0
127
+ wiki_edit_karma: nil, # int 0+, def: 0
128
+ wikimode: nil # string [disabled, modonly, anyone]
129
+ }
130
+ params["header-title"] = '' # string max 500 chars
131
+
132
+ params.keys.each{|key|
133
+ if !attrs[key].nil?
134
+ params[key] = attrs[key]
135
+ end
136
+ }
137
+
138
+ empties = params.map{ |obj|
139
+ obj.last.nil? ? obj.first.to_s : nil
140
+ }
141
+ empties = empties.reject!{ |elm| elm.nil? }
142
+ if !empties.empty?
143
+ raise "The following item should not be nil => [" + empties.join(', ') + ']'
144
+ end
145
+
146
+ post path, params
147
+ end
148
+
149
+ # Get the current settings of a subreddit.
150
+ #
151
+ # @param subreddit [Redd::Object::Subreddit, String] The subreddit to
152
+ # submit.
153
+ def about_edit(subreddit)
154
+ name = extract_attribute(subreddit, :display_name)
155
+ object_from_response :get, "/r/#{name}/about/edit.json"
156
+ end
157
+
86
158
  private
87
159
 
88
160
  # Subscribe or unsubscribe to a subreddit.
data/lib/redd/version.rb CHANGED
@@ -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.6.4"
4
+ VERSION = "0.6.5"
5
5
  end
metadata CHANGED
@@ -1,139 +1,139 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redd
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.4
4
+ version: 0.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Avinash Dwarapu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-19 00:00:00.000000000 Z
11
+ date: 2014-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: vcr
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: webmock
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: faraday
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 0.9.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 0.9.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: faraday_middleware
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: 0.9.1
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.9.1
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: multi_json
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: '1.10'
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '1.10'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: memoizable
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: A Reddit API Wrapper for Ruby.
@@ -143,11 +143,11 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
- - .gitignore
147
- - .rspec
148
- - .rubocop.yml
149
- - .travis.yml
150
- - .yardopts
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".rubocop.yml"
149
+ - ".travis.yml"
150
+ - ".yardopts"
151
151
  - Gemfile
152
152
  - LICENSE.md
153
153
  - README.md
@@ -241,17 +241,17 @@ require_paths:
241
241
  - lib
242
242
  required_ruby_version: !ruby/object:Gem::Requirement
243
243
  requirements:
244
- - - '>='
244
+ - - ">="
245
245
  - !ruby/object:Gem::Version
246
246
  version: '0'
247
247
  required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  requirements:
249
- - - '>='
249
+ - - ">="
250
250
  - !ruby/object:Gem::Version
251
251
  version: '0'
252
252
  requirements: []
253
253
  rubyforge_project:
254
- rubygems_version: 2.0.14
254
+ rubygems_version: 2.2.2
255
255
  signing_key:
256
256
  specification_version: 4
257
257
  summary: A Reddit API Wrapper for Ruby.