Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f87f232

Browse files
rubocop autocorrections
1 parent 10d7fb4 commit f87f232

25 files changed

+326
-332
lines changed

‎Gemfile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
source 'https://rubygems.org'
1+
source "https://rubygems.org"
22

33
# Specify your gem's dependencies in ruby-stackoverflow.gemspec
44
gemspec

‎Rakefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
require "bundler/gem_tasks"
2-
require 'rspec/core/rake_task'
2+
require "rspec/core/rake_task"
33

44
RSpec::Core::RakeTask.new(:spec)
55

6-
task :default=> :spec
6+
task default: :spec

‎lib/generators/ruby_stackoverflow/ruby_stackoverflow_generator.rb‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
require 'rails/generators'
1+
require "rails/generators"
22

33
class RubyStackoverflowGenerator < Rails::Generators::Base
44
desc "Creates the ruby-stackoverflow initializer file at config/initialize/ruby-stackoverflow.rb"
5-
class_option :client_key, :aliases=>"-k", :type=>:string, :desc=> "Your Stackoverflow Client key"
6-
class_option :access_token, :aliases=>"-k", :type=>:string, :desc=> "Your STackoverflow access token"
5+
class_option :client_key, aliases: "-k", type: :string, desc: "Your Stackoverflow Client key"
6+
class_option :access_token, aliases: "-k", type: :string, desc: "Your STackoverflow access token"
77

88
def self.source_root
99
@_ruby_stackoverflow_root ||= File.expand_path("../templates", __FILE__)
1010
end
1111

1212
def install
13-
template 'ruby_stackoverflow.rb','config/initializers/ruby_stackoverflow.rb'
13+
template "ruby_stackoverflow.rb","config/initializers/ruby_stackoverflow.rb"
1414
end
1515

1616
private

‎lib/ruby-stackoverflow.rb‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def client
1212
end
1313

1414
# @private
15-
def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9"
15+
def respond_to_missing?(method_name, include_private=false); client.respond_to?(method_name, include_private); end if RUBY_VERSION >= "1.9"
1616
# @private
17-
def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9"
17+
def respond_to?(method_name, include_private=false); client.respond_to?(method_name, include_private) || super; end if RUBY_VERSION < "1.9"
1818

1919
private
2020

‎lib/ruby-stackoverflow/client.rb‎

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
1-
require 'json'
2-
require 'ruby-stackoverflow/client/response_data'
3-
require 'ruby-stackoverflow/client/resource/resource'
4-
require 'ruby-stackoverflow/client/resource/user'
5-
require 'ruby-stackoverflow/client/resource/question'
6-
require 'ruby-stackoverflow/client/resource/answer'
7-
require 'ruby-stackoverflow/client/resource/notification'
8-
require 'ruby-stackoverflow/client/resource/badge'
9-
require 'ruby-stackoverflow/client/resource/reputation'
10-
require 'ruby-stackoverflow/client/resource/suggested_edit'
11-
require 'ruby-stackoverflow/client/resource/comment'
12-
require 'ruby-stackoverflow/client/resource/tag'
13-
require 'ruby-stackoverflow/client/resource/post'
14-
require 'ruby-stackoverflow/client/resource/permission'
15-
require 'ruby-stackoverflow/client/resource/stackoverflow_error'
16-
require 'ruby-stackoverflow/client/user_helper'
17-
require 'ruby-stackoverflow/client/question_helper'
18-
require 'ruby-stackoverflow/client/badges_helper'
19-
require 'ruby-stackoverflow/client/comments_helper'
20-
require 'ruby-stackoverflow/client/parse_options'
1+
require "json"
2+
require "ruby-stackoverflow/client/response_data"
3+
require "ruby-stackoverflow/client/resource/resource"
4+
require "ruby-stackoverflow/client/resource/user"
5+
require "ruby-stackoverflow/client/resource/question"
6+
require "ruby-stackoverflow/client/resource/answer"
7+
require "ruby-stackoverflow/client/resource/notification"
8+
require "ruby-stackoverflow/client/resource/badge"
9+
require "ruby-stackoverflow/client/resource/reputation"
10+
require "ruby-stackoverflow/client/resource/suggested_edit"
11+
require "ruby-stackoverflow/client/resource/comment"
12+
require "ruby-stackoverflow/client/resource/tag"
13+
require "ruby-stackoverflow/client/resource/post"
14+
require "ruby-stackoverflow/client/resource/permission"
15+
require "ruby-stackoverflow/client/resource/stackoverflow_error"
16+
require "ruby-stackoverflow/client/user_helper"
17+
require "ruby-stackoverflow/client/question_helper"
18+
require "ruby-stackoverflow/client/badges_helper"
19+
require "ruby-stackoverflow/client/comments_helper"
20+
require "ruby-stackoverflow/client/parse_options"
2121

2222
module RubyStackoverflow
2323
class Client
@@ -29,8 +29,8 @@ class Client
2929

3030
attr_accessor :configuration
3131

32-
def getr(url,klass, options={})
33-
request :get, url,klass,options
32+
def getr(url,klass, options={})
33+
request :get, url,klass,options
3434
end
3535

3636
def configure
@@ -39,9 +39,9 @@ def configure
3939

4040
private
4141

42-
def request(method, url, klass, options={})
42+
def request(method, url, klass, options={})
4343
url = append_params_to_url(url, parse_options(options))
44-
response = HTTParty.send(method,url)
44+
response = HTTParty.send(method,url)
4545
parse_response(response, klass)
4646
end
4747

@@ -53,17 +53,17 @@ def parse_response(data, klass)
5353
def append_params_to_url(url, options)
5454
url = Configuration.api_url + url
5555
options.merge!(key_params)
56-
options[:site] ||= configuration.site || 'stackoverflow'
57-
options = options.to_a.map{|k,v|"#{k}=#{v}"}
58-
url+'?'+options.join('&')
56+
options[:site] ||= configuration.site || "stackoverflow"
57+
options = options.to_a.map{|k,v| "#{k}=#{v}"}
58+
url + "?" + options.join("&")
5959
end
6060

6161
def key_params
62-
{key: configuration.client_key, access_token: configuration.access_token}
62+
{key: configuration.client_key, access_token: configuration.access_token}
6363
end
6464

6565
def configuration
66-
@configuration||= Configuration.new
66+
@configuration||= Configuration.new
6767
end
6868
end
6969
end

‎lib/ruby-stackoverflow/client/badges_helper.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def badges_by_tags(options = {})
3838

3939
private
4040

41-
def badges_response(options = {}, url= "")
41+
def badges_response(options = {}, url= "")
4242
url = "badges/" + url
4343
getr(url, "badge", options)
4444
end

‎lib/ruby-stackoverflow/client/comments_helper.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ def comments_by_ids(ids, options = {})
1212

1313
private
1414

15-
def comments_response(options={}, url='')
16-
url = 'comments/' + url
17-
getr(url, 'comment', options)
15+
def comments_response(options={}, url="")
16+
url = "comments/" + url
17+
getr(url, "comment", options)
1818
end
1919
end
2020
end

‎lib/ruby-stackoverflow/client/parse_options.rb‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ module RubyStackoverflow
22
class Client
33
module ParseOptions
44
def parse_options(options = {})
5-
options.each do|k,v|
5+
options.each do|k,v|
66
case k
7-
when :fromdate, :todate, :min, :max
7+
when :fromdate, :todate, :min, :max
88
begin
99
options[k] = Time.parse(v).to_i
1010
rescue
@@ -17,7 +17,7 @@ def parse_options(options = {})
1717
end
1818

1919
def join_ids(ids)
20-
ids.join(';')
20+
ids.join(";")
2121
end
2222
end
2323
end

‎lib/ruby-stackoverflow/client/question_helper.rb‎

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,54 +5,54 @@ def questions(options = {})
55
question_response(options)
66
end
77

8-
def questions_by_ids(ids, options = {})
8+
def questions_by_ids(ids, options = {})
99
url = join_ids(ids)
1010
question_response(options, url)
1111
end
1212

13-
def answers_of_questions(ids, options={})
14-
url = join_ids(ids) + '/answers'
13+
def answers_of_questions(ids, options={})
14+
url = join_ids(ids) + "/answers"
1515
question_response(options, url)
1616
end
1717

18-
def comments_of_questions(ids, options={})
19-
url = join_ids(ids) + '/comments'
18+
def comments_of_questions(ids, options={})
19+
url = join_ids(ids) + "/comments"
2020
question_response(options, url)
2121
end
2222

23-
def linked_questions(ids, options={})
24-
url = join_ids(ids)+'/linked'
23+
def linked_questions(ids, options={})
24+
url = join_ids(ids) + "/linked"
2525
question_response(options, url)
2626
end
2727

28-
def related_questions(ids, options={})
29-
url= join_ids(ids) + '/related'
28+
def related_questions(ids, options={})
29+
url= join_ids(ids) + "/related"
3030
question_response(options, url)
3131
end
3232

33-
def timeline_of_questions(ids, options={})
34-
url = join_ids(ids) + '/timeline'
33+
def timeline_of_questions(ids, options={})
34+
url = join_ids(ids) + "/timeline"
3535
question_response(options, url)
3636
end
3737

38-
def featured_questions(options={})
39-
url = 'featured'
38+
def featured_questions(options={})
39+
url = "featured"
4040
question_response(options, url)
4141
end
4242

43-
def unanswered_questions(options={})
44-
question_response(options, 'unanswered')
43+
def unanswered_questions(options={})
44+
question_response(options, "unanswered")
4545
end
4646

47-
def noanswered_questions(options={})
48-
question_response(options, 'no-answers')
47+
def noanswered_questions(options={})
48+
question_response(options, "no-answers")
4949
end
5050

5151
private
5252

53-
def question_response(options={}, url='')
54-
url = 'questions/' + url
55-
getr(url, 'question', options)
53+
def question_response(options={}, url="")
54+
url = "questions/" + url
55+
getr(url, "question", options)
5656
end
5757
end
5858
end

‎lib/ruby-stackoverflow/client/resource/question.rb‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module RubyStackoverflow
22
class Client
33
class Question < Resource
4-
attr_reader :answers, :comments,:user, :posts
5-
def initialize(attributes_hash={})
4+
attr_reader :answers, :comments,:user, :posts
5+
def initialize(attributes_hash={})
66
@answers = []
77
@comments = []
88
@posts = []
@@ -12,15 +12,15 @@ def initialize(attributes_hash={})
1212
class << self
1313
def parse_data(data)
1414
questions = []
15-
data.each do|attr_hash|
15+
data.each do|attr_hash|
1616
if data_has_answer?(data)
1717
question = create_question(attr_hash, questions, :question_id)
1818
question.answers.push(Answer.new(attr_hash))
1919
elsif data_has_comment?(data)
20-
question = create_question(attr_hash, questions,:post_id)
20+
question = create_question(attr_hash, questions,:post_id)
2121
question.comments.push(Comment.new(attr_hash))
2222
elsif data_has_timeline?(data)
23-
question = create_question(attr_hash, questions,:question_id)
23+
question = create_question(attr_hash, questions,:question_id)
2424
question.posts.push(Post.new(attr_hash))
2525
else
2626
questions << new(attr_hash)
@@ -42,20 +42,19 @@ def data_has_timeline?(data)
4242
end
4343

4444
def find_or_create_question(questions, qid)
45-
question_array = questions.select{|q|q.question_id == qid}
46-
!question_array.empty? ? question_array.first : new({question_id: qid})
45+
question_array = questions.select{|q|q.question_id == qid}
46+
!question_array.empty? ? question_array.first : new(question_id: qid)
4747
end
4848

49-
5049
def create_question(attr_hash, questions, hash_key)
5150
qid = attr_hash.delete(hash_key)
5251
question = find_or_create_question(questions, qid)
53-
questions << question unless question_exists?(questions,qid)
52+
questions << question unless question_exists?(questions,qid)
5453
question
5554
end
5655

5756
def question_exists?(questions, question_id)
58-
question_array = questions.select{|q|q.question_id == question_id }
57+
question_array = questions.select{|q|q.question_id == question_id }
5958
!question_array.empty?
6059
end
6160
end

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /