stackconnect 0.0.7 → 0.0.8
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/README.md +6 -4
- data/lib/stackconnect.rb +7 -1
- data/spec/stack_spec.rb +7 -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: 78a2c20cf03921bc1c14b0ec1b5a611e481537de
|
4
|
+
data.tar.gz: 3161bccf9aea327ca6649c4d92a5134c81598d10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 639f14f913a53042bcbaaeb1ddd3ab6f364b9b4cc2c45d828e67f328f7cb903c747406d6c7ae99cc6fa778a3525588af28b3eb525509cfbaf89e7fecb20a4fe7
|
7
|
+
data.tar.gz: c58765db774f55aca1180344bc0ea42da8cca83b6872e197c49fc3497b0f8f40e349306e99171b3338e6ae0370504c401970e5d7318c67abfa103532575c35b3
|
data/README.md
CHANGED
@@ -21,8 +21,10 @@ Or install it yourself as:
|
|
21
21
|
These methods are quota restricted. The Stack Exchange API only allows a quota of 10000 without an API key: http://api.stackexchange.com/docs/authentication. Once you get over that quota without a key, your IP address will be throttled from making any more requests until the next day.
|
22
22
|
|
23
23
|
### Retrieve Total Number of Questions
|
24
|
-
|
25
|
-
|
24
|
+
```
|
25
|
+
sc = StackConnect.new
|
26
|
+
total = sc.retrieve_total_questions(from_date)
|
27
|
+
```
|
26
28
|
|
27
29
|
This will return an number.
|
28
30
|
|
@@ -30,12 +32,12 @@ From date has to be in Unix date format. So for example, to retrieve the total n
|
|
30
32
|
|
31
33
|
```
|
32
34
|
date = Date.today.to_time.to_i
|
33
|
-
total =
|
35
|
+
total = sc.retrieve_total_questions(from_date)
|
34
36
|
```
|
35
37
|
|
36
38
|
### Retrieve Most Popular Tags of All Time
|
37
39
|
|
38
|
-
`data =
|
40
|
+
`data = sc.retrieve_most_popular_tags`
|
39
41
|
|
40
42
|
This will return a JSON data object which you can then parse. An example:
|
41
43
|
|
data/lib/stackconnect.rb
CHANGED
@@ -5,7 +5,7 @@ require 'uri'
|
|
5
5
|
class StackConnect
|
6
6
|
attr_accessor :api, :site, :uri
|
7
7
|
|
8
|
-
@@VERSION = "0.0.
|
8
|
+
@@VERSION = "0.0.8"
|
9
9
|
@@api = 'http://api.stackexchange.com/'
|
10
10
|
@@site = 'stackoverflow'
|
11
11
|
@@uri = URI(@@api)
|
@@ -29,6 +29,12 @@ class StackConnect
|
|
29
29
|
data = JSON.parse(@@uri.open.read)
|
30
30
|
end
|
31
31
|
|
32
|
+
def retrieve_hot_questions(from_date)
|
33
|
+
@@uri.path = '/2.1/questions'
|
34
|
+
@@uri.query = ({ :fromdate=>from_date, :site=>'stackoverflow', :sort=>'hot', :order=>'desc'}).to_query
|
35
|
+
data = JSON.parse(@@uri.open.read)
|
36
|
+
end
|
37
|
+
|
32
38
|
def self.return_version
|
33
39
|
@@VERSION
|
34
40
|
end
|
data/spec/stack_spec.rb
CHANGED
@@ -11,13 +11,18 @@ describe StackConnect do
|
|
11
11
|
@connect.retrieve_total_questions(date).to_i.should be_a(Fixnum)
|
12
12
|
end
|
13
13
|
|
14
|
-
it "retrieve popular tags should return
|
14
|
+
it "retrieve popular tags should return json object" do
|
15
15
|
@connect.retrieve_most_popular_tags.should be_a(Hash)
|
16
16
|
end
|
17
17
|
|
18
|
-
it "retrieve popular tags of the days returns
|
18
|
+
it "retrieve popular tags of the days returns json object" do
|
19
19
|
date = Date.today.to_time.to_i
|
20
20
|
@connect.retrieve_day_popular_tags(date).should be_a(Hash)
|
21
21
|
end
|
22
|
+
|
23
|
+
it "retrieve hot questions returns json object" do
|
24
|
+
date = Date.today.to_time.to_i
|
25
|
+
@connect.retrieve_hot_questions(date).should be_a(Hash)
|
26
|
+
end
|
22
27
|
end
|
23
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.8
|
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-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|