Package not found. Please check the package name and try again.
so_repute 0.0.1
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +74 -0
- data/Rakefile +5 -0
- data/lib/so_repute.rb +63 -0
- data/lib/so_repute/version.rb +3 -0
- data/so_repute.gemspec +28 -0
- data/spec/lib/so_repute_spec.rb +75 -0
- data/spec/spec_helper.rb +1 -0
- metadata +140 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Aaditi Jain
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# SoRepute
|
|
2
|
+
|
|
3
|
+
Fetches StackOverflow information of a person from his/her stackoverflow user_id
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
**It is advisable to register your application in at stackapps when using this gem (which inturn uses stackexchange API). Use this link to register your application at stackapps https://stackapps.com/apps/oauth/register**
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
`gem 'so_repute'`
|
|
11
|
+
|
|
12
|
+
And then execute:
|
|
13
|
+
`$ bundle`
|
|
14
|
+
|
|
15
|
+
Or install it yourself as:
|
|
16
|
+
`$ gem install so_repute`
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
**require 'so_repute'**
|
|
21
|
+
|
|
22
|
+
**user = SoRepute::Base.new(user_id, app_key)**
|
|
23
|
+
|
|
24
|
+
#app_key is obtained when you register your app at stackapps. Registering your app alows you a larger number of hit-quota per day. If you do not want to register your app, do : SoRepute::Base.new(user_id)
|
|
25
|
+
|
|
26
|
+
1) **user.reputation**
|
|
27
|
+
|
|
28
|
+
#returns current total reputation of the user.
|
|
29
|
+
|
|
30
|
+
2) **user.reputation_change_quarter**
|
|
31
|
+
|
|
32
|
+
#returns users reputation gained in the current quarter
|
|
33
|
+
|
|
34
|
+
3) **user.reputation_change_month**
|
|
35
|
+
|
|
36
|
+
#returns users reputation gained in the current month
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
4) **user.reputation_change_week**
|
|
40
|
+
|
|
41
|
+
#returns users reputation gained in the current week
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
5) **user.reputation_change_day**
|
|
45
|
+
|
|
46
|
+
#returns users reputation gained today(UTC)
|
|
47
|
+
|
|
48
|
+
6) **user.badges**
|
|
49
|
+
|
|
50
|
+
#Returns a array with count of each type of badge as well as total number of badges of a user in a format as follows: {bronze: 12, silver: 4, gold: 4, total: 20}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
7) **user.total_answers**
|
|
54
|
+
|
|
55
|
+
#returns total number of answers answered by a user.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
8) **user.total_questions**
|
|
59
|
+
|
|
60
|
+
#returns total number of questions asked by a user.
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
9) **user.accepted_answers**
|
|
64
|
+
|
|
65
|
+
#returns totalnumber of answers by the user that were accepted as correct answer.
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
## Contributing
|
|
69
|
+
|
|
70
|
+
1. Fork it
|
|
71
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
72
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
73
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
74
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/so_repute.rb
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
require "so_repute/version"
|
|
2
|
+
require 'httparty'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'open-uri'
|
|
5
|
+
module SoRepute
|
|
6
|
+
class Base
|
|
7
|
+
def initialize(user_id, app_key=nil)
|
|
8
|
+
@user_id = user_id
|
|
9
|
+
@app_key = app_key
|
|
10
|
+
user_info = HTTParty.get("https://api.stackexchange.com/users/#{@user_id}/?site=stackoverflow&key=#{@app_key}").parsed_response
|
|
11
|
+
if user_info.keys.include?("error_id")
|
|
12
|
+
raise ((user_info["error_name"] == "throttle_violation") ? "Number Of Requests exceeded the daily quota of #{@app_key.nil? ? 300 : 10000}" : "Incorrect user_id or app_key")
|
|
13
|
+
else
|
|
14
|
+
@user_info = user_info["items"][0]
|
|
15
|
+
@user_answers = HTTParty.get("https://api.stackexchange.com/users/#{@user_id}/answers/?site=stackoverflow&pagesize=100&filter=!9YdnSQVoS&page=1" + (@app_key.nil? ? "" : "&key=#{@app_key}")).parsed_response
|
|
16
|
+
@user_questions = HTTParty.get("https://api.stackexchange.com/users/#{@user_id}/questions/?site=stackoverflow&filter=!9YdnSQVoS&pagesize=100&page=1" + (@app_key.nil? ? "" : "&key=#{@app_key}")).parsed_response
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def reputation
|
|
21
|
+
@user_info["reputation"]
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def reputation_change_quarter
|
|
25
|
+
@user_info["reputation_change_quarter"]
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def reputation_change_month
|
|
29
|
+
@user_info["reputation_change_month"]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def reputation_change_week
|
|
33
|
+
@user_info["reputation_change_week"]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def reputation_change_day
|
|
37
|
+
@user_info["reputation_change_day"]
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def badges
|
|
41
|
+
bronze = @user_info["badge_counts"]["bronze"]
|
|
42
|
+
silver = @user_info["badge_counts"]["silver"]
|
|
43
|
+
gold = @user_info["badge_counts"]["gold"]
|
|
44
|
+
total = bronze + silver + gold
|
|
45
|
+
{bronze: bronze, silver: silver, gold: gold, total: total }
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def total_answers
|
|
49
|
+
@user_answers["total"]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def accepted_answers
|
|
53
|
+
@search_page = Nokogiri::HTML(open("https://stackoverflow.com/search?q=user%3A#{@user_id}+isaccepted%3Ayes"))
|
|
54
|
+
@search_page.css('div.results-header > h2').first.text.delete(",results").strip.to_i
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def total_questions
|
|
59
|
+
@user_questions["total"]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
end
|
data/so_repute.gemspec
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'so_repute/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "so_repute"
|
|
8
|
+
spec.version = SoRepute::VERSION
|
|
9
|
+
spec.authors = ["Aaditi Jain"]
|
|
10
|
+
spec.email = ["aaditi2290@gmail.com"]
|
|
11
|
+
spec.description = %q{Fetches stackoverflow information of a person from his/her stackoverflow user_id}
|
|
12
|
+
spec.summary = %q{Fetches stackoverflow information of a person from his/her stackoverflow user_id}
|
|
13
|
+
spec.homepage = "https://github.com/Aaditi/so_repute"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
|
+
spec.require_paths = ["lib"]
|
|
20
|
+
|
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
spec.add_development_dependency "rspec"
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
spec.add_runtime_dependency "nokogiri", "~> 1.6.5"
|
|
27
|
+
spec.add_runtime_dependency "httparty", "~> 0.13.3"
|
|
28
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'httparty'
|
|
3
|
+
require 'nokogiri'
|
|
4
|
+
require 'open-uri'
|
|
5
|
+
|
|
6
|
+
describe SoRepute do
|
|
7
|
+
before (:all) do
|
|
8
|
+
@user = SoRepute::Base.new(2440312, "BgnaQ2fdzYqqWRX1RQvxog((")
|
|
9
|
+
@required_user_info = HTTParty.get("https://api.stackexchange.com/users/2440312/?site=stackoverflow&key=BgnaQ2fdzYqqWRX1RQvxog((").parsed_response["items"][0]
|
|
10
|
+
@required_user_answers = HTTParty.get("https://api.stackexchange.com/users/2440312/answers/?site=stackoverflow&filter=!9YdnSQVoS&pagesize=100&page=1&key=BgnaQ2fdzYqqWRX1RQvxog((").parsed_response
|
|
11
|
+
@required_user_questions = HTTParty.get("https://api.stackexchange.com/users/2440312/questions/?site=stackoverflow&filter=!9YdnSQVoS&pagesize=100&page=1&key=BgnaQ2fdzYqqWRX1RQvxog((").parsed_response
|
|
12
|
+
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
describe '#reputation' do
|
|
16
|
+
it 'should output users total reputation' do
|
|
17
|
+
@user.reputation.should eq(@required_user_info["reputation"])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
describe '#reputation_change_quarter'do
|
|
22
|
+
it 'should output users reputation gained in the current quarter' do
|
|
23
|
+
@user.reputation_change_quarter.should eq(@required_user_info["reputation_change_quarter"])
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#reputation_change_month'do
|
|
28
|
+
it 'should output users reputation gained in the current month' do
|
|
29
|
+
@user.reputation_change_month.should eq(@required_user_info["reputation_change_month"])
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#reputation_change_week'do
|
|
34
|
+
it 'should output users reputation gained in the current week' do
|
|
35
|
+
@user.reputation_change_week.should eq(@required_user_info["reputation_change_week"])
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
describe '#reputation_change_day'do
|
|
41
|
+
it 'should output users reputation gained in the day(UTC)' do
|
|
42
|
+
@user.reputation_change_day.should eq(@required_user_info["reputation_change_day"])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
describe '#badges'do
|
|
47
|
+
it 'should output a hash with counts of different badges' do
|
|
48
|
+
@user.badges.should eq({bronze: @required_user_info["badge_counts"]["bronze"],
|
|
49
|
+
silver: @required_user_info["badge_counts"]["silver"],
|
|
50
|
+
gold: @required_user_info["badge_counts"]["gold"],
|
|
51
|
+
total: (@required_user_info["badge_counts"]["bronze"] + @required_user_info["badge_counts"]["silver"] + @required_user_info["badge_counts"]["gold"] )
|
|
52
|
+
})
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
describe '#total_answers'do
|
|
57
|
+
it 'should output total number of answers given by the user' do
|
|
58
|
+
@user.total_answers.should eq(@required_user_answers["total"])
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
describe '#total_questions'do
|
|
63
|
+
it 'should output total number of questions given by the user' do
|
|
64
|
+
@user.total_questions.should eq(@required_user_questions["total"])
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
describe '#accepted_answers'do
|
|
69
|
+
it 'should output total number of accpeted anwers of an user' do
|
|
70
|
+
page = (Nokogiri::HTML(open("https://stackoverflow.com/search?q=user%3A2440312+isaccepted%3Ayes")))
|
|
71
|
+
required_result = page.css('div.results-header > h2').first.text.delete(",results").strip.to_i
|
|
72
|
+
@user.accepted_answers.should eq(required_result)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
require 'so_repute'
|
metadata
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: so_repute
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Aaditi Jain
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2014-12-18 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.3'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '1.3'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: rspec
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ! '>='
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :development
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ! '>='
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
- !ruby/object:Gem::Dependency
|
|
63
|
+
name: nokogiri
|
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
|
65
|
+
none: false
|
|
66
|
+
requirements:
|
|
67
|
+
- - ~>
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: 1.6.5
|
|
70
|
+
type: :runtime
|
|
71
|
+
prerelease: false
|
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
+
none: false
|
|
74
|
+
requirements:
|
|
75
|
+
- - ~>
|
|
76
|
+
- !ruby/object:Gem::Version
|
|
77
|
+
version: 1.6.5
|
|
78
|
+
- !ruby/object:Gem::Dependency
|
|
79
|
+
name: httparty
|
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
|
81
|
+
none: false
|
|
82
|
+
requirements:
|
|
83
|
+
- - ~>
|
|
84
|
+
- !ruby/object:Gem::Version
|
|
85
|
+
version: 0.13.3
|
|
86
|
+
type: :runtime
|
|
87
|
+
prerelease: false
|
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ~>
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: 0.13.3
|
|
94
|
+
description: Fetches stackoverflow information of a person from his/her stackoverflow
|
|
95
|
+
user_id
|
|
96
|
+
email:
|
|
97
|
+
- aaditi2290@gmail.com
|
|
98
|
+
executables: []
|
|
99
|
+
extensions: []
|
|
100
|
+
extra_rdoc_files: []
|
|
101
|
+
files:
|
|
102
|
+
- .gitignore
|
|
103
|
+
- Gemfile
|
|
104
|
+
- LICENSE.txt
|
|
105
|
+
- README.md
|
|
106
|
+
- Rakefile
|
|
107
|
+
- lib/so_repute.rb
|
|
108
|
+
- lib/so_repute/version.rb
|
|
109
|
+
- so_repute.gemspec
|
|
110
|
+
- spec/lib/so_repute_spec.rb
|
|
111
|
+
- spec/spec_helper.rb
|
|
112
|
+
homepage: https://github.com/Aaditi/so_repute
|
|
113
|
+
licenses:
|
|
114
|
+
- MIT
|
|
115
|
+
post_install_message:
|
|
116
|
+
rdoc_options: []
|
|
117
|
+
require_paths:
|
|
118
|
+
- lib
|
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
|
+
none: false
|
|
121
|
+
requirements:
|
|
122
|
+
- - ! '>='
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
|
+
none: false
|
|
127
|
+
requirements:
|
|
128
|
+
- - ! '>='
|
|
129
|
+
- !ruby/object:Gem::Version
|
|
130
|
+
version: '0'
|
|
131
|
+
requirements: []
|
|
132
|
+
rubyforge_project:
|
|
133
|
+
rubygems_version: 1.8.28
|
|
134
|
+
signing_key:
|
|
135
|
+
specification_version: 3
|
|
136
|
+
summary: Fetches stackoverflow information of a person from his/her stackoverflow
|
|
137
|
+
user_id
|
|
138
|
+
test_files:
|
|
139
|
+
- spec/lib/so_repute_spec.rb
|
|
140
|
+
- spec/spec_helper.rb
|