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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78a2c20cf03921bc1c14b0ec1b5a611e481537de
4
- data.tar.gz: 3161bccf9aea327ca6649c4d92a5134c81598d10
3
+ metadata.gz: 57e93044a7b703705d95956647d9abaf81dc1622
4
+ data.tar.gz: 82ac9ee1689feb4f35c469318e1bc70de39dc72a
5
5
  SHA512:
6
- metadata.gz: 639f14f913a53042bcbaaeb1ddd3ab6f364b9b4cc2c45d828e67f328f7cb903c747406d6c7ae99cc6fa778a3525588af28b3eb525509cfbaf89e7fecb20a4fe7
7
- data.tar.gz: c58765db774f55aca1180344bc0ea42da8cca83b6872e197c49fc3497b0f8f40e349306e99171b3338e6ae0370504c401970e5d7318c67abfa103532575c35b3
6
+ metadata.gz: 20107ce0646546540dc4f40524bb7132e305266524a4f052b2c5a5c9e0eee2583c584e35dfd1c1f3cc76e1fe2a7e8a80963f77967e4b99a2d71a9f74cb6c0529
7
+ data.tar.gz: 21d58c4a6c6a3eb624c374d1c439c51507672ce04f00605e83b9aa7798f6a3ebcd14b301af41d7470ddc3d85c2ee0d5212bfa3b404624e6e6f495229569acab8
@@ -5,36 +5,49 @@ require 'uri'
5
5
  class StackConnect
6
6
  attr_accessor :api, :site, :uri
7
7
 
8
- @@VERSION = "0.0.8"
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
- @@uri.path = '/2.1/questions'
15
- @@uri.query = ({:site=>@@site, :filter=>'!--Me6hWI5gUs', :fromdate=>from_date}).to_query
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
- @@uri.path = '/2.1/tags'
22
- @@uri.query = ({ :order=>'desc', :sort=>'popular', :site=>@@site}).to_query
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
- @@uri.path = '/2.1/tags'
28
- @@uri.query = ({ :fromdate => from_date, :site=>'stackoverflow', :sort => 'activity', :order=>'desc'}).to_query
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
- @@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)
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
@@ -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.8
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-17 00:00:00.000000000 Z
11
+ date: 2014-02-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber