biostars-api 0.1.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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +61 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/biostars-api.gemspec +38 -0
- data/lib/biostars/api.rb +39 -0
- data/lib/biostars/api/exceptions.rb +17 -0
- data/lib/biostars/api/post.rb +99 -0
- data/lib/biostars/api/stats.rb +119 -0
- data/lib/biostars/api/traffic.rb +21 -0
- data/lib/biostars/api/user.rb +39 -0
- data/lib/biostars/api/version.rb +6 -0
- data/lib/biostars/api/vote.rb +43 -0
- metadata +264 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0fdccec4a0660cc65e66e0bc43eb4afeb83175ac
|
4
|
+
data.tar.gz: 908dc07939e8cbce249a44024d852946dbd29e0d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 262c5495484997fd42e2a4a5da489f55f61410db38bb9f4f1f8ea0d84c94b8ee4df473f1d2b0511998f530796f969b7bc1dc2e1ac469625871d99354b2ea12d5
|
7
|
+
data.tar.gz: 0779bcfa383d5bac1dd61fb8c04871850f51165a04ba3d1b2d1f3238c42711a960f25b5ae768de5aa927836e03cc16f9150b4d34f0a8422330f947f68c4c43fd
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Arian Amador
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Biostars::Api
|
2
|
+
|
3
|
+
A wrapper for the [Biostars.org](https://www.biostars.org/) public API.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
* httparty
|
7
|
+
* json
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'biostars-api'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install biostars-api
|
24
|
+
|
25
|
+
## Examples
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
# Retrieve the latest site traffic stats
|
29
|
+
traffic = Biostars::API.traffic
|
30
|
+
p traffic.post_views_last_60_min # number of post views over the last hour
|
31
|
+
|
32
|
+
# Retrieve activity for the last 24 hours.
|
33
|
+
latest_info = Biostars::API::Stats.latest
|
34
|
+
p latest_info.new_users # Arary of user ids [1,2,3..10]
|
35
|
+
p latest_info.comments # Number of comments
|
36
|
+
|
37
|
+
# Retrieve an Array of the lastest users
|
38
|
+
latest_users = latest_info.all_users
|
39
|
+
|
40
|
+
# Get a specific Users information
|
41
|
+
user = Biostars::API::Stats.User.find(latest_users.first.id)
|
42
|
+
p user.id # User id
|
43
|
+
p user.name # Username
|
44
|
+
|
45
|
+
# The same can be achieved for Posts and Votes
|
46
|
+
latest_posts = latest_info.all_posts
|
47
|
+
latest_votes = latest_info.all_votes
|
48
|
+
```
|
49
|
+
|
50
|
+
## Documentation
|
51
|
+
|
52
|
+
* API - https://www.biostars.org/info/api/
|
53
|
+
* Rubydoc - http://www.rubydoc.info/github/arian-amador/biostars-api
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it ( https://github.com/arian-amador/biostars-api/fork )
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "biostars/api"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
$:.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'biostars/api'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "biostars-api"
|
7
|
+
spec.version = Biostars::API::VERSION
|
8
|
+
spec.authors = ["Arian Amador"]
|
9
|
+
spec.email = ["arian@arianamador.com"]
|
10
|
+
|
11
|
+
if spec.respond_to?(:metadata)
|
12
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
|
13
|
+
end
|
14
|
+
|
15
|
+
spec.summary = %q{Gem wrapping biostars.org public API}
|
16
|
+
spec.description = %q{Gem wrapping biostars.org public API}
|
17
|
+
spec.homepage = "https://www.github.com/arian-amador/biostars-api"
|
18
|
+
spec.license = "MIT"
|
19
|
+
|
20
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
|
+
spec.bindir = "exe"
|
22
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
23
|
+
spec.require_paths = ["lib"]
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.8"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
|
28
|
+
spec.add_development_dependency 'minitest', '~> 5.5', '>= 5.5.1'
|
29
|
+
spec.add_development_dependency 'minitest-reporters', '~> 1.0', '>= 1.0.11'
|
30
|
+
spec.add_development_dependency "shoulda-context", '~> 1.2', '>= 1.2.1'
|
31
|
+
spec.add_development_dependency "guard", '~> 2.12', '>= 2.12.4'
|
32
|
+
spec.add_development_dependency "guard-minitest", '~> 2.4', '>= 2.4.4'
|
33
|
+
spec.add_development_dependency "vcr", '~> 2.9', '>= 2.9.3'
|
34
|
+
spec.add_development_dependency "webmock", '~> 1.20', '>= 1.20.4'
|
35
|
+
|
36
|
+
spec.add_dependency "httparty", "~> 0.13.3"
|
37
|
+
spec.add_dependency "json", '~> 1.8', '>= 1.8.2'
|
38
|
+
end
|
data/lib/biostars/api.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../api', __FILE__)
|
3
|
+
|
4
|
+
require 'httparty'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
require "api/exceptions"
|
8
|
+
require "api/version"
|
9
|
+
require "api/traffic"
|
10
|
+
require "api/stats"
|
11
|
+
require "api/user"
|
12
|
+
require "api/post"
|
13
|
+
require "api/vote"
|
14
|
+
|
15
|
+
module Biostars
|
16
|
+
module API
|
17
|
+
|
18
|
+
# Used for API requests
|
19
|
+
API_URL = 'https://www.biostars.org/api'
|
20
|
+
|
21
|
+
# Number of post views over the last 60 min filtered by unique IPs.
|
22
|
+
#
|
23
|
+
# @return [Traffic] returns a Traffic object.
|
24
|
+
# @raise [Biostars::Error] if API is not responding
|
25
|
+
def self.traffic
|
26
|
+
attributes = Biostars::API.get "traffic"
|
27
|
+
attributes ? Biostars::API::Traffic.new(attributes) : raise(Biostars::Error)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Used for general GET http requests to the API
|
31
|
+
#
|
32
|
+
# @param url [String] API request endpoint.
|
33
|
+
# @return [Hash] returns API response
|
34
|
+
def self.get(url)
|
35
|
+
response = HTTParty.get "#{API_URL}/#{url}"
|
36
|
+
response.success? ? JSON.parse(response.body) : false
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Biostars
|
2
|
+
# Generic Error
|
3
|
+
class Error < StandardError; end
|
4
|
+
|
5
|
+
# Raised on User Errors
|
6
|
+
class UserError < Error; end
|
7
|
+
|
8
|
+
# Raised on Post Errors
|
9
|
+
class PostError < Error; end
|
10
|
+
|
11
|
+
# Raised on Vote Errors
|
12
|
+
class VoteError < Error; end
|
13
|
+
|
14
|
+
# Raised on Stats Errors
|
15
|
+
class StatsError < Error; end
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,99 @@
|
|
1
|
+
module Biostars
|
2
|
+
module API
|
3
|
+
class Post
|
4
|
+
|
5
|
+
# @return [Fixnum] number of answers.
|
6
|
+
attr_reader :answer_count
|
7
|
+
|
8
|
+
# @return [String] author name.
|
9
|
+
attr_reader :author
|
10
|
+
|
11
|
+
# @return [Fixnum] author's identifier, a number.
|
12
|
+
attr_reader :author_id
|
13
|
+
|
14
|
+
# @return [Fixnum] number of bookmarks.
|
15
|
+
attr_reader :book_count
|
16
|
+
|
17
|
+
# @return [Fixnum] number of comments.
|
18
|
+
attr_reader :comment_count
|
19
|
+
|
20
|
+
# @return [String] creation date, ISO 8601 format.
|
21
|
+
attr_reader :creation_date
|
22
|
+
|
23
|
+
# @return [Boolean] true if the question has an accepted answer, boolean.
|
24
|
+
attr_reader :has_accepted
|
25
|
+
|
26
|
+
# @return [Fixnum] identifier of the post, a number.
|
27
|
+
attr_reader :id
|
28
|
+
|
29
|
+
# @return [String] date of last edit, ISO 8601 format.
|
30
|
+
attr_reader :lastedit_date
|
31
|
+
|
32
|
+
# @return [Fixnum] user who last edited this post.
|
33
|
+
attr_reader :lastedit_user_id
|
34
|
+
|
35
|
+
# @return [Fixnum] identifier of the parent post.
|
36
|
+
attr_reader :parent_id
|
37
|
+
|
38
|
+
# @return [Fixnum] rank, a number.
|
39
|
+
attr_reader :rank
|
40
|
+
|
41
|
+
# @return [Fixnum] number of replies.
|
42
|
+
attr_reader :reply_count
|
43
|
+
|
44
|
+
# @return [Fixnum] identifier of the root post.
|
45
|
+
attr_reader :root_id
|
46
|
+
|
47
|
+
# @return [String] status message.
|
48
|
+
attr_reader :status
|
49
|
+
|
50
|
+
# @return [Fixnum] status' identifier, a number.
|
51
|
+
attr_reader :status_id
|
52
|
+
|
53
|
+
# @return [Fixnum] number of subscribers following this post.
|
54
|
+
attr_reader :subs_count
|
55
|
+
|
56
|
+
# @return [String] tags.
|
57
|
+
attr_reader :tag_val
|
58
|
+
|
59
|
+
# @return [Fixnum] thread's score.
|
60
|
+
attr_reader :thread_score
|
61
|
+
|
62
|
+
# @return [String] title.
|
63
|
+
attr_reader :title
|
64
|
+
|
65
|
+
# @return [String] type of post.
|
66
|
+
attr_reader :type
|
67
|
+
|
68
|
+
# @return [Fixnum] type's identifier for this post.
|
69
|
+
attr_reader :type_id
|
70
|
+
|
71
|
+
# @return [String] url.
|
72
|
+
attr_reader :url
|
73
|
+
|
74
|
+
# @return [Fixnum] number of views.
|
75
|
+
attr_reader :view_count
|
76
|
+
|
77
|
+
# @return [Fixnum] number of votes.
|
78
|
+
attr_reader :vote_count
|
79
|
+
|
80
|
+
# @return [String] content.
|
81
|
+
attr_reader :xhtml
|
82
|
+
def initialize(attributes)
|
83
|
+
attributes.each do |k,v|
|
84
|
+
instance_variable_set("@#{k}", v) unless v.nil?
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
# Finds post with the given id.
|
89
|
+
#
|
90
|
+
# @param id [Fixnum] post id.
|
91
|
+
# @return [Post] returns Post object.
|
92
|
+
# @raise [Biostars::PostError] if Post is not found.
|
93
|
+
def self.find(id)
|
94
|
+
attributes = Biostars::API.get "post/#{id}"
|
95
|
+
attributes ? new(attributes) : raise(Biostars::PostError)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
@@ -0,0 +1,119 @@
|
|
1
|
+
module Biostars
|
2
|
+
module API
|
3
|
+
class Stats
|
4
|
+
|
5
|
+
# @return [Fixnum] total number of answers as of the given day/date.
|
6
|
+
attr_reader :answers
|
7
|
+
|
8
|
+
# @return [Fixnum] total number of comments as of the given day/date .
|
9
|
+
attr_reader :comments
|
10
|
+
|
11
|
+
# @return [String] the current date, ISO 8601 format
|
12
|
+
attr_reader :date
|
13
|
+
|
14
|
+
# @return [Array] number of new posts in the given day/date .
|
15
|
+
attr_reader :new_posts
|
16
|
+
|
17
|
+
# @return [Array] number of new users in the given day/date .
|
18
|
+
attr_reader :new_users
|
19
|
+
|
20
|
+
# @return [Array] number of new votes in the given day/date .
|
21
|
+
attr_reader :new_votes
|
22
|
+
|
23
|
+
# @return [Fixnum] total number of questions as of the given day/date.
|
24
|
+
attr_reader :questions
|
25
|
+
|
26
|
+
# @return [Fixnum] date, unix epoch time format.
|
27
|
+
attr_reader :timestamp
|
28
|
+
|
29
|
+
# @return [Fixnum] total number of toplevel post as of the given day/date.
|
30
|
+
attr_reader :toplevel
|
31
|
+
|
32
|
+
# @return [Fixnum] total number of users as of the given day/date.
|
33
|
+
attr_reader :users
|
34
|
+
|
35
|
+
# @return [Fixnum] total number of votes as of the given day/date.
|
36
|
+
attr_reader :votes
|
37
|
+
|
38
|
+
def initialize(attributes)
|
39
|
+
attributes.each do |k,v|
|
40
|
+
instance_variable_set "@#{k}", v unless v.nil?
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
# Returns an Array of Post objects for all Posts on the given day/date.
|
45
|
+
#
|
46
|
+
# @return [Array] of Post objects.
|
47
|
+
def all_posts
|
48
|
+
new_posts.collect do |post_id|
|
49
|
+
Biostars::API::Post.find post_id
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Returns an Array of Vote objects for all Votes on the given day/date.
|
54
|
+
#
|
55
|
+
# @return [Array] of Vote objects.
|
56
|
+
def all_votes
|
57
|
+
new_votes.collect do |vote_id|
|
58
|
+
Biostars::API::Vote.find vote_id
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Returns an Array of User objects for all Users on the given day/date.
|
63
|
+
#
|
64
|
+
# @return [Array] of User objects.
|
65
|
+
def all_users
|
66
|
+
new_users.collect do |user_id|
|
67
|
+
Biostars::API::User.find user_id
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
class << self
|
72
|
+
|
73
|
+
# Helper method to look up stats for the prior date.
|
74
|
+
#
|
75
|
+
# @return [Stats] returns a Stats object.
|
76
|
+
def latest
|
77
|
+
find_by_date
|
78
|
+
end
|
79
|
+
|
80
|
+
# Statistics as of the Nth day after day-0 (the day of the first ever post).
|
81
|
+
#
|
82
|
+
# @param day [Date] number of days after day-0, a number.
|
83
|
+
# @return [Stats] returns a Stats object.
|
84
|
+
# @raise [Biostars::StatsError] if the day passed is not a valid Fixnum.
|
85
|
+
def find_by_day(day=Date.today.day)
|
86
|
+
raise Biostars::StatsError, "Expecting a Date Object" unless day.is_a? Fixnum
|
87
|
+
|
88
|
+
find "stats/day/#{day}"
|
89
|
+
end
|
90
|
+
|
91
|
+
# Statistics as of the given date.
|
92
|
+
#
|
93
|
+
# @param date [Date] Date object for specific date.
|
94
|
+
# @return [Stats] returns a Stats object.
|
95
|
+
# @raise [Biostars::StatsError] if the date passed is not a valid Date.
|
96
|
+
def find_by_date(date=Date.today-1)
|
97
|
+
raise Biostars::StatsError unless date.is_a? Date
|
98
|
+
|
99
|
+
url = "stats/date/%s/%s/%s" % [
|
100
|
+
date.year,
|
101
|
+
sprintf('%02d', date.month),
|
102
|
+
sprintf('%02d', date.day),
|
103
|
+
]
|
104
|
+
|
105
|
+
find url
|
106
|
+
end
|
107
|
+
|
108
|
+
private
|
109
|
+
|
110
|
+
# Used to call the main HTTParty get but we also don't want anyone
|
111
|
+
# other that the class methods to call it.
|
112
|
+
def find(url)
|
113
|
+
attributes = Biostars::API.get(url)
|
114
|
+
attributes ? new(attributes) : raise(Biostars::StatsError)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Biostars
|
2
|
+
module API
|
3
|
+
class Traffic
|
4
|
+
|
5
|
+
# @return [String] the current date, ISO 8601 format.
|
6
|
+
attr_reader :date
|
7
|
+
|
8
|
+
# @return [Fixnum] number of post views over the last 60 min filtered by unique IPs.
|
9
|
+
attr_reader :post_views_last_60_min
|
10
|
+
|
11
|
+
# @return [Fixnum] current date unix epoch time format.
|
12
|
+
attr_reader :timestamp
|
13
|
+
|
14
|
+
def initialize(attributes)
|
15
|
+
attributes.each do |k,v|
|
16
|
+
instance_variable_set "@#{k}", v unless v.nil?
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Biostars
|
2
|
+
module API
|
3
|
+
class User
|
4
|
+
# @return [String] the date the user joined the website, as the number of days ago
|
5
|
+
attr_reader :date_joined
|
6
|
+
|
7
|
+
# @return [Fixnum] the identifier of the user
|
8
|
+
attr_reader :id
|
9
|
+
|
10
|
+
# @return [String] the date the user joined the website, ISO 8601 format
|
11
|
+
attr_reader :joined_days_ago
|
12
|
+
|
13
|
+
# @return [String] the date of the last login of the user, ISO 8601 format
|
14
|
+
attr_reader :last_login
|
15
|
+
|
16
|
+
# @return [String] the name of the user.
|
17
|
+
attr_reader :name
|
18
|
+
|
19
|
+
# @return [Fixnum] the number of votes given by the user.
|
20
|
+
attr_reader :vote_count
|
21
|
+
|
22
|
+
def initialize(attributes)
|
23
|
+
attributes.each do |k,v|
|
24
|
+
instance_variable_set "@#{k}", v unless v.nil?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Finds user with the given id.
|
29
|
+
#
|
30
|
+
# @param id [Fixnum] user id.
|
31
|
+
# @return [User] returns User object.
|
32
|
+
# @raise [Biostars::UserError] if User is not found.
|
33
|
+
def self.find(id)
|
34
|
+
attributes = Biostars::API.get "user/#{id}"
|
35
|
+
attributes ? new(attributes) : raise(Biostars::UserError)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Biostars
|
2
|
+
module API
|
3
|
+
class Vote
|
4
|
+
|
5
|
+
# @return [String] author name.
|
6
|
+
attr_reader :author
|
7
|
+
|
8
|
+
# @return [Fixnum] author's identifier, a number.
|
9
|
+
attr_reader :author_id
|
10
|
+
|
11
|
+
# @return [String] date of the vote, ISO 8601 format.
|
12
|
+
attr_reader :date
|
13
|
+
|
14
|
+
# @return [Fixnum] identifier of the vote, a number.
|
15
|
+
attr_reader :id
|
16
|
+
|
17
|
+
# @return [Fixnum] identifier of the voted post.
|
18
|
+
attr_reader :post_id
|
19
|
+
|
20
|
+
# @return [String] type of vote.
|
21
|
+
attr_reader :type
|
22
|
+
|
23
|
+
# @return [Fixnum] type's identifier for this vote.
|
24
|
+
attr_reader :type_id
|
25
|
+
|
26
|
+
def initialize(attributes)
|
27
|
+
attributes.each do |k,v|
|
28
|
+
instance_variable_set "@#{k}", v unless v.nil?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Finds vote with the given id.
|
33
|
+
#
|
34
|
+
# @param id [Fixnum] vote id.
|
35
|
+
# @return [Vote] returns Vote object.
|
36
|
+
# @raise [Biostars::VoteError] if the Vote is not found.
|
37
|
+
def self.find(id)
|
38
|
+
attributes = Biostars::API.get "vote/#{id}"
|
39
|
+
attributes ? new(attributes) : raise(Biostars::VoteError)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,264 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: biostars-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Arian Amador
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.8'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.5'
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 5.5.1
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '5.5'
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 5.5.1
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: minitest-reporters
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - "~>"
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '1.0'
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.0.11
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - "~>"
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.0'
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 1.0.11
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: shoulda-context
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.2'
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.2.1
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.2'
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 1.2.1
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: guard
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '2.12'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.12.4
|
111
|
+
type: :development
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.12'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 2.12.4
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: guard-minitest
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - "~>"
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '2.4'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 2.4.4
|
131
|
+
type: :development
|
132
|
+
prerelease: false
|
133
|
+
version_requirements: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '2.4'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 2.4.4
|
141
|
+
- !ruby/object:Gem::Dependency
|
142
|
+
name: vcr
|
143
|
+
requirement: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - "~>"
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '2.9'
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: 2.9.3
|
151
|
+
type: :development
|
152
|
+
prerelease: false
|
153
|
+
version_requirements: !ruby/object:Gem::Requirement
|
154
|
+
requirements:
|
155
|
+
- - "~>"
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '2.9'
|
158
|
+
- - ">="
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 2.9.3
|
161
|
+
- !ruby/object:Gem::Dependency
|
162
|
+
name: webmock
|
163
|
+
requirement: !ruby/object:Gem::Requirement
|
164
|
+
requirements:
|
165
|
+
- - "~>"
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '1.20'
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: 1.20.4
|
171
|
+
type: :development
|
172
|
+
prerelease: false
|
173
|
+
version_requirements: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - "~>"
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '1.20'
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: 1.20.4
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: httparty
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 0.13.3
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 0.13.3
|
195
|
+
- !ruby/object:Gem::Dependency
|
196
|
+
name: json
|
197
|
+
requirement: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - "~>"
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '1.8'
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 1.8.2
|
205
|
+
type: :runtime
|
206
|
+
prerelease: false
|
207
|
+
version_requirements: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - "~>"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '1.8'
|
212
|
+
- - ">="
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 1.8.2
|
215
|
+
description: Gem wrapping biostars.org public API
|
216
|
+
email:
|
217
|
+
- arian@arianamador.com
|
218
|
+
executables: []
|
219
|
+
extensions: []
|
220
|
+
extra_rdoc_files: []
|
221
|
+
files:
|
222
|
+
- ".gitignore"
|
223
|
+
- ".travis.yml"
|
224
|
+
- Gemfile
|
225
|
+
- LICENSE.txt
|
226
|
+
- README.md
|
227
|
+
- Rakefile
|
228
|
+
- bin/console
|
229
|
+
- bin/setup
|
230
|
+
- biostars-api.gemspec
|
231
|
+
- lib/biostars/api.rb
|
232
|
+
- lib/biostars/api/exceptions.rb
|
233
|
+
- lib/biostars/api/post.rb
|
234
|
+
- lib/biostars/api/stats.rb
|
235
|
+
- lib/biostars/api/traffic.rb
|
236
|
+
- lib/biostars/api/user.rb
|
237
|
+
- lib/biostars/api/version.rb
|
238
|
+
- lib/biostars/api/vote.rb
|
239
|
+
homepage: https://www.github.com/arian-amador/biostars-api
|
240
|
+
licenses:
|
241
|
+
- MIT
|
242
|
+
metadata: {}
|
243
|
+
post_install_message:
|
244
|
+
rdoc_options: []
|
245
|
+
require_paths:
|
246
|
+
- lib
|
247
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
253
|
+
requirements:
|
254
|
+
- - ">="
|
255
|
+
- !ruby/object:Gem::Version
|
256
|
+
version: '0'
|
257
|
+
requirements: []
|
258
|
+
rubyforge_project:
|
259
|
+
rubygems_version: 2.4.1
|
260
|
+
signing_key:
|
261
|
+
specification_version: 4
|
262
|
+
summary: Gem wrapping biostars.org public API
|
263
|
+
test_files: []
|
264
|
+
has_rdoc:
|