biostars-api 0.1.3 → 0.1.4
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 +7 -3
- data/biostars-api.gemspec +2 -12
- data/lib/biostars/api/post.rb +2 -0
- data/lib/biostars/api/stats.rb +41 -43
- data/lib/biostars/api/traffic.rb +1 -0
- data/lib/biostars/api/user.rb +1 -0
- data/lib/biostars/api/version.rb +2 -2
- data/lib/biostars/api/vote.rb +1 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96fd9ae3ed4771bfcb5a241ca3d5c0b028bcdc88
|
4
|
+
data.tar.gz: fe29a2a1668be06a183b5e699c14a02c975d8028
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0955537219b6efa2c53d736e5caffc5e961103b55ddcc464554de57ea7aa966930f32b1cfb591dc8eb4785e550b7ca06e742c80a86fa0272ec050e99d931854b
|
7
|
+
data.tar.gz: a699bfd2619354db49871556e1eaf6855c8848839d4238661101ef6ed28f28847b120ae60a7a9474f7f3a464c6632d7a7b9b627cd0d400a875ec173f21468d76
|
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
#
|
1
|
+
# biostars-api
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/biostars-api) [](https://travis-ci.org/arian-amador/biostars-api) [](https://inch-ci.org/github/arian-amador/biostars-api)
|
4
|
+
|
5
|
+
A wrapper for the [biostars.org](https://www.biostars.org/) public API.
|
6
|
+
|
7
|
+
Biostars focuses on bioinformatics, computational genomics and biological data analysis.
|
4
8
|
|
5
9
|
## Requirements
|
6
10
|
* httparty
|
@@ -50,7 +54,7 @@ latest_votes = latest_info.all_votes
|
|
50
54
|
## Documentation
|
51
55
|
|
52
56
|
* API - https://www.biostars.org/info/api/
|
53
|
-
* Rubydoc - http://www.rubydoc.info/github/arian-amador/biostars-api/
|
57
|
+
* Rubydoc - http://www.rubydoc.info/github/arian-amador/biostars-api/master
|
54
58
|
|
55
59
|
## Contributing
|
56
60
|
|
data/biostars-api.gemspec
CHANGED
@@ -1,30 +1,20 @@
|
|
1
1
|
# coding: utf-8
|
2
|
-
|
3
|
-
require 'biostars/api/version'
|
2
|
+
require File.expand_path('../lib/biostars/api/version', __FILE__)
|
4
3
|
|
5
4
|
Gem::Specification.new do |spec|
|
6
5
|
spec.name = "biostars-api"
|
7
6
|
spec.version = Biostars::API::VERSION
|
8
7
|
spec.authors = ["Arian Amador"]
|
9
8
|
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
9
|
spec.summary = %q{Gem wrapping biostars.org public API}
|
16
|
-
spec.description =
|
10
|
+
spec.description = spec.description
|
17
11
|
spec.homepage = "https://www.github.com/arian-amador/biostars-api"
|
18
12
|
spec.license = "MIT"
|
19
|
-
|
20
13
|
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
14
|
spec.require_paths = ["lib"]
|
24
15
|
|
25
16
|
spec.add_development_dependency 'bundler', '~> 1.7', '>= 1.7.9'
|
26
17
|
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
-
|
28
18
|
spec.add_development_dependency 'minitest', '~> 5.5', '>= 5.5.1'
|
29
19
|
spec.add_development_dependency 'minitest-reporters', '~> 1.0', '>= 1.0.11'
|
30
20
|
spec.add_development_dependency "shoulda-context", '~> 1.2', '>= 1.2.1'
|
data/lib/biostars/api/post.rb
CHANGED
data/lib/biostars/api/stats.rb
CHANGED
@@ -39,6 +39,7 @@ module Biostars
|
|
39
39
|
# @return [Fixnum] total number of votes as of the given day/date.
|
40
40
|
attr_reader :votes
|
41
41
|
|
42
|
+
# Instantiate the Biostars::API::Stats.
|
42
43
|
def initialize(attributes)
|
43
44
|
attributes.each do |k,v|
|
44
45
|
instance_variable_set "@#{k}", v unless v.nil?
|
@@ -72,54 +73,51 @@ module Biostars
|
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
find_by_date
|
82
|
-
end
|
76
|
+
# Helper method to look up stats for the prior date.
|
77
|
+
#
|
78
|
+
# @return [Stats] returns a Stats object.
|
79
|
+
def self.latest
|
80
|
+
find_by_date
|
81
|
+
end
|
83
82
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
83
|
+
# Statistics as of the Nth day after day-0 (the day of the first ever post).
|
84
|
+
#
|
85
|
+
# @param day [Date] number of days after day-0, a number.
|
86
|
+
# @return [Stats] returns a Stats object.
|
87
|
+
# @raise [Biostars::StatsError] if the day passed is not a valid Fixnum.
|
88
|
+
def self.find_by_day(day=Date.today.day)
|
89
|
+
raise Biostars::StatsError, "Expecting a Date Object" unless day.is_a? Fixnum
|
91
90
|
|
92
|
-
|
93
|
-
|
91
|
+
find "stats/day/#{day}"
|
92
|
+
end
|
94
93
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
94
|
+
# Statistics as of the given date.
|
95
|
+
#
|
96
|
+
# @param year [Fixnum] year to search for
|
97
|
+
# @param month [Fixnum] month to search for
|
98
|
+
# @param day [Fixnum] day to search for
|
99
|
+
# @return [Stats] returns a Stats object.
|
100
|
+
# @raise [Biostars::StatsError] if the variables passed are not valid Fixnum
|
101
|
+
def self.find_by_date(year=Date.today.year, month=Date.today.month, day=(Date.today.day-1))
|
102
|
+
raise Biostars::StatsError unless year.is_a?(Fixnum) || month.is_a?(Fixnum) || day.is_a?(Fixnum)
|
103
|
+
|
104
|
+
url = "stats/date/%s/%s/%s" % [
|
105
|
+
year,
|
106
|
+
sprintf('%02d', month),
|
107
|
+
sprintf('%02d', day),
|
108
|
+
]
|
109
|
+
|
110
|
+
find url
|
111
|
+
end
|
113
112
|
|
114
|
-
|
113
|
+
private
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
end
|
115
|
+
# Used to call the main HTTParty get but we also don't want anyone
|
116
|
+
# other that the class methods to call it.
|
117
|
+
def self.find(url)
|
118
|
+
attributes = Biostars::API.get(url)
|
119
|
+
attributes ? new(attributes) : raise(Biostars::StatsError)
|
120
|
+
end
|
123
121
|
end
|
124
122
|
end
|
125
123
|
end
|
data/lib/biostars/api/traffic.rb
CHANGED
data/lib/biostars/api/user.rb
CHANGED
data/lib/biostars/api/version.rb
CHANGED
data/lib/biostars/api/vote.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biostars-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arian Amador
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -218,7 +218,7 @@ dependencies:
|
|
218
218
|
- - ">="
|
219
219
|
- !ruby/object:Gem::Version
|
220
220
|
version: 1.8.2
|
221
|
-
description:
|
221
|
+
description: ''
|
222
222
|
email:
|
223
223
|
- arian@arianamador.com
|
224
224
|
executables: []
|