arxiv-references 0.1.5 → 0.1.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 225161a6b0503ca774a846ad804eb205144d6c5a
4
- data.tar.gz: c48bee9f466545bc878471e022bce09e936a0b05
3
+ metadata.gz: daa78fd2737bd135435527f1534ced7910016f66
4
+ data.tar.gz: 9d5bc8e4f8046160ff32135b450191a11e44c833
5
5
  SHA512:
6
- metadata.gz: ee917aeaf67117fa8a9041574262e4c939908dd95a362c5530ca86c97400d4776c329b12e8f0c7ca1c1c62ed9ce56feaccfea2e95d032d8af0f4e1b2f3e739d8
7
- data.tar.gz: 7e20169f3ed005131be57a33d3e4563a430121f553974b3e2dc4e5241b071200c6da8cfb4ecdfba7108b943b03e9a1ab926ed51a53105f2dca29c19b046ea0bc
6
+ metadata.gz: 30c204729334a420e27e2f0b5111bb00c46ccf5a3da26cc12736b8a65f109290e3cd6ca855f54c170d41578ab11a2373a03d1e7139f426b24d249a9f00ba99ed
7
+ data.tar.gz: 25e3705840d15c2e78efd358aa1680c50807f5af3ed09402d0f915acd4286631adadd820cdec89e932fa69602b3d4fbad65ce81603754575acfaf68f54f5a09e
data/Gemfile CHANGED
@@ -2,4 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in arxiv-references.gemspec
4
4
  gemspec
5
-
data/README.md CHANGED
@@ -1,3 +1,7 @@
1
+ [![Gem Version](https://badge.fury.io/rb/arxiv-references.svg)](https://badge.fury.io/rb/arxiv-references)
2
+ [![LICENSES](https://img.shields.io/badge/LICENSE-GPL-blue.svg)](https://img.shields.io/badge/LICENSE-GPL-blue.svg)
3
+ [![Code Climate](https://codeclimate.com/github/nishimuuu/Arxiv-references/badges/gpa.svg)](https://codeclimate.com/github/nishimuuu/Arxiv-references)
4
+ [![Test Coverage](https://codeclimate.com/github/nishimuuu/Arxiv-references/badges/coverage.svg)](https://codeclimate.com/github/nishimuuu/Arxiv-references/coverage)
1
5
  # Arxiv::References
2
6
 
3
7
  Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/arxiv/references`. To experiment with that code, run `bin/console` for an interactive prompt.
@@ -1,3 +1,8 @@
1
+
2
+ require 'pathname'
3
+ lib = Pathname.new(__FILE__).dirname.join().expand_path.to_s
4
+ $:.unshift lib
5
+
1
6
  require "references/version"
2
7
  require 'references/myUtil'
3
8
  require 'references/ArxivReferences'
@@ -55,20 +55,19 @@ module ArxivUtil
55
55
  fetchFromUrl(target_url, work_dir)
56
56
  end
57
57
 
58
- def self.fetchFromPdfUrl(pdfUrl, work_dir)
59
- job_id = makeId
60
- makeDir(job_id, work_dir)
61
- file_name = makeFile(job_id, work_dir)
62
-
58
+ def self.fetchPdfFile(pdfUrl,file_name)
63
59
  open(file_name, 'wb') do |o|
64
60
  open(pdfUrl) do |data|
65
61
  o.write(data.read)
66
62
  end
67
63
  end
64
+ end
65
+
66
+ def self.convertSingleColPdf(job_id, work_dir,file_name)
68
67
  cmd = "k2pdfopt -dev kpw #{file_name}"
69
68
  PTY.spawn(cmd) do |i,o|
70
69
  o.sync = true
71
- i.expect(/\S.*Enter option above \(h=help, q=quit\):/,10){|line|
70
+ i.expect(/\S.*Enter option above \(h=help, q=quit\):/,10){
72
71
  o.puts "\n"
73
72
  o.flush
74
73
  }
@@ -78,8 +77,11 @@ module ArxivUtil
78
77
  break unless res.index('written').nil?
79
78
  end
80
79
  end
81
- executed_pdf = getK2Pdf(job_id, work_dir)
82
- reader = PDF::Reader.new(executed_pdf)
80
+ return getK2Pdf(job_id, work_dir)
81
+ end
82
+
83
+ def self.fetchReference(file_name)
84
+ reader = PDF::Reader.new(file_name)
83
85
  page_no = reader.
84
86
  pages.
85
87
  reject{|i|
@@ -102,10 +104,20 @@ module ArxivUtil
102
104
  gsub('- ','').
103
105
  split("\n")
104
106
 
105
- references = ref_page[(ref_page.index{|i| i =~ REFERENCE_START_REGEXP}+1)..ref_page.length].
107
+ return ref_page[(ref_page.index{|i| i =~ REFERENCE_START_REGEXP}+1)..ref_page.length].
106
108
  select{|i|
107
109
  i.length > 5
108
110
  }
111
+ end
112
+
113
+ def self.fetchFromPdfUrl(pdfUrl, work_dir)
114
+ job_id = makeId
115
+ makeDir(job_id, work_dir)
116
+ file_name = makeFile(job_id, work_dir)
117
+
118
+ fetchPdfFile(pdfUrl, file_name)
119
+ executed_pdf = convertSingleColPdf(job_id, work_dir, file_name)
120
+ references = fetchReference(executed_pdf)
109
121
  removeDir(job_id, work_dir)
110
122
  return references
111
123
  end
@@ -1,5 +1,5 @@
1
1
  module Arxiv
2
2
  module References
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.5.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arxiv-references
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takahiro Nishimura
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-05-02 00:00:00.000000000 Z
11
+ date: 2016-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler