ar_xiv 0.0.3

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27a232008d4bf3b8008a227d0d624dd98b6cd6ee
4
+ data.tar.gz: cd6fa827a2fa8e9f85a63850b89709fad1e4dd2d
5
+ SHA512:
6
+ metadata.gz: 3ef15b949d1dac7bf6db81182910d2078f685f33859f9da09cd8dbd50303ab1148596de0e040859bfa05cc712cfeb549bf790c815826de58f346ddf623de6b15
7
+ data.tar.gz: ff39db5ca4aaf11ddd5827911e989831b4538b54347a2b410302faf1f4743284efb1a6e4a87407d9977d47cd067f1c3720bc51e156e67ee2e219a18c1321040a
@@ -0,0 +1,17 @@
1
+ # http://editorconfig.org
2
+
3
+ root = true
4
+
5
+ [*]
6
+ charset = utf-8
7
+ indent_style = space
8
+ indent_size = 2
9
+ end_of_line = crlf
10
+ insert_final_newline = true
11
+ trim_trailing_whitespace = true
12
+
13
+ [*.md]
14
+ insert_final_newline = false
15
+ trim_trailing_whitespace = false
16
+
17
+
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /notes
11
+ sample
12
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in arxiv_reader.gemspec
4
+
5
+ gemspec
6
+
7
+ gem "wdm", ">=0.1.0" if Gem.win_platform?
@@ -0,0 +1,77 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features)
6
+
7
+ ## Uncomment to clear the screen before every task
8
+ # clearing :on
9
+
10
+ ## Guard internally checks for changes in the Guardfile and exits.
11
+ ## If you want Guard to automatically start up again, run guard in a
12
+ ## shell loop, e.g.:
13
+ ##
14
+ ## $ while bundle exec guard; do echo "Restarting Guard..."; done
15
+ ##
16
+ ## Note: if you are using the `directories` clause above and you are not
17
+ ## watching the project directory ('.'), then you will want to move
18
+ ## the Guardfile to a watched dir and symlink it back, e.g.
19
+ #
20
+ # $ mkdir config
21
+ # $ mv Guardfile config/
22
+ # $ ln -s config/Guardfile .
23
+ #
24
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
25
+
26
+ # Note: The cmd option is now required due to the increasing number of ways
27
+ # rspec may be run, below are examples of the most common uses.
28
+ # * bundler: 'bundle exec rspec'
29
+ # * bundler binstubs: 'bin/rspec'
30
+ # * spring: 'bin/rspec' (This will use spring if running and you have
31
+ # installed the spring binstubs per the docs)
32
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
33
+ # * 'just' rspec: 'rspec'
34
+
35
+ guard :rspec, cmd: "bundle exec rspec" do
36
+ require "guard/rspec/dsl"
37
+ dsl = Guard::RSpec::Dsl.new(self)
38
+
39
+ # Feel free to open issues for suggestions and improvements
40
+
41
+ # RSpec files
42
+ rspec = dsl.rspec
43
+ watch(rspec.spec_helper) { rspec.spec_dir }
44
+ watch(rspec.spec_support) { rspec.spec_dir }
45
+ watch(rspec.spec_files)
46
+
47
+ # Ruby files
48
+ ruby = dsl.ruby
49
+ dsl.watch_spec_files_for(ruby.lib_files)
50
+
51
+ # Rails files
52
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
53
+ dsl.watch_spec_files_for(rails.app_files)
54
+ dsl.watch_spec_files_for(rails.views)
55
+
56
+ watch(rails.controllers) do |m|
57
+ [
58
+ rspec.spec.("routing/#{m[1]}_routing"),
59
+ rspec.spec.("controllers/#{m[1]}_controller"),
60
+ rspec.spec.("acceptance/#{m[1]}")
61
+ ]
62
+ end
63
+
64
+ # Rails config changes
65
+ watch(rails.spec_helper) { rspec.spec_dir }
66
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
67
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
68
+
69
+ # Capybara features specs
70
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
71
+
72
+ # Turnip features and steps
73
+ watch(%r{^spec/acceptance/(.+)\.feature$})
74
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
75
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
76
+ end
77
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 n-kats
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.
@@ -0,0 +1,45 @@
1
+ # ArXiv
2
+
3
+ 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/ar_xiv`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ar_xiv'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ar_xiv
22
+
23
+ ## Usage
24
+
25
+ ```
26
+ require 'ar_xiv'
27
+
28
+ ArXiv.config = {
29
+ start: 0,
30
+ max_results: 10,
31
+ sort_by: 'lastUpdatedDate',
32
+ sort_order: 'descending'
33
+ }
34
+ puts ArXiv::get({cat: "math.GT"})
35
+ ```
36
+
37
+ ## Development
38
+
39
+ ## Contributing
40
+
41
+ 1. Fork it ( https://github.com/n-kats/ar_xiv/fork )
42
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
43
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
44
+ 4. Push to the branch (`git push origin my-new-feature`)
45
+ 5. Create a new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ar_xiv/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ar_xiv"
8
+ spec.version = ArXiv::VERSION
9
+ spec.authors = ["Katsunori Nakanishi"]
10
+ spec.email = ["n-kats19890214@hotmail.co.jp"]
11
+ spec.licenses = "MIT"
12
+ spec.summary = %q{simple request to arXiv}
13
+ spec.description = %q{simple request to arXiv and get data}
14
+ spec.homepage = "https://github.com/n-kats/ar_xiv"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "nokogiri", "~> 1.6"
22
+ spec.add_development_dependency "bundler", "~> 1.9"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "guard", "~> 2.1"
25
+ spec.add_development_dependency "guard-rspec", "~> 4.5"
26
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ar_xiv"
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
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,33 @@
1
+ require 'net/http'
2
+ require 'uri'
3
+ require 'nokogiri'
4
+ require 'ar_xiv/category'
5
+ require 'ar_xiv/request'
6
+ require 'ar_xiv/xml_parser'
7
+ require 'ar_xiv/version'
8
+
9
+ module ArXiv
10
+ @config = {}
11
+ def self.get(key, value=nil)
12
+ raise "set config by ArXiv.config = some_hash" if @config.empty?
13
+ case key
14
+ when Query
15
+ query = key
16
+ when ComposedQuery
17
+ query = key
18
+ else
19
+ query = Query.new(key,value)
20
+ end
21
+ xml = Request.new(query,@config).get
22
+ XMLParser.parse_short(xml)
23
+ end
24
+
25
+ def self.config
26
+ @config
27
+ end
28
+
29
+ def self.config=(hash)
30
+ @config = hash
31
+ end
32
+ end
33
+
@@ -0,0 +1,149 @@
1
+ module ArXiv
2
+ module Category
3
+ cat = <<-CAT
4
+ stat.AP Statistics - Applications
5
+ stat.CO Statistics - Computation
6
+ stat.ML Statistics - Machine Learning
7
+ stat.ME Statistics - Methodology
8
+ stat.TH Statistics - Theory
9
+ q-bio.BM Quantitative Biology - Biomolecules
10
+ q-bio.CB Quantitative Biology - Cell Behavior
11
+ q-bio.GN Quantitative Biology - Genomics
12
+ q-bio.MN Quantitative Biology - Molecular Networks
13
+ q-bio.NC Quantitative Biology - Neurons and Cognition
14
+ q-bio.OT Quantitative Biology - Other
15
+ q-bio.PE Quantitative Biology - Populations and Evolution
16
+ q-bio.QM Quantitative Biology - Quantitative Methods
17
+ q-bio.SC Quantitative Biology - Subcellular Processes
18
+ q-bio.TO Quantitative Biology - Tissues and Organs
19
+ cs.AR Computer Science - Architecture
20
+ cs.AI Computer Science - Artificial Intelligence
21
+ cs.CL Computer Science - Computation and Language
22
+ cs.CC Computer Science - Computational Complexity
23
+ cs.CE Computer Science - Computational Engineering; Finance; and Science
24
+ cs.CG Computer Science - Computational Geometry
25
+ cs.GT Computer Science - Computer Science and Game Theory
26
+ cs.CV Computer Science - Computer Vision and Pattern Recognition
27
+ cs.CY Computer Science - Computers and Society
28
+ cs.CR Computer Science - Cryptography and Security
29
+ cs.DS Computer Science - Data Structures and Algorithms
30
+ cs.DB Computer Science - Databases
31
+ cs.DL Computer Science - Digital Libraries
32
+ cs.DM Computer Science - Discrete Mathematics
33
+ cs.DC Computer Science - Distributed; Parallel; and Cluster Computing
34
+ cs.GL Computer Science - General Literature
35
+ cs.GR Computer Science - Graphics
36
+ cs.HC Computer Science - Human-Computer Interaction
37
+ cs.IR Computer Science - Information Retrieval
38
+ cs.IT Computer Science - Information Theory
39
+ cs.LG Computer Science - Learning
40
+ cs.LO Computer Science - Logic in Computer Science
41
+ cs.MS Computer Science - Mathematical Software
42
+ cs.MA Computer Science - Multiagent Systems
43
+ cs.MM Computer Science - Multimedia
44
+ cs.NI Computer Science - Networking and Internet Architecture
45
+ cs.NE Computer Science - Neural and Evolutionary Computing
46
+ cs.NA Computer Science - Numerical Analysis
47
+ cs.OS Computer Science - Operating Systems
48
+ cs.OH Computer Science - Other
49
+ cs.PF Computer Science - Performance
50
+ cs.PL Computer Science - Programming Languages
51
+ cs.RO Computer Science - Robotics
52
+ cs.SE Computer Science - Software Engineering
53
+ cs.SD Computer Science - Sound
54
+ cs.SC Computer Science - Symbolic Computation
55
+ nlin.AO Nonlinear Sciences - Adaptation and Self-Organizing Systems
56
+ nlin.CG Nonlinear Sciences - Cellular Automata and Lattice Gases
57
+ nlin.CD Nonlinear Sciences - Chaotic Dynamics
58
+ nlin.SI Nonlinear Sciences - Exactly Solvable and Integrable Systems
59
+ nlin.PS Nonlinear Sciences - Pattern Formation and Solitons
60
+ math.AG Mathematics - Algebraic Geometry
61
+ math.AT Mathematics - Algebraic Topology
62
+ math.AP Mathematics - Analysis of PDEs
63
+ math.CT Mathematics - Category Theory
64
+ math.CA Mathematics - Classical Analysis and ODEs
65
+ math.CO Mathematics - Combinatorics
66
+ math.AC Mathematics - Commutative Algebra
67
+ math.CV Mathematics - Complex Variables
68
+ math.DG Mathematics - Differential Geometry
69
+ math.DS Mathematics - Dynamical Systems
70
+ math.FA Mathematics - Functional Analysis
71
+ math.GM Mathematics - General Mathematics
72
+ math.GN Mathematics - General Topology
73
+ math.GT Mathematics - Geometric Topology
74
+ math.GR Mathematics - Group Theory
75
+ math.HO Mathematics - History and Overview
76
+ math.IT Mathematics - Information Theory
77
+ math.KT Mathematics - K-Theory and Homology
78
+ math.LO Mathematics - Logic
79
+ math.MP Mathematics - Mathematical Physics
80
+ math.MG Mathematics - Metric Geometry
81
+ math.NT Mathematics - Number Theory
82
+ math.NA Mathematics - Numerical Analysis
83
+ math.OA Mathematics - Operator Algebras
84
+ math.OC Mathematics - Optimization and Control
85
+ math.PR Mathematics - Probability
86
+ math.QA Mathematics - Quantum Algebra
87
+ math.RT Mathematics - Representation Theory
88
+ math.RA Mathematics - Rings and Algebras
89
+ math.SP Mathematics - Spectral Theory
90
+ math.ST Mathematics - Statistics
91
+ math.SG Mathematics - Symplectic Geometry
92
+ astro-ph Astrophysics
93
+ cond-mat.dis-nn Physics - Disordered Systems and Neural Networks
94
+ cond-mat.mes-hall Physics - Mesoscopic Systems and Quantum Hall Effect
95
+ cond-mat.mtrl-sci Physics - Materials Science
96
+ cond-mat.other Physics - Other
97
+ cond-mat.soft Physics - Soft Condensed Matter
98
+ cond-mat.stat-mech Physics - Statistical Mechanics
99
+ cond-mat.str-el Physics - Strongly Correlated Electrons
100
+ cond-mat.supr-con Physics - Superconductivity
101
+ gr-qc General Relativity and Quantum Cosmology
102
+ hep-ex High Energy Physics - Experiment
103
+ hep-lat High Energy Physics - Lattice
104
+ hep-ph High Energy Physics - Phenomenology
105
+ hep-th High Energy Physics - Theory
106
+ math-ph Mathematical Physics
107
+ nucl-ex Nuclear Experiment
108
+ nucl-th Nuclear Theory
109
+ physics.acc-ph Physics - Accelerator Physics
110
+ physics.ao-ph Physics - Atmospheric and Oceanic Physics
111
+ physics.atom-ph Physics - Atomic Physics
112
+ physics.atm-clus Physics - Atomic and Molecular Clusters
113
+ physics.bio-ph Physics - Biological Physics
114
+ physics.chem-ph Physics - Chemical Physics
115
+ physics.class-ph Physics - Classical Physics
116
+ physics.comp-ph Physics - Computational Physics
117
+ physics.data-an Physics - Data Analysis; Statistics and Probability
118
+ physics.flu-dyn Physics - Fluid Dynamics
119
+ physics.gen-ph Physics - General Physics
120
+ physics.geo-ph Physics - Geophysics
121
+ physics.hist-ph Physics - History of Physics
122
+ physics.ins-det Physics - Instrumentation and Detectors
123
+ physics.med-ph Physics - Medical Physics
124
+ physics.optics Physics - Optics
125
+ physics.ed-ph Physics - Physics Education
126
+ physics.soc-ph Physics - Physics and Society
127
+ physics.plasm-ph Physics - Plasma Physics
128
+ physics.pop-ph Physics - Popular Physics
129
+ physics.space-ph Physics - Space Physics
130
+ quant-ph Quantum Physics
131
+ CAT
132
+ CAT_REGEXP = /\A([\w-]+)\.([\w-]+)\t(.*)\n*\z/
133
+ CAT_REGEXP2 = /\A([\w-]+)\t(.*)\n*\z/
134
+
135
+ LIST_HASH = {}
136
+ cat.lines.each do |l|
137
+ case l
138
+ when CAT_REGEXP
139
+ LIST_HASH[$1] ||= {}
140
+ LIST_HASH[$1][$2] = $3
141
+ when CAT_REGEXP2
142
+ LIST_HASH[$1] = $2
143
+ else
144
+ raise "\n\tFOUND UNKNOWN FORMAT:\n#{l}" # FIXME: improve this error message
145
+ end
146
+ end
147
+ end
148
+ end
149
+
@@ -0,0 +1,103 @@
1
+ module ArXiv
2
+ module QueryOperator
3
+ def and(query)
4
+ ComposedQuery.new("AND", self, query)
5
+ end
6
+
7
+ def or(query)
8
+ ComposedQuery.new("OR", self, query)
9
+ end
10
+
11
+ def andnot(query)
12
+ ComposedQuery.new("ANDNOT", self, query)
13
+ end
14
+
15
+ # TODO: + や - の実装
16
+ end
17
+
18
+ # AND OR ANDOR を意識しないquery
19
+ class Query
20
+ include QueryOperator
21
+ # @queryは
22
+ # {xx: [str,str,str]}
23
+ def initialize(key, value=nil)
24
+ if value==nil
25
+ case key
26
+ when String
27
+ @key = "all"
28
+ @value = [key]
29
+ when Array
30
+ @key = "all"
31
+ @value = key
32
+ when Hash
33
+ raise if key.keys.length != 1 # TODO: 1以外に対応
34
+ @key = key.keys.first
35
+ @value = (key[@key].is_a? Array) ? key[@key] : [key[@key]]
36
+ end
37
+ else
38
+ @key = key
39
+ @value = (key.is_a? Array) ? value : [value]
40
+ end
41
+ end
42
+
43
+ def to_query_string
44
+ "#{@key}:%28%22#{@value.join("%22+AND+%22")}%22%29"
45
+ end
46
+ end
47
+
48
+ class ComposedQuery
49
+ include QueryOperator
50
+ def initialize(str, *args)
51
+ case str
52
+ when String
53
+ @op = str
54
+ @requests = args
55
+ when Query
56
+ @op = ""
57
+ @request = str
58
+ else
59
+ raise "Fail to make a Composed Request"
60
+ end
61
+ end
62
+
63
+ def to_query_string
64
+ if @op.empty?
65
+ @request.to_query_string
66
+ else
67
+ "%28#{@requests.map(&:to_query_string).join("%29+#{@op.upcase}+%28")}%29"
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ class Request
74
+
75
+ PARAMS = %w{search_query start max_results id_list sort_by sort_order}
76
+
77
+ def initialize(query=nil, hash={})
78
+ @option = hash.dup
79
+ @query = query # String, Query, or ComposedQuery
80
+ end
81
+
82
+ def api_url
83
+ @option["search_query"] = @query.to_query_string if @query
84
+ url = "http://export.arxiv.org/api/query?"
85
+ @option.each.with_index do |(k,v),i|
86
+ url += "&" if i != 0
87
+ url += "#{k}=#{v}"
88
+ end
89
+ url
90
+ end
91
+
92
+ def get
93
+ req = Net::HTTP.get_response(URI.parse(api_url))
94
+ req.body
95
+ end
96
+
97
+ PARAMS.each do |par|
98
+ define_method "#{par}=".to_sym do |val|
99
+ @option[par] = val
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,3 @@
1
+ module ArXiv
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,97 @@
1
+ module ArXiv
2
+
3
+ DATA_CSS_LIST = {
4
+ id: "id",
5
+ title: "title",
6
+ authors: "author>name",
7
+ summary: "summary",
8
+ updated: "updated",
9
+ published: "published",
10
+ categories: "category"
11
+ }
12
+
13
+ class XMLParser
14
+ def initialize(xml)
15
+ @entries = Nokogiri::XML(xml).css('entry').map{|x| Entry.new(x)}
16
+ end
17
+
18
+ def to_obj
19
+ @entries.map(&:to_hash)
20
+ end
21
+
22
+ def to_short_obj
23
+ @entries.map(&:to_hash)
24
+ end
25
+
26
+ def self.parse(xml)
27
+ new(xml).to_obj
28
+ end
29
+
30
+ def self.parse_short(xml)
31
+ new(xml).to_short_obj
32
+ end
33
+ end
34
+
35
+ # ���ꂼ��̃G���g���[�̏���
36
+ class Entry
37
+
38
+ def initialize(noko)
39
+ @xml = noko
40
+ end
41
+
42
+ %w{updated published summary}.each do |x|
43
+ define_method x.to_sym do
44
+ @xml.css(x).text
45
+ end
46
+ end
47
+
48
+ def id
49
+ case @xml.css("id").text
50
+ when /\/(\d+\.\d+v\d+)\z/
51
+ return $1
52
+ when /\/(\d+v\d+)\z/
53
+ return $1
54
+ end
55
+ end
56
+
57
+ def title
58
+ @xml.css("title").text.gsub(/\n/,' ').gsub(/\s+/,' ')
59
+ end
60
+
61
+ def authors
62
+ @xml.css('author>name').map(&:text)
63
+ end
64
+
65
+ def primary_category
66
+ @xml.css('arxiv:primary_category').first['term']
67
+ end
68
+
69
+ def categories
70
+ @xml.css('category').map{|x|x['term']}
71
+ end
72
+
73
+ def to_short_hash
74
+ {
75
+ "id" => id,
76
+ "title" => title,
77
+ "authors" => authors,
78
+ "summary" => summary,
79
+ "categories" => categories
80
+ }
81
+ end
82
+
83
+ def to_hash
84
+ {
85
+ "id" => id,
86
+ "title" => title,
87
+ "authors" => authors,
88
+ "abstract" => summary,
89
+ "updated" => updated,
90
+ "published" => published,
91
+ "categories" => categories
92
+ }
93
+ end
94
+ end
95
+
96
+ end
97
+
@@ -0,0 +1,4 @@
1
+ favorite.txt������
2
+ ignore_words��ݒ�
3
+ �]�v�ȃs���I�h�Ƃ�������
4
+
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ar_xiv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Katsunori Nakanishi
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.9'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: guard-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.5'
83
+ description: simple request to arXiv and get data
84
+ email:
85
+ - n-kats19890214@hotmail.co.jp
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".editorconfig"
91
+ - ".gitignore"
92
+ - ".rspec"
93
+ - ".travis.yml"
94
+ - Gemfile
95
+ - Guardfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - ar_xiv.gemspec
100
+ - bin/console
101
+ - bin/setup
102
+ - lib/ar_xiv.rb
103
+ - lib/ar_xiv/category.rb
104
+ - lib/ar_xiv/request.rb
105
+ - lib/ar_xiv/version.rb
106
+ - lib/ar_xiv/xml_parser.rb
107
+ - todo.txt
108
+ homepage: https://github.com/n-kats/ar_xiv
109
+ licenses:
110
+ - MIT
111
+ metadata: {}
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.6
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: simple request to arXiv
132
+ test_files: []
133
+ has_rdoc: