Skip to content

Commit 9082d11

Browse files
committed
Use 19 style hash format
1 parent ce89fa3 commit 9082d11

File tree

6 files changed

+78
-66
lines changed

6 files changed

+78
-66
lines changed

commands/search.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@
1111
arg = q['url']
1212
subtitle = "Stocks: " + q['stock_count'].to_s + " LGTM:" + q['lgtm_count'].to_s + " Comments:" + q['comment_count'].to_s + " Create At:" + q['created_at']
1313

14-
item = { uid: q['id'], arg: arg, title: q['title'], subtitle: subtitle, icon: 'icon.png'}
14+
item = {
15+
:uid => q['id'],
16+
:arg => arg,
17+
:title => q['title'],
18+
:subtitle => subtitle,
19+
:icon => 'icon.png'
20+
}
1521
results << item
1622
end
1723

commands/setup.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
exit
1212
end
1313

14-
auth = Qiita::API.auth name: credentials.first, password: credentials.last
14+
auth = Qiita::API.auth credentials.first, credentials.last
1515

1616
unless auth
1717
puts "ERROR: Authentication failed"
1818
exit
1919
end
2020

21-
config = Qiita::Config.new name: auth['url_name'], token: auth['token']
21+
config = Qiita::Config.new :name => auth['url_name'], :token => auth['token']
2222
config.save
2323

2424
puts "Setup complete"

commands/stocks.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
exit
1616
end
1717

18-
data = Qiita::API.search(QUERY, token: config.token, stocked: 1)
18+
data = Qiita::API.search(QUERY, :token => config.token, :stocked => 1)
1919

2020
results = []
2121
data.each do |q|
2222
subtitle = "Stocks: " + q['stock_count'].to_s + " LGTM:" + q['lgtm_count'].to_s + " Comments:" + q['comment_count'].to_s + " Create At:" + q['created_at']
2323

2424
item = {
25-
uid: q['id'],
26-
arg: q['url'],
27-
title: q['title'],
28-
subtitle: subtitle,
29-
icon: 'icon.png'
25+
:uid => q['id'],
26+
:arg => q['url'],
27+
:title => q['title'],
28+
:subtitle => subtitle,
29+
:icon => 'icon.png'
3030
}
3131

3232
results << item

lib/qiita/alfred.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,13 @@ def self.to_alfred(array)
2727
end
2828

2929
def self.message(str)
30-
puts Qiita::Alfred.to_alfred([{ uid: 0, arg: nil, title: str, subtitle: nil, icon: 'icon.png'}])
30+
puts Qiita::Alfred.to_alfred([{
31+
:uid => 0,
32+
:arg => nil,
33+
:title => str,
34+
:subtitle => nil,
35+
:icon => 'icon.png'
36+
}])
3137
end
3238
end
3339
end

lib/qiita/api.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ class API
99

1010
ENDPOINT = "https://qiita.com/api/v1/"
1111

12-
def self.auth(name: name, password: password)
12+
def self.auth(name, password)
1313
uri = URI.join(ENDPOINT, 'auth')
14-
params = {url_name: name, password: password}
14+
params = {:url_name => name, :password => password}
1515
fetch uri, params, method: :post
1616
end
1717

1818
def self.search(query, args={})
1919
uri = URI.join(ENDPOINT, 'search')
20-
fetch uri, {q: query}.update(args)
20+
fetch uri, {:q => query}.update(args)
2121
end
2222

2323
def self.fetch(uri, params={}, *args)

spec/alfred_qiita_spec.rb

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,36 @@
3636
.with(:query => { :q => @search_word })
3737
.to_return(:body => [
3838
{
39-
id: 1458,
40-
uuid: "bbcca9f634028dc2f11c",
41-
user: {
42-
id: 1,
43-
url_name: "o_ame",
44-
profile_image_url: "https://example.com/avatar.png"
39+
:id => 1458,
40+
:uuid => "bbcca9f634028dc2f11c",
41+
:user => {
42+
:id => 1,
43+
:url_name => "o_ame",
44+
:profile_image_url => "https://example.com/avatar.png"
4545
},
46-
title: "test",
47-
created_at: "2011-12-26 19:41:26 +0900",
48-
updated_at: "2012-03-16 11:30:27 +0900",
49-
created_at_in_words: "2年以上",
50-
updated_at_in_words: "2年以上",
51-
tags: [
46+
:title => "test",
47+
:created_at => "2011-12-26 19:41:26 +0900",
48+
:updated_at => "2012-03-16 11:30:27 +0900",
49+
:created_at_in_words => "2年以上",
50+
:updated_at_in_words => "2年以上",
51+
:tags => [
5252
{
53-
name: "CoffeeScript",
54-
url_name: "coffeescript",
55-
icon_url: "https://s3-ap-northeast-1.amazonaws.com/qiita-tag-image/e41b881d25c683db2ce913dba0d07b9695a55741/medium.jpg?1368788624",
56-
versions: [ ]
53+
:name => "CoffeeScript",
54+
:url_name => "coffeescript",
55+
:icon_url => "https://s3-ap-northeast-1.amazonaws.com/qiita-tag-image/e41b881d25c683db2ce913dba0d07b9695a55741/medium.jpg?1368788624",
56+
:versions => [ ]
5757
}
5858
],
59-
stock_count: 2,
60-
comment_count: 0,
61-
url: "http://qiita.com/mizchi/items/bbcca9f634028dc2f11c",
62-
created_at_as_seconds: 1324896086,
63-
tweet: false,
64-
gist_url: nil,
65-
private: false,
66-
raw_body: "feafa",
67-
body: "feafewafa",
68-
stock_users: [
59+
:stock_count => 2,
60+
:comment_count => 0,
61+
:url => "http://qiita.com/mizchi/items/bbcca9f634028dc2f11c",
62+
:created_at_as_seconds => 1324896086,
63+
:tweet => false,
64+
:gist_url => nil,
65+
:private => false,
66+
:raw_body => "feafa",
67+
:body => "feafewafa",
68+
:stock_users => [
6969
"CLG",
7070
"mizchi"
7171
]
@@ -97,43 +97,43 @@
9797
.with(:query => { :q => @search_word, :token => @expected_token, :stocked => 1 })
9898
.to_return(:body => [
9999
{
100-
id: 1458,
101-
uuid: "bbcca9f634028dc2f11c",
102-
user: {
103-
id: 1,
104-
url_name: "o_ame",
105-
profile_image_url: "https://example.com/avatar.png"
100+
:id => 1458,
101+
:uuid => "bbcca9f634028dc2f11c",
102+
:user => {
103+
:id => 1,
104+
:url_name => "o_ame",
105+
:profile_image_url => "https://example.com/avatar.png"
106106
},
107-
title: "test",
108-
created_at: "2011-12-26 19:41:26 +0900",
109-
updated_at: "2012-03-16 11:30:27 +0900",
110-
created_at_in_words: "2年以上",
111-
updated_at_in_words: "2年以上",
112-
tags: [
107+
:title => "test",
108+
:created_at => "2011-12-26 19:41:26 +0900",
109+
:updated_at => "2012-03-16 11:30:27 +0900",
110+
:created_at_in_words => "2年以上",
111+
:updated_at_in_words => "2年以上",
112+
:tags => [
113113
{
114-
name: "CoffeeScript",
115-
url_name: "coffeescript",
116-
icon_url: "https://s3-ap-northeast-1.amazonaws.com/qiita-tag-image/e41b881d25c683db2ce913dba0d07b9695a55741/medium.jpg?1368788624",
117-
versions: [ ]
114+
:name => "CoffeeScript",
115+
:url_name => "coffeescript",
116+
:icon_url => "https://s3-ap-northeast-1.amazonaws.com/qiita-tag-image/e41b881d25c683db2ce913dba0d07b9695a55741/medium.jpg?1368788624",
117+
:versions => [ ]
118118
}
119119
],
120-
stock_count: 2,
121-
comment_count: 0,
122-
url: "http://qiita.com/mizchi/items/bbcca9f634028dc2f11c",
123-
created_at_as_seconds: 1324896086,
124-
tweet: false,
125-
gist_url: nil,
126-
private: false,
127-
raw_body: "feafa",
128-
body: "feafewafa",
129-
stock_users: [
120+
:stock_count => 2,
121+
:comment_count => 0,
122+
:url => "http://qiita.com/mizchi/items/bbcca9f634028dc2f11c",
123+
:created_at_as_seconds => 1324896086,
124+
:tweet => false,
125+
:gist_url => nil,
126+
:private => false,
127+
:raw_body => "feafa",
128+
:body => "feafewafa",
129+
:stock_users => [
130130
"CLG",
131131
"mizchi"
132132
]
133133
}
134134
].to_json ,:status => 200)
135135

136-
@response = Qiita::API.search(@search_word, token: @expected_token, stocked: 1)
136+
@response = Qiita::API.search(@search_word, :token => @expected_token, :stocked => 1)
137137
end
138138

139139
it 'Response should be Hash' do

0 commit comments

Comments
 (0)