qiita 1.0.4 → 1.0.5
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 +4 -4
- data/CHANGELOG.md +8 -5
- data/lib/qiita/resource_based_methods.rb +49 -0
- data/lib/qiita/version.rb +1 -1
- metadata +2 -3
- data/script/generate-objc +0 -152
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 103dfda3a4a2c0db813e4908fa62b94873eaf702
|
4
|
+
data.tar.gz: 52dbaf4cdd23b18cdcdeaf38d3ec3c0735bba189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 226526d7c16bb443326855cb615324b1535cb3299ac1daf9f87fd956bbecccbffe1a0ed5c4ff0528b06f93ac9e6cc1ecc80db48eb7ae07dab12181bda3463ede
|
7
|
+
data.tar.gz: c1321b24f99122b2af1f989731d7e0bf5626b8883694e27db36a6bb294c6216979092bc99fc10c9031f0760fac9f3c9ebc329ded9d51dcad1eb1bc953d9c8168
|
data/CHANGELOG.md
CHANGED
@@ -1,14 +1,17 @@
|
|
1
|
+
## 1.0.5
|
2
|
+
- Add client methods about following, LGTM, and stock
|
3
|
+
|
1
4
|
## 1.0.4
|
2
|
-
|
5
|
+
- Add list_teams method
|
3
6
|
|
4
7
|
## 1.0.3
|
5
|
-
|
8
|
+
- Escape request URL path
|
6
9
|
|
7
10
|
## 1.0.2
|
8
|
-
|
11
|
+
- Add a new API: list_item_stockers(item_id)
|
9
12
|
|
10
13
|
## 1.0.1
|
11
|
-
|
14
|
+
- Fix response body existence check logic
|
12
15
|
|
13
16
|
## 1.0.0
|
14
|
-
|
17
|
+
- Support Qiita API v2
|
@@ -119,6 +119,13 @@ module Qiita
|
|
119
119
|
get("/api/v2/users/#{user_id}/stocks", params, headers)
|
120
120
|
end
|
121
121
|
|
122
|
+
# ### Qiita::Client#get_item_stock(item_id, params = nil, headers = nil)
|
123
|
+
# 特定の投稿をストックしている場合に204を返します。
|
124
|
+
#
|
125
|
+
def get_item_stock(item_id, params = nil, headers = nil)
|
126
|
+
get("/api/v2/items/#{item_id}/stock", params, headers)
|
127
|
+
end
|
128
|
+
|
122
129
|
# ### Qiita::Client#stock_item(item_id, params = nil, headers = nil)
|
123
130
|
# 特定の投稿をストックします。
|
124
131
|
#
|
@@ -210,6 +217,27 @@ module Qiita
|
|
210
217
|
get("/api/v2/users/#{user_id}/following_tags", params, headers)
|
211
218
|
end
|
212
219
|
|
220
|
+
# ### Qiita::Client#get_tag_following(id, params = nil, headers = nil)
|
221
|
+
# 特定のタグをフォローしている場合に204を返します。
|
222
|
+
#
|
223
|
+
def get_tag_following(id, params = nil, headers = nil)
|
224
|
+
get("/api/v2/tags/#{id}/following", params, headers)
|
225
|
+
end
|
226
|
+
|
227
|
+
# ### Qiita::Client#follow_tag(id, params = nil, headers = nil)
|
228
|
+
# 特定のタグをフォローします。
|
229
|
+
#
|
230
|
+
def follow_tag(id, params = nil, headers = nil)
|
231
|
+
put("/api/v2/tags/#{id}/following", params, headers)
|
232
|
+
end
|
233
|
+
|
234
|
+
# ### Qiita::Client#unfollow_tag(id, params = nil, headers = nil)
|
235
|
+
# 特定のタグへのフォローを解除します。
|
236
|
+
#
|
237
|
+
def unfollow_tag(id, params = nil, headers = nil)
|
238
|
+
delete("/api/v2/tags/#{id}/following", params, headers)
|
239
|
+
end
|
240
|
+
|
213
241
|
# ### Qiita::Client#list_teams(params = nil, headers = nil)
|
214
242
|
# 現在のリクエストで認証されているユーザが所属している全てのチームを返します。
|
215
243
|
#
|
@@ -293,5 +321,26 @@ module Qiita
|
|
293
321
|
def list_item_stockers(item_id, params = nil, headers = nil)
|
294
322
|
get("/api/v2/items/#{item_id}/stockers", params, headers)
|
295
323
|
end
|
324
|
+
|
325
|
+
# ### Qiita::Client#get_user_following(user_id, params = nil, headers = nil)
|
326
|
+
# 特定のユーザをフォローしている場合に204を返します。
|
327
|
+
#
|
328
|
+
def get_user_following(user_id, params = nil, headers = nil)
|
329
|
+
get("/api/v2/users/#{user_id}/following", params, headers)
|
330
|
+
end
|
331
|
+
|
332
|
+
# ### Qiita::Client#follow_user(user_id, params = nil, headers = nil)
|
333
|
+
# 特定のユーザをフォローします。
|
334
|
+
#
|
335
|
+
def follow_user(user_id, params = nil, headers = nil)
|
336
|
+
put("/api/v2/users/#{user_id}/following", params, headers)
|
337
|
+
end
|
338
|
+
|
339
|
+
# ### Qiita::Client#unfollow_user(user_id, params = nil, headers = nil)
|
340
|
+
# 特定のユーザへのフォローを外します。
|
341
|
+
#
|
342
|
+
def unfollow_user(user_id, params = nil, headers = nil)
|
343
|
+
delete("/api/v2/users/#{user_id}/following", params, headers)
|
344
|
+
end
|
296
345
|
end
|
297
346
|
end
|
data/lib/qiita/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -225,7 +225,6 @@ files:
|
|
225
225
|
- lib/qiita/version.rb
|
226
226
|
- qiita.gemspec
|
227
227
|
- script/generate
|
228
|
-
- script/generate-objc
|
229
228
|
- spec/qiita/client_spec.rb
|
230
229
|
- spec/spec_helper.rb
|
231
230
|
homepage: https://github.com/increments/qiita-rb
|
data/script/generate-objc
DELETED
@@ -1,152 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# # script/generate-objc
|
3
|
-
# Generates a subclass of AFHTTPSessionManager from given JSON Schema.
|
4
|
-
#
|
5
|
-
# ## Usage
|
6
|
-
# Run this script with a path to JSON Schema of Qiita API v2, available only for staff.
|
7
|
-
#
|
8
|
-
# ```sh
|
9
|
-
# bundle exec ./script/generate-objc [-h|-m] INCQiitaSessionManager /path/to/json/schema > INCQiitaSessionManager.[h|m]
|
10
|
-
# ```
|
11
|
-
#
|
12
|
-
require "active_support/core_ext/object/try"
|
13
|
-
require "active_support/core_ext/string/indent"
|
14
|
-
require "active_support/core_ext/string/inflections"
|
15
|
-
require "active_support/core_ext/string/strip"
|
16
|
-
require "json_schema"
|
17
|
-
require "optparse"
|
18
|
-
require "ostruct"
|
19
|
-
require "yaml"
|
20
|
-
|
21
|
-
# View object class to generate String representation of each method.
|
22
|
-
method_class = Class.new(OpenStruct) do
|
23
|
-
def to_s
|
24
|
-
if header?
|
25
|
-
<<-EOS.strip_heredoc
|
26
|
-
/// #{description}
|
27
|
-
#{return_type_marker}#{wrapped_method_signature(return_type_marker.length).indent(8).strip};
|
28
|
-
EOS
|
29
|
-
else
|
30
|
-
<<-EOS.strip_heredoc
|
31
|
-
#{return_type_marker}#{wrapped_method_signature(return_type_marker.length).indent(8).strip} {
|
32
|
-
NSString *path = [NSString stringWithFormat:#{path_format_and_arguments}];
|
33
|
-
return [self #{request_method}:path parameters:parameters success:success failure:failure];
|
34
|
-
}
|
35
|
-
EOS
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def return_type_marker
|
42
|
-
"- (NSURLSessionDataTask *)"
|
43
|
-
end
|
44
|
-
|
45
|
-
def wrapped_method_signature(offset)
|
46
|
-
components = method_signature.split(/ (?=[0-9A-Za-z_]+:)/)
|
47
|
-
colon_position = offset + components[0].index(":")
|
48
|
-
aligned = [components[0]]
|
49
|
-
components[1..-1].each do |component|
|
50
|
-
aligned << " " * (colon_position - component.index(":")) + component
|
51
|
-
end
|
52
|
-
aligned.join("\n")
|
53
|
-
end
|
54
|
-
|
55
|
-
def method_signature
|
56
|
-
camelize_objcish(method_name) + with_arguments
|
57
|
-
end
|
58
|
-
|
59
|
-
def with_arguments
|
60
|
-
arguments = required_argument_names.map {|name|
|
61
|
-
camelize_objcish(name) + ":(NSString *)" + camelize_objcish(name)
|
62
|
-
}
|
63
|
-
arguments << "parameters:(NSDictionary *)parameters"
|
64
|
-
arguments << "success:(void (^)(NSURLSessionDataTask *task, id responseObject))success"
|
65
|
-
arguments << "failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure"
|
66
|
-
"With" + upcase_first(arguments.join(" "))
|
67
|
-
end
|
68
|
-
|
69
|
-
def camelize_objcish(name)
|
70
|
-
name = name.split(/_/).map {|component|
|
71
|
-
case component
|
72
|
-
when "id" then "i_d" # to camelize into "ID"
|
73
|
-
else component
|
74
|
-
end
|
75
|
-
}.join("_")
|
76
|
-
name =~ /^i_d/ ? name.camelize : name.camelize(:lower)
|
77
|
-
end
|
78
|
-
|
79
|
-
def upcase_first(s)
|
80
|
-
s[0].upcase + s[1..-1]
|
81
|
-
end
|
82
|
-
|
83
|
-
def path_format_and_arguments
|
84
|
-
placeholder_pattern = %r<{\(.*/([^/]+)\)}>
|
85
|
-
format = %Q<@"#{href.gsub(placeholder_pattern, '%@')}">
|
86
|
-
keys = href.scan(placeholder_pattern).flatten
|
87
|
-
arguments = keys.map {|key| camelize_objcish(key) }
|
88
|
-
([format] + arguments).join(", ")
|
89
|
-
end
|
90
|
-
|
91
|
-
def path
|
92
|
-
?" + href.gsub(%r<{\(.*/([^/]+)\)}>, '#{\1}') + ?"
|
93
|
-
end
|
94
|
-
|
95
|
-
def header?
|
96
|
-
_generates_header
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
opt = OptionParser.new
|
101
|
-
opt.on("-h CLASS") {|c| $class_name = c; $generates_header = true }
|
102
|
-
opt.on("-m CLASS") {|c| $class_name = c; $generates_header = false }
|
103
|
-
opt.parse!(ARGV)
|
104
|
-
unless $class_name
|
105
|
-
abort "Neither -h nor -m given. Aborted."
|
106
|
-
end
|
107
|
-
path_to_json_schema = ARGV[0]
|
108
|
-
hash = YAML.load_file(path_to_json_schema)
|
109
|
-
schema = JsonSchema.parse!(hash).tap(&:expand_references!)
|
110
|
-
links = schema.properties.values.map(&:links).flatten
|
111
|
-
methods = links.map do |link|
|
112
|
-
method_class.new(
|
113
|
-
_generates_header: $generates_header,
|
114
|
-
available_parameters: (link.schema.try(:properties) || {}).map do |name, property|
|
115
|
-
{
|
116
|
-
description: property.description,
|
117
|
-
name: name,
|
118
|
-
type: property.type,
|
119
|
-
}
|
120
|
-
end,
|
121
|
-
description: link.description,
|
122
|
-
href: link.href,
|
123
|
-
method_name: link.title,
|
124
|
-
request_method: link.method.upcase,
|
125
|
-
required_argument_names: link.href.scan(%r<{\(.*/([^/]+)\)}>).flatten,
|
126
|
-
)
|
127
|
-
end
|
128
|
-
if $generates_header
|
129
|
-
puts <<-EOS.strip_heredoc
|
130
|
-
#import <AFNetworking/AFHTTPSessionManager.h>
|
131
|
-
|
132
|
-
@interface #{$class_name} : AFHTTPSessionManager
|
133
|
-
|
134
|
-
#{methods.join("\n").indent(4).strip}
|
135
|
-
|
136
|
-
@end
|
137
|
-
EOS
|
138
|
-
else
|
139
|
-
puts <<-EOS.strip_heredoc
|
140
|
-
#import "#{$class_name}.h"
|
141
|
-
|
142
|
-
@implementation #{$class_name}
|
143
|
-
|
144
|
-
+ (instancetype)manager {
|
145
|
-
return [[[self class] alloc] initWithBaseURL:[NSURL URLWithString:@"https://qiita.com"]];
|
146
|
-
}
|
147
|
-
|
148
|
-
#{methods.join("\n").indent(4).strip}
|
149
|
-
|
150
|
-
@end
|
151
|
-
EOS
|
152
|
-
end
|