lagotto-rb 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 741d5b5d9a7455609a53899fc11c53fd9d2cb19a
4
+ data.tar.gz: bad416508c0bb9a40d4f3f74f97335ea85fe99ec
5
+ SHA512:
6
+ metadata.gz: ce8e05acddca135c66514c88761517c0ddd4a1b194037fa2508c46673cb35932245309673d6214026b3a0e6ffed380d05202af82166f04a24de2fdf16fac9ed4
7
+ data.tar.gz: c60777def8b6d4ee7a2946ef3f3759416126e4d101bdd77500a55a19b2647e8e18e45734e5e1bb548031249b2201c3e37f1806d3336b9ca004a3e0250cd729ff
data/.gitignore ADDED
@@ -0,0 +1,38 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /test/tmp/
9
+ /test/version_tmp/
10
+ /tmp/
11
+
12
+ ## Specific to RubyMotion:
13
+ .dat*
14
+ .repl_history
15
+ build/
16
+
17
+ ## Documentation cache and generated files:
18
+ /.yardoc/
19
+ /_yardoc/
20
+ /doc/
21
+ /rdoc/
22
+
23
+ ## Environment normalisation:
24
+ /.bundle/
25
+ /lib/bundler/man/
26
+
27
+ # for a library or gem, you might want to ignore these files since the code is
28
+ # intended to run in multiple environments; otherwise, check them in:
29
+ #Gemfile.lock
30
+ .ruby-version
31
+ .ruby-gemset
32
+
33
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
34
+ .rvmrc
35
+
36
+ cache/
37
+
38
+ lib/serrano/response.rb
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.7
4
+ - 2.2.3
data/CHANGELOG.md ADDED
@@ -0,0 +1,3 @@
1
+ ## 0.2.0 (2016-01-08)
2
+
3
+ + First version to Rubygems
data/CONDUCT.md ADDED
@@ -0,0 +1,25 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who
4
+ contribute through reporting issues, posting feature requests, updating documentation,
5
+ submitting pull requests or patches, and other activities.
6
+
7
+ We are committed to making participation in this project a harassment-free experience for
8
+ everyone, regardless of level of experience, gender, gender identity and expression,
9
+ sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
10
+
11
+ Examples of unacceptable behavior by participants include the use of sexual language or
12
+ imagery, derogatory comments or personal attacks, trolling, public or private harassment,
13
+ insults, or other unprofessional conduct.
14
+
15
+ Project maintainers have the right and responsibility to remove, edit, or reject comments,
16
+ commits, code, wiki edits, issues, and other contributions that are not aligned to this
17
+ Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
18
+ from the project team.
19
+
20
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
21
+ opening an issue or contacting one or more of the project maintainers.
22
+
23
+ This Code of Conduct is adapted from the Contributor Covenant
24
+ (http:contributor-covenant.org), version 1.0.0, available at
25
+ http://contributor-covenant.org/version/1/0/0/
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,53 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lagotto-rb (0.1.3.9000)
5
+ faraday (~> 0.9.1)
6
+ faraday_middleware (~> 0.10.0)
7
+ launchy (~> 2.4, >= 2.4.2)
8
+ multi_json (~> 1.0)
9
+ thor (~> 0.18)
10
+
11
+ GEM
12
+ remote: https://rubygems.org/
13
+ specs:
14
+ addressable (2.3.8)
15
+ codecov (0.1.1)
16
+ json
17
+ simplecov
18
+ url
19
+ docile (1.1.5)
20
+ faraday (0.9.2)
21
+ multipart-post (>= 1.2, < 3)
22
+ faraday_middleware (0.10.0)
23
+ faraday (>= 0.7.4, < 0.10)
24
+ json (1.8.3)
25
+ launchy (2.4.3)
26
+ addressable (~> 2.3)
27
+ multi_json (1.11.2)
28
+ multipart-post (2.0.0)
29
+ power_assert (0.2.4)
30
+ rake (0.9.6)
31
+ simplecov (0.10.0)
32
+ docile (~> 1.1.0)
33
+ json (~> 1.8)
34
+ simplecov-html (~> 0.10.0)
35
+ simplecov-html (0.10.0)
36
+ test-unit (3.1.3)
37
+ power_assert
38
+ thor (0.19.1)
39
+ url (0.3.2)
40
+
41
+ PLATFORMS
42
+ ruby
43
+
44
+ DEPENDENCIES
45
+ bundler (~> 1.6)
46
+ codecov (~> 0.1)
47
+ lagotto-rb!
48
+ rake (~> 0)
49
+ simplecov (~> 0.10)
50
+ test-unit (~> 3.1)
51
+
52
+ BUNDLED WITH
53
+ 1.10.6
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (C) 2016 Scott Chamberlain
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,136 @@
1
+ lagotto-rb
2
+ ==========
3
+
4
+ [![Build Status](https://api.travis-ci.org/lagotto/lagotto-rb.png)](https://travis-ci.org/lagotto/lagotto-rb)
5
+ [![gem version](https://img.shields.io/gem/v/lagotto-rb.svg)](https://rubygems.org/gems/lagotto-rb)
6
+ [![codecov.io](http://codecov.io/github/lagotto/lagotto-rb/coverage.svg?branch=master)](http://codecov.io/github/lagotto/lagotto-rb?branch=master)
7
+
8
+ A Ruby client for the Lagotto application for article level metrics data
9
+
10
+ __This is alpha software, so expect changes__
11
+
12
+ Other Lagotto clients:
13
+
14
+ * R - [alm](https://github.com/ropensci/alm)
15
+ * Python - [pyalm](https://github.com/lagotto/pyalm)
16
+
17
+ ## Changes
18
+
19
+ For changes see the [Changelog][changelog]
20
+
21
+ ## API
22
+
23
+ Methods in relation to [Lagotto API][lapi] routes
24
+
25
+ * `/works` - `Lagotto.works()`
26
+ * `/works_sources` - `Lagotto.works_sources()`
27
+ * `/events` - `Lagotto.events()`
28
+ * `/publishers` - `Lagotto.publishers()`
29
+ * `/groups` - `Lagotto.groups()`
30
+ * `/references` - `Lagotto.references()`
31
+ * `/work_types` - `Lagotto.work_types()`
32
+ * `/docs` - `Lagotto.docs()`
33
+ * `/relation_types` - `Lagotto.relation_types()`
34
+ * `/sources` - `Lagotto.sources()`
35
+ * `/recommendations` - `Lagotto.recommendations()`
36
+ * `/status` - `Lagotto.status()`
37
+
38
+ ## Install
39
+
40
+ ### Release version
41
+
42
+ ```
43
+ gem install lagotto-rb
44
+ ```
45
+
46
+ ### Development version
47
+
48
+ Install dependencies
49
+
50
+ ```
51
+ git clone git@github.com:sckott/serrano.git
52
+ cd serrano
53
+ rake install
54
+ ```
55
+
56
+ ### In Ruby repl
57
+
58
+ Get altmetrics by DOI
59
+
60
+ ```ruby
61
+ Lagotto.works(ids: 'http://doi.org/10.15468/DL.SQNY5P', instance: "crossref")
62
+ ```
63
+
64
+ Search for altmetrics by source
65
+
66
+ ```ruby
67
+ Lagotto.works(source: 'twitter', instance: "crossref")
68
+ ```
69
+
70
+ Make a `/works` route request by source
71
+
72
+ ```ruby
73
+ Lagotto.works_sources(source: 'twitter', per_page: 2)
74
+ ```
75
+
76
+ Make a `/events` route request
77
+
78
+ ```ruby
79
+ Lagotto.events(ids: '10.1371/journal.pone.0029797', instance: "crossref")
80
+ ```
81
+
82
+ Make a `/publishers` route request
83
+
84
+ ```ruby
85
+ Lagotto.publishers(id: 340)
86
+ ```
87
+
88
+ Make a `/groups` route request
89
+
90
+ ```ruby
91
+ Lagotto.groups()
92
+ ```
93
+
94
+ Make a `/references` route request
95
+
96
+ ```ruby
97
+ Lagotto.references(per_page: 5, instance: 'crossref')
98
+ ```
99
+
100
+ ### On the CLI
101
+
102
+ ```
103
+ ~$ lagotto
104
+ Commands:
105
+ lagotto help [COMMAND] # Describe available commands or one specific command
106
+ lagotto version # Get lagotto-rb version
107
+ lagotto works [ids] # Get works by ids
108
+ ```
109
+
110
+ ```
111
+ # A single id
112
+ ~$ lagotto works http://doi.org/10.1371/journal.pone.0025110
113
+
114
+ DOI: 10.1371/journal.pone.0033693
115
+ type: journal-article
116
+ title: Methylphenidate Exposure Induces Dopamine Neuron Loss and Activation of Microglia in the Basal Ganglia of Mice
117
+
118
+ # JSON output
119
+ ~$ lagotto works --limit=2 --json
120
+
121
+ {"meta":{"status":"ok","message-type":"work-list", ...
122
+
123
+ # JSON output, parse with jq
124
+ ~$ lagotto works --limit=2 --json | jq .works[].DOI
125
+
126
+ "10.1371/journal.pgen.1005692"
127
+ "10.1371/journal.pgen.1005425"
128
+ ```
129
+
130
+ ## Meta
131
+
132
+ * Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
133
+ * License: MIT
134
+
135
+ [lapi]: http://alm.plos.org/docs/api
136
+ [changelog]: https://github.com/lagotto/lagotto-rb/blob/master/CHANGELOG.md
data/Rakefile ADDED
@@ -0,0 +1,41 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "test"
6
+ t.test_files = FileList['test/test*.rb']
7
+ t.verbose = true
8
+ end
9
+
10
+ desc "Run tests"
11
+ task :default => :test
12
+
13
+ desc "Build lagotto-rb docs"
14
+ task :docs do
15
+ system "yardoc"
16
+ end
17
+
18
+ desc "bundle install"
19
+ task :b do
20
+ system "bundle install"
21
+ end
22
+
23
+ desc "clean out builds"
24
+ task :clean do
25
+ system "ls | grep [0-9].gem | xargs rm"
26
+ end
27
+
28
+ desc "Build lagotto-rb"
29
+ task :build do
30
+ system "gem build lagotto-rb.gemspec"
31
+ end
32
+
33
+ desc "Install lagotto-rb"
34
+ task :install => :build do
35
+ system "gem install lagotto-rb-#{Lagotto::VERSION}.gem"
36
+ end
37
+
38
+ desc "Release to Rubygems"
39
+ task :release => :build do
40
+ system "gem push lagotto-rb-#{Lagotto::VERSION}.gem"
41
+ end
data/bin/lagotto ADDED
@@ -0,0 +1,91 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "thor"
4
+ require "lagotto-rb"
5
+ require "multi_json"
6
+
7
+ class Lg < Thor
8
+ include Thor::Actions
9
+ # class_option :json, :type => :boolean, :default => false
10
+
11
+ desc "works [ids]", "Get works by ids"
12
+ long_desc <<-LONGDESC
13
+ `lagotto works` accepts one or more ids to search for works
14
+
15
+ Toggle `json` to get simplified (summary) or complete output (JSON)
16
+
17
+ # A single id
18
+ \x5$ lagotto works http://doi.org/10.1371/journal.pone.0025110
19
+
20
+ DOI: 10.1371/journal.pone.0033693
21
+ \x5type: journal-article
22
+ \x5title: Methylphenidate Exposure Induces Dopamine Neuron Loss and Activation of Microglia in the Basal Ganglia of Mice
23
+
24
+ # No ids
25
+ \x5$ lagotto works --limit=2
26
+
27
+ DOI: 10.1371/journal.pone.0146052
28
+ \x5id: http://doi.org/10.1371/journal.pone.0146052
29
+ \x5title: What Do We Learn from Spheroid Culture Systems? Insights from Tumorspheres Derived from Primary Colon Cancer Tissue
30
+
31
+ DOI: 10.1371/journal.pone.0145401
32
+ \x5id: http://doi.org/10.1371/journal.pone.0145401
33
+ \x5title: Social Factors Influencing Child Health in Ghana
34
+
35
+ # JSON output
36
+ \x5$ lagotto works --limit=2 --json
37
+
38
+ {"meta":{"status":"ok","message-type":"work-list", ...
39
+
40
+ # JSON output, parse with jq
41
+ \x5$ lagotto works --limit=2 --json | jq .works[].DOI
42
+
43
+ "10.1371/journal.pgen.1005692"
44
+ \x5"10.1371/journal.pgen.1005425"
45
+ LONGDESC
46
+ option :limit, :type => :numeric, :default => 50
47
+ option :json, :type => :boolean, :default => false
48
+ def works(ids = nil)
49
+ puts ids
50
+ out = Lagotto.works(ids: ids, per_page: options[:limit])
51
+ if !options[:json]
52
+ if ids.nil?
53
+ out = out['works'].collect { |x| x.select { |k,v| k[/DOI|id|^title$/] } }
54
+ else
55
+ out = [out['works'][0].select { |k,v| k[/DOI|id|^title$/] }]
56
+ end
57
+ out.each do |x|
58
+ puts 'DOI: ' + x['DOI'].to_s
59
+ puts 'id: ' + x['id']
60
+ puts 'title: ' + x['title']
61
+ puts
62
+ end
63
+ else
64
+ puts MultiJson.encode(out)
65
+ end
66
+ end
67
+
68
+ desc "version", "Get lagotto-rb version"
69
+ def version
70
+ puts Lagotto::VERSION
71
+ end
72
+
73
+ private
74
+
75
+ def print_works(data)
76
+ if data.is_a? Array
77
+ data = data[0]['message']['items']
78
+ else
79
+ data = data.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
80
+ end
81
+ data.each do |x|
82
+ puts 'DOI: ' + x['DOI']
83
+ puts 'type: ' + x['type']
84
+ puts 'title: ' + x['title'][0]
85
+ puts
86
+ end
87
+ end
88
+
89
+ end
90
+
91
+ Lg.start(ARGV)
@@ -0,0 +1,25 @@
1
+ require 'alm'
2
+
3
+ # Get alerts data from a Lagotto instance
4
+ Lagotto.alerts(user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
5
+ Lagotto.alerts(user: ENV["CROSSREF_ALERTS_USER"], pwd: ENV["CROSSREF_ALERTS_PWD"], instance: "crossref")
6
+ Lagotto.alerts(user: ENV["PKP_ALERTS_USER"], pwd: ENV["PKP_ALERTS_PWD"], instance: "pkp")
7
+
8
+ # Query for alerts
9
+ Lagotto.alerts(q: 'timed', user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
10
+
11
+ # Filter to those unresolved
12
+ Lagotto.alerts(unresolved: true, user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
13
+
14
+ # Filter by alert class name
15
+ Lagotto.alerts(class_name: 'EventCountIncreasingTooFastError', user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
16
+
17
+ # Get alerts by DOI
18
+ Lagotto.alerts(ids: "10.1371/journal.pone.0029797", user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
19
+
20
+ # Paging
21
+ Lagotto.alerts(per_page: 2, user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
22
+ Lagotto.alerts(per_page: 2, page: 2, user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])
23
+
24
+ # Filter by alert level (of severity)
25
+ Lagotto.alerts(level: "error", user: ENV["PLOS_ALERTS_USER"], pwd: ENV["PLOS_ALERTS_PWD"])