paper_summary 0.0.1

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
+ !binary "U0hBMQ==":
3
+ metadata.gz: e29dde93f78030ecd160e079d036fb5ebcd0ade5
4
+ data.tar.gz: 3a477844e8786573203684e071962c27610151ec
5
+ !binary "U0hBNTEy":
6
+ metadata.gz: e124162bb51ccff184cba284df95f34d1269eace18b7dd6c0be7f80b58d973ae042bfd881a52a094066994a40e11a3a5575fa6f554517a17db77a5e5be90b1ef
7
+ data.tar.gz: 6a00be595abe1997016c988d975e68c8fa700d738efc2a11c9244904ba43afb47f72b35c8f8f725be133d5f7b512e9138d488eea6c2b5941ac7c210cb808eabd
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.sublime-project
19
+ *.sublime-workspace
20
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in paper_metadata.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jure Triglav
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,45 @@
1
+ # PaperMetadata
2
+
3
+ PaperMetadata is a gem that gets a publication's metadata by accessing the CrossRef OpenURL API.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'paper_metadata'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install paper_metadata
18
+
19
+ ## Usage
20
+
21
+ You can use PaperMetadata like this:
22
+
23
+ result = PaperMetadata.metadata_for('doi:10.1021/ac1014832')
24
+
25
+ The result will be a hash similar to this one:
26
+
27
+ { :volume=>"82",
28
+ :isssue=>"19",
29
+ :first_page=>"8153",
30
+ :last_page=>"8160",
31
+ :title=>
32
+ "Basic Modeling Approach To Optimize Elemental Imaging by Laser Ablation ICPMS",
33
+ :authors=>"Jure Triglav, Johannes T. van Elteren, Vid S. Šelih",
34
+ :journal=>"Anal. Chem. 2010",
35
+ :resource=>"http://pubs.acs.org/doi/abs/10.1021/ac1014832" }
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create new Pull Request
44
+
45
+ Be sure to run the specs too.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+
5
+ Rake::TestTask.new do |t|
6
+ t.libs << 'test'
7
+ end
8
+
9
+ desc "Run tests"
10
+ task :default => :test
@@ -0,0 +1,3 @@
1
+ module PaperSummary
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,48 @@
1
+ require 'paper_summary/version'
2
+ require 'nokogiri'
3
+ require 'net/http'
4
+ require 'open-uri'
5
+ require 'cgi'
6
+ require 'uri'
7
+ require 'json'
8
+ require 'pry'
9
+
10
+ module PaperSummary
11
+ class << self
12
+
13
+ def summary_for(identifier)
14
+ if identifier =~ /^arxiv\:(.*)/i
15
+ nil # summary_for_arxiv($1.strip)
16
+ elsif identifier =~ /^doi\:\s*(10\.7554\/.*)/i
17
+ summary_for_elife($1.strip)
18
+ elsif identifier =~ /^doi\:(.*)/i
19
+ nil
20
+ end
21
+ end
22
+
23
+ def summary_for_elife(doi)
24
+ fluiddb = JSON.parse(open("http://fluiddb.fluidinfo.com/values?query=elifesciences.org/api_v1/article/doi=%22#{doi}%22&tag=*").read)
25
+
26
+ # Get the DOI url
27
+ doi = fluiddb['results']['id'].values.first['fluiddb/about']['value'].match(/doi\.org\/(.*)/)[1]
28
+
29
+ # Get the eLife url
30
+ url = URI.parse('http://dx.doi.org')
31
+ res = Net::HTTP.start(url.host, url.port) {|http|
32
+ http.get("/#{doi}")
33
+ }
34
+ url = URI.parse(res['location'])
35
+ res = Net::HTTP.start(url.host, url.port) {|http|
36
+ http.get(url.path)
37
+ }
38
+ elife_xml_url = res['location'] + '.source.xml'
39
+
40
+ # Get the eLife paper XML
41
+ xml = Nokogiri::XML(open(elife_xml_url)).css('abstract[abstract-type="executive-summary"] p')
42
+ summary = {}
43
+ summary[:summary_html] = xml.to_html
44
+ summary[:summary_text] = xml.text
45
+ summary
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'paper_summary/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "paper_summary"
8
+ gem.version = PaperSummary::VERSION
9
+ gem.authors = ["Jure Triglav"]
10
+ gem.email = ["juretriglav@gmail.com"]
11
+ gem.summary = %q{Paper_summary gem gets the summary for papers with a DOI or an arXiv identifier}
12
+ gem.description = %q{Summary getter for scientific papers}
13
+ gem.homepage = "http://github.com/jure/paper_summary"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_development_dependency "pry"
21
+ # Tests
22
+ gem.add_development_dependency "rake"
23
+ gem.add_development_dependency "webmock"
24
+ gem.add_runtime_dependency "nokogiri", ["= 1.5.6"]
25
+ end
data/test/dx_doi.raw ADDED
@@ -0,0 +1,12 @@
1
+ HTTP/1.1 303 See Other
2
+ Server: Apache-Coyote/1.1
3
+ Vary: Accept
4
+ Location: http://elife.elifesciences.org/lookup/doi/10.7554/eLife.00013
5
+ Expires: Thu, 25 Jul 2013 09:30:47 GMT
6
+ Content-Type: text/html;charset=utf-8
7
+ Content-Length: 208
8
+ Date: Wed, 24 Jul 2013 10:24:44 GMT
9
+
10
+
11
+ <HTML><HEAD><TITLE>Handle Redirect</TITLE></HEAD>
12
+ <BODY><A HREF="http://elife.elifesciences.org/lookup/doi/10.7554/eLife.00013">http://elife.elifesciences.org/lookup/doi/10.7554/eLife.00013</A></BODY></HTML>