stackconnect 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/stackconnect.rb +26 -13
- data/spec/stack_spec.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57e93044a7b703705d95956647d9abaf81dc1622
|
4
|
+
data.tar.gz: 82ac9ee1689feb4f35c469318e1bc70de39dc72a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20107ce0646546540dc4f40524bb7132e305266524a4f052b2c5a5c9e0eee2583c584e35dfd1c1f3cc76e1fe2a7e8a80963f77967e4b99a2d71a9f74cb6c0529
|
7
|
+
data.tar.gz: 21d58c4a6c6a3eb624c374d1c439c51507672ce04f00605e83b9aa7798f6a3ebcd14b301af41d7470ddc3d85c2ee0d5212bfa3b404624e6e6f495229569acab8
|
data/lib/stackconnect.rb
CHANGED
@@ -5,36 +5,49 @@ require 'uri'
|
|
5
5
|
class StackConnect
|
6
6
|
attr_accessor :api, :site, :uri
|
7
7
|
|
8
|
-
@@VERSION = "0.0.
|
8
|
+
@@VERSION = "0.0.9"
|
9
9
|
@@api = 'http://api.stackexchange.com/'
|
10
10
|
@@site = 'stackoverflow'
|
11
11
|
@@uri = URI(@@api)
|
12
12
|
|
13
13
|
def retrieve_total_questions(from_date)
|
14
|
-
|
15
|
-
|
16
|
-
data = JSON.parse(@@uri.open.read)
|
14
|
+
args = {:fromdate=>from_date, :filter => '!--Me6hWI5gUs'}
|
15
|
+
data = form_query('/2.1/questions', args)
|
17
16
|
count = data["total"]
|
18
17
|
end
|
19
18
|
|
20
19
|
def retrieve_most_popular_tags
|
21
|
-
|
22
|
-
|
23
|
-
data = JSON.parse(@@uri.open.read)
|
20
|
+
args = {:sort=>'popular', :order=>'desc'}
|
21
|
+
form_query('/2.1/tags', args)
|
24
22
|
end
|
25
23
|
|
26
24
|
def retrieve_day_popular_tags(from_date)
|
27
|
-
|
28
|
-
|
29
|
-
data = JSON.parse(@@uri.open.read)
|
25
|
+
args = { :fromdate => from_date, :sort=>'activity', :order=>'desc'}
|
26
|
+
form_query('/2.1/tags', args)
|
30
27
|
end
|
31
28
|
|
32
29
|
def retrieve_hot_questions(from_date)
|
33
|
-
|
34
|
-
|
35
|
-
data = JSON.parse(@@uri.open.read)
|
30
|
+
args = {:fromdate => from_date, :sort =>'hot', :order=>'desc'}
|
31
|
+
form_query('/2.1/questions', args)
|
36
32
|
end
|
37
33
|
|
34
|
+
def retrieve_hot_questions(from_date, page)
|
35
|
+
args = {:fromdate => from_date, :sort=>'hot', :order=>'desc', :page=>page, :pagesize=>100}
|
36
|
+
form_query('/2.1/questions', args)
|
37
|
+
end
|
38
|
+
|
39
|
+
def form_query (path, args)
|
40
|
+
args.merge!(:site=>'stackoverflow')
|
41
|
+
@@uri.path = path
|
42
|
+
@@uri.query = args.to_query
|
43
|
+
puts @@uri
|
44
|
+
parse
|
45
|
+
end
|
46
|
+
|
47
|
+
def parse
|
48
|
+
JSON.parse(@@uri.open.read)
|
49
|
+
end
|
50
|
+
|
38
51
|
def self.return_version
|
39
52
|
@@VERSION
|
40
53
|
end
|
data/spec/stack_spec.rb
CHANGED
@@ -20,9 +20,9 @@ describe StackConnect do
|
|
20
20
|
@connect.retrieve_day_popular_tags(date).should be_a(Hash)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "retrieve hot questions returns json object" do
|
23
|
+
it "retrieve hot questions returns json object" do
|
24
24
|
date = Date.today.to_time.to_i
|
25
|
-
@connect.retrieve_hot_questions(date).should be_a(Hash)
|
25
|
+
@connect.retrieve_hot_questions(date, 1).should be_a(Hash)
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackconnect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- amirtcheva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|