arxiv 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc CHANGED
@@ -1,3 +1,42 @@
1
- = arXiv
1
+ http://docs.scholastica.s3.amazonaws.com/scholastica_logo.png
2
2
 
3
- Not quite ready for production.
3
+ A Ruby wrapper for the {arXiv API}[http://arxiv.org/help/api/index]. ArXiv is an open access pre-print server used primarily in physics, mathematics, computer science, quantitative biology, quantitative finance and statistics.
4
+
5
+ <i>This is not a complete wrapper around the arXiv API. We'll be making improvements as needed for our overlay journals. If you'd like something added, send us a note or make a pull request.</i>
6
+
7
+ == Fetching a manuscript
8
+ Grab a manuscript using the arXiv document id:
9
+
10
+ manuscript = Arxiv.get('1202.0819')
11
+
12
+ And inspect it:
13
+
14
+ manuscript.revision? # => false
15
+ manuscript.title # => "Laser frequency comb techniques for precise astronomical spectroscopy"
16
+ manuscript.abstract # => "Precise astronomical spectroscopic analyses routinely assume..."
17
+ manuscript.arxiv_id # => "1202.0819"
18
+ manuscript.version # => 1
19
+ manuscript.pdf_url # => "http://arxiv.org/pdf/1202.0819v1"
20
+
21
+ == Authors
22
+ Look up a manuscript's authors:
23
+
24
+ authors = manuscript.authors # => an array of all the manuscript's authors
25
+ authors.map(&:name) # => ["Michael T. Murphy", "Clayton R. Locke", "Philip S. Light", "Andre N. Luiten", "Jon S. Lawrence"]
26
+
27
+ # a single author
28
+ authors.last.name # => "Jon S. Lawrence"
29
+ authors.last.affiliations # => ["Australian Astronomical Observatory", "Macquarie University"]
30
+
31
+ == Categories
32
+ Look at a manuscript's categories:
33
+
34
+ manuscript.categories # => an array of categories
35
+ manuscript.categories.map(&:abbreviation) # => ["astro-ph.IM", "astro-ph.CO", "astro-ph.EP"]
36
+
37
+ # a single category
38
+ manuscript.primary_category.name # => "astro-ph.IM"
39
+ manuscript.primary_category.description # => "Physics - Instrumentation and Methods for Astrophysics"
40
+
41
+ == License
42
+ This project uses MIT-LICENSE.
data/lib/arxiv.rb CHANGED
@@ -1,8 +1,15 @@
1
- require 'arxiv/version'
2
1
  require 'open-uri'
3
2
  require 'nokogiri'
4
3
  require 'happymapper'
5
4
 
5
+ require 'arxiv/version'
6
+ require 'arxiv/string_scrubber'
7
+
8
+ require 'arxiv/models/author'
9
+ require 'arxiv/models/link'
10
+ require 'arxiv/models/category'
11
+ require 'arxiv/models/manuscript'
12
+
6
13
  module Arxiv
7
14
 
8
15
  def self.get(id)
@@ -11,99 +18,4 @@ module Arxiv
11
18
  manuscript = Arxiv::Manuscript.parse(response.to_s, single: id)
12
19
  end
13
20
 
14
- class StringScrubber
15
- def self.scrub(string)
16
- string.gsub("\n", ' ').strip.squeeze(" ")
17
- end
18
- end
19
-
20
- class Author
21
- include HappyMapper
22
- element :name, StringScrubber, parser: :scrub
23
- has_many :affiliations, StringScrubber, parser: :scrub, tag: 'affiliation'
24
- end
25
-
26
- class Link
27
- include HappyMapper
28
- attribute :url, String, tag: 'href'
29
- attribute :content_type, String, tag: 'type'
30
- end
31
-
32
- class Category
33
- include HappyMapper
34
-
35
- def self.types
36
- url = ::URI.parse("http://arxiv-api.googlegroups.com/attach/5e540c5aa16cd1a1/servicedocument.xml?gda=GkSq-0UAAACv8MuSQ9shr-Fm8egpLVNUyoJFgZHB152DBrQX4ANeXa_N1TJg9KB-8oF-EwbRpI6O3f1cykW9hbJ1ju6H3kglGu1iLHeqhw4ZZRj3RjJ_-A&view=1&part=2")
37
- xml = ::Nokogiri::XML(open(url)).remove_namespaces!
38
- category_mapping = {}
39
- categories = xml.xpath("/service/workspace/collection/categories/category")
40
- categories.each do |category|
41
- abbreviation = category.attributes["term"].value.match(/[^\/]+$/)[0]
42
- description = category.attributes["label"].value
43
- category_mapping.merge!(abbreviation => description)
44
- end
45
- category_mapping
46
- end
47
-
48
- Types = Category.types
49
-
50
- attribute :abbreviation, String, tag: 'term'
51
-
52
- def description
53
- Types[abbreviation]
54
- end
55
-
56
- def long_description
57
- "#{abbreviation} (#{description})"
58
- end
59
-
60
- end
61
-
62
- class Manuscript
63
- include HappyMapper
64
-
65
- tag 'entry'
66
- element :arxiv_url, String, tag: 'id'
67
- element :created_at, DateTime, tag: 'published'
68
- element :updated_at, DateTime, tag: 'published'
69
- element :title, StringScrubber, parser: :scrub
70
- element :summary, StringScrubber, parser: :scrub
71
- element :comment, StringScrubber, parser: :scrub
72
- has_one :primary_category, Category
73
- has_many :categories, Category
74
- has_many :authors, Author
75
- has_many :links, Link
76
-
77
- alias :abstract :summary
78
-
79
- def revision?
80
- created_at != updated_at
81
- end
82
-
83
- def arxiv_id
84
- arxiv_url.match(/([^\/]+)v\d+$/)[1]
85
- end
86
-
87
- def arxiv_versioned_id
88
- arxiv_url.match(/([^\/]+)$/)[1]
89
- end
90
-
91
- def version
92
- arxiv_url.match(/v(\d+)$/)[1].to_i
93
- end
94
-
95
- def content_types
96
- links.map(&:content_type)
97
- end
98
-
99
- def available_in_pdf?
100
- content_types.any? { |type| type == "application/pdf" }
101
- end
102
-
103
- def pdf_url
104
- links.find { |l| l.content_type == "application/pdf" }.url if available_in_pdf?
105
- end
106
-
107
- end
108
-
109
21
  end
@@ -0,0 +1,7 @@
1
+ module Arxiv
2
+ class Author
3
+ include HappyMapper
4
+ element :name, StringScrubber, parser: :scrub
5
+ has_many :affiliations, StringScrubber, parser: :scrub, tag: 'affiliation'
6
+ end
7
+ end
@@ -0,0 +1,31 @@
1
+ module Arxiv
2
+ class Category
3
+ include HappyMapper
4
+
5
+ def self.types
6
+ url = ::URI.parse("http://arxiv-api.googlegroups.com/attach/5e540c5aa16cd1a1/servicedocument.xml?gda=GkSq-0UAAACv8MuSQ9shr-Fm8egpLVNUyoJFgZHB152DBrQX4ANeXa_N1TJg9KB-8oF-EwbRpI6O3f1cykW9hbJ1ju6H3kglGu1iLHeqhw4ZZRj3RjJ_-A&view=1&part=2")
7
+ xml = ::Nokogiri::XML(open(url)).remove_namespaces!
8
+ category_mapping = {}
9
+ categories = xml.xpath("/service/workspace/collection/categories/category")
10
+ categories.each do |category|
11
+ abbreviation = category.attributes["term"].value.match(/[^\/]+$/)[0]
12
+ description = category.attributes["label"].value
13
+ category_mapping.merge!(abbreviation => description)
14
+ end
15
+ category_mapping
16
+ end
17
+
18
+ Types = Category.types
19
+
20
+ attribute :abbreviation, String, tag: 'term'
21
+
22
+ def description
23
+ Types[abbreviation]
24
+ end
25
+
26
+ def long_description
27
+ "#{abbreviation} (#{description})"
28
+ end
29
+
30
+ end
31
+ end
@@ -0,0 +1,7 @@
1
+ module Arxiv
2
+ class Link
3
+ include HappyMapper
4
+ attribute :url, String, tag: 'href'
5
+ attribute :content_type, String, tag: 'type'
6
+ end
7
+ end
@@ -0,0 +1,48 @@
1
+ module Arxiv
2
+ class Manuscript
3
+ include HappyMapper
4
+
5
+ tag 'entry'
6
+ element :arxiv_url, String, tag: 'id'
7
+ element :created_at, DateTime, tag: 'published'
8
+ element :updated_at, DateTime, tag: 'published'
9
+ element :title, StringScrubber, parser: :scrub
10
+ element :summary, StringScrubber, parser: :scrub
11
+ element :comment, StringScrubber, parser: :scrub
12
+ has_one :primary_category, Category
13
+ has_many :categories, Category
14
+ has_many :authors, Author
15
+ has_many :links, Link
16
+
17
+ alias :abstract :summary
18
+
19
+ def revision?
20
+ created_at != updated_at
21
+ end
22
+
23
+ def arxiv_id
24
+ arxiv_url.match(/([^\/]+)v\d+$/)[1]
25
+ end
26
+
27
+ def arxiv_versioned_id
28
+ arxiv_url.match(/([^\/]+)$/)[1]
29
+ end
30
+
31
+ def version
32
+ arxiv_url.match(/v(\d+)$/)[1].to_i
33
+ end
34
+
35
+ def content_types
36
+ links.map(&:content_type)
37
+ end
38
+
39
+ def available_in_pdf?
40
+ content_types.any? { |type| type == "application/pdf" }
41
+ end
42
+
43
+ def pdf_url
44
+ links.find { |l| l.content_type == "application/pdf" }.url if available_in_pdf?
45
+ end
46
+
47
+ end
48
+ end
@@ -0,0 +1,7 @@
1
+ module Arxiv
2
+ class StringScrubber
3
+ def self.scrub(string)
4
+ string.gsub("\n", ' ').strip.squeeze(" ")
5
+ end
6
+ end
7
+ end
data/lib/arxiv/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Arxiv
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module Arxiv
4
+ describe Author do
5
+ before(:all) { @author = Arxiv.get('1202.0819').authors.first }
6
+
7
+ describe "name" do
8
+ it "should return the author's name" do
9
+ @author.name.should == "Michael T. Murphy"
10
+ end
11
+ end
12
+
13
+ describe "affiliations" do
14
+ it "should return an array of the author's affiliations" do
15
+ @author.affiliations.should include("Swinburne University of Technology")
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+
3
+ module Arxiv
4
+ describe Category do
5
+ before(:all) { @category = Arxiv.get('1202.0819').primary_category }
6
+
7
+ describe "abbreviation" do
8
+ it "should fetch the category's abbreviation" do
9
+ @category.abbreviation.should == "astro-ph.IM"
10
+ end
11
+ end
12
+
13
+ describe "description" do
14
+ it "should fetch the category's description" do
15
+ @category.description.should == "Physics - Instrumentation and Methods for Astrophysics"
16
+ end
17
+ end
18
+
19
+ describe "long_description" do
20
+ it "should fetch the category's #long_description" do
21
+ @category.long_description.should == "astro-ph.IM (Physics - Instrumentation and Methods for Astrophysics)"
22
+ end
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ module Arxiv
4
+ describe Link do
5
+ before(:all) { @link = Arxiv.get('1202.0819').links.last }
6
+
7
+ describe "content_type" do
8
+ it "should fetch the link's content type" do
9
+ @link.content_type.should == 'application/pdf'
10
+ end
11
+ end
12
+
13
+ describe "url" do
14
+ it "should fetch the link's url" do
15
+ @link.url.should == 'http://arxiv.org/pdf/1202.0819v1'
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,105 @@
1
+ require 'spec_helper'
2
+
3
+ module Arxiv
4
+ describe Manuscript do
5
+ before(:all) { @manuscript = Arxiv.get('1202.0819') }
6
+
7
+ describe "arxiv_url" do
8
+ it "should fetch the link to the manuscript's page on arXiv" do
9
+ @manuscript.arxiv_url.should == "http://arxiv.org/abs/1202.0819v1"
10
+ end
11
+ end
12
+
13
+ describe "created_at" do
14
+ it "should fetch the datetime when the manuscript was first published to arXiv" do
15
+ @manuscript.created_at.should == DateTime.parse("2012-02-03T21:00:00Z")
16
+ end
17
+ end
18
+
19
+ describe "updated_at" do
20
+ it "should fetch the datetime when the manuscript was last updated" do
21
+ @manuscript.updated_at.should == DateTime.parse("2012-02-03T21:00:00Z")
22
+ end
23
+ end
24
+
25
+ describe "title" do
26
+ it "should fetch the manuscript's title" do
27
+ @manuscript.title.should == "Laser frequency comb techniques for precise astronomical spectroscopy"
28
+ end
29
+ end
30
+
31
+ describe "abstract" do
32
+ it "should fetch the manuscript's abstract" do
33
+ @manuscript.abstract.should == "Precise astronomical spectroscopic analyses routinely assume that individual pixels in charge-coupled devices (CCDs) have uniform sensitivity to photons. Intra-pixel sensitivity (IPS) variations may already cause small systematic errors in, for example, studies of extra-solar planets via stellar radial velocities and cosmological variability in fundamental constants via quasar spectroscopy, but future experiments requiring velocity precisions approaching ~1 cm/s will be more strongly affected. Laser frequency combs have been shown to provide highly precise wavelength calibration for astronomical spectrographs, but here we show that they can also be used to measure IPS variations in astronomical CCDs in situ. We successfully tested a laser frequency comb system on the Ultra-High Resolution Facility spectrograph at the Anglo-Australian Telescope. By modelling the 2-dimensional comb signal recorded in a single CCD exposure, we find that the average IPS deviates by <8 per cent if it is assumed to vary symmetrically about the pixel centre. We also demonstrate that series of comb exposures with absolutely known offsets between them can yield tighter constraints on symmetric IPS variations from ~100 pixels. We discuss measurement of asymmetric IPS variations and absolute wavelength calibration of astronomical spectrographs and CCDs using frequency combs."
34
+ end
35
+ end
36
+
37
+ describe "comment" do
38
+ it "should fetch the manuscript's comment" do
39
+ @manuscript.comment.should == "11 pages, 7 figures. Accepted for publication in MNRAS"
40
+ end
41
+ end
42
+
43
+ describe "revision?" do
44
+ it "should return true if the manuscript has been revised" do
45
+ @manuscript.should_not be_revision
46
+ end
47
+ end
48
+
49
+ describe "arxiv_versioned_id" do
50
+ it "should return the unique document id used by arXiv" do
51
+ @manuscript.arxiv_versioned_id.should == '1202.0819v1'
52
+ end
53
+ end
54
+
55
+ describe "arxiv_id" do
56
+ it "should return the unique document id used by arXiv" do
57
+ @manuscript.arxiv_id.should == '1202.0819'
58
+ end
59
+ end
60
+
61
+ describe "version" do
62
+ it "should return the manuscript's version number" do
63
+ @manuscript.version.should == 1
64
+ end
65
+ end
66
+
67
+ describe "content_types" do
68
+ it "return an array of available content_types" do
69
+ @manuscript.content_types.should include("text/html", "application/pdf")
70
+ @manuscript.content_types.should have(2).content_types
71
+ end
72
+ end
73
+
74
+ describe "available_in_pdf?" do
75
+ it "should return true if the manuscript is available to be downloaded in PDF" do
76
+ @manuscript.should be_available_in_pdf
77
+ end
78
+ end
79
+
80
+ describe "pdf_url" do
81
+ it "should return the url to download the manuscript in PDF format" do
82
+ @manuscript.pdf_url.should == 'http://arxiv.org/pdf/1202.0819v1'
83
+ end
84
+ end
85
+
86
+ describe "authors" do
87
+ it "should return an array of all the manuscript's authors" do
88
+ @manuscript.authors.should have(5).authors
89
+ end
90
+ end
91
+
92
+ describe "categories" do
93
+ it "should fetch the manuscript's categories" do
94
+ @manuscript.categories.map(&:abbreviation).should include("astro-ph.IM", "astro-ph.CO", "astro-ph.EP")
95
+ end
96
+ end
97
+
98
+ describe "primary_category" do
99
+ it "should description" do
100
+ @manuscript.primary_category.abbreviation.should == "astro-ph.IM"
101
+ end
102
+ end
103
+
104
+ end
105
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arxiv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -15,7 +15,7 @@ date: 2012-02-14 00:00:00.000000000Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: happymapper
18
- requirement: &2152849100 !ruby/object:Gem::Requirement
18
+ requirement: &2153612280 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ! '>='
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: '0'
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2152849100
26
+ version_requirements: *2153612280
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
- requirement: &2152848680 !ruby/object:Gem::Requirement
29
+ requirement: &2153611860 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ! '>='
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: '0'
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2152848680
37
+ version_requirements: *2153611860
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rspec
40
- requirement: &2152848260 !ruby/object:Gem::Requirement
40
+ requirement: &2153611440 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ! '>='
@@ -45,7 +45,7 @@ dependencies:
45
45
  version: '0'
46
46
  type: :development
47
47
  prerelease: false
48
- version_requirements: *2152848260
48
+ version_requirements: *2153611440
49
49
  description: Makes interacting with arXiv data really easy.
50
50
  email:
51
51
  - coryschires@gmail.com
@@ -57,12 +57,21 @@ files:
57
57
  - .rspec
58
58
  - .rvmrc
59
59
  - Gemfile
60
+ - MIT-LICENSE
60
61
  - README.rdoc
61
62
  - Rakefile
62
63
  - arxiv.gemspec
63
64
  - lib/arxiv.rb
65
+ - lib/arxiv/models/author.rb
66
+ - lib/arxiv/models/category.rb
67
+ - lib/arxiv/models/link.rb
68
+ - lib/arxiv/models/manuscript.rb
69
+ - lib/arxiv/string_scrubber.rb
64
70
  - lib/arxiv/version.rb
65
- - spec/arxiv_spec.rb
71
+ - spec/arxiv/models/author_spec.rb
72
+ - spec/arxiv/models/category_spec.rb
73
+ - spec/arxiv/models/link_spec.rb
74
+ - spec/arxiv/models/manuscript_spec.rb
66
75
  - spec/spec_helper.rb
67
76
  homepage: ''
68
77
  licenses: []
@@ -89,5 +98,8 @@ signing_key:
89
98
  specification_version: 3
90
99
  summary: Ruby wrapper accessing the arXiv API
91
100
  test_files:
92
- - spec/arxiv_spec.rb
101
+ - spec/arxiv/models/author_spec.rb
102
+ - spec/arxiv/models/category_spec.rb
103
+ - spec/arxiv/models/link_spec.rb
104
+ - spec/arxiv/models/manuscript_spec.rb
93
105
  - spec/spec_helper.rb
data/spec/arxiv_spec.rb DELETED
@@ -1,102 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Arxiv do
4
- before :all do
5
- @manuscript = Arxiv.get('1202.0819') # export.arxiv.org/api/query?id_list=1202.0819
6
- end
7
-
8
- it "should fetch the link to the manuscript's page on arXiv" do
9
- @manuscript.arxiv_url.should == "http://arxiv.org/abs/1202.0819v1"
10
- end
11
- it "should fetch the datetime when the manuscript was first published to arXiv" do
12
- @manuscript.created_at.should == DateTime.parse("2012-02-03T21:00:00Z")
13
- end
14
- it "should fetch the datetime when the manuscript was last updated" do
15
- @manuscript.updated_at.should == DateTime.parse("2012-02-03T21:00:00Z")
16
- end
17
- it "should fetch the manuscript's title" do
18
- @manuscript.title.should == "Laser frequency comb techniques for precise astronomical spectroscopy"
19
- end
20
- it "should fetch the manuscript's abstract" do
21
- @manuscript.abstract.should == "Precise astronomical spectroscopic analyses routinely assume that individual pixels in charge-coupled devices (CCDs) have uniform sensitivity to photons. Intra-pixel sensitivity (IPS) variations may already cause small systematic errors in, for example, studies of extra-solar planets via stellar radial velocities and cosmological variability in fundamental constants via quasar spectroscopy, but future experiments requiring velocity precisions approaching ~1 cm/s will be more strongly affected. Laser frequency combs have been shown to provide highly precise wavelength calibration for astronomical spectrographs, but here we show that they can also be used to measure IPS variations in astronomical CCDs in situ. We successfully tested a laser frequency comb system on the Ultra-High Resolution Facility spectrograph at the Anglo-Australian Telescope. By modelling the 2-dimensional comb signal recorded in a single CCD exposure, we find that the average IPS deviates by <8 per cent if it is assumed to vary symmetrically about the pixel centre. We also demonstrate that series of comb exposures with absolutely known offsets between them can yield tighter constraints on symmetric IPS variations from ~100 pixels. We discuss measurement of asymmetric IPS variations and absolute wavelength calibration of astronomical spectrographs and CCDs using frequency combs."
22
- end
23
- it "should fetch the manuscript's comment" do
24
- @manuscript.comment.should == "11 pages, 7 figures. Accepted for publication in MNRAS"
25
- end
26
-
27
- context "authors" do
28
- it "should fetch the authors" do
29
- @manuscript.authors.should have(5).authors
30
- end
31
- it "should fetch the author's affiliations" do
32
- author = @manuscript.authors.first
33
- author.affiliations.should include("Swinburne University of Technology")
34
- end
35
- end
36
-
37
- context "categories" do
38
- it "should fetch the manuscript's categories" do
39
- @manuscript.categories.map(&:abbreviation).should include("astro-ph.IM", "astro-ph.CO", "astro-ph.EP")
40
- end
41
- it "should fetch the category's abbreviation" do
42
- @manuscript.primary_category.abbreviation.should == "astro-ph.IM"
43
- end
44
- it "should fetch the category's description" do
45
- @manuscript.primary_category.description.should == "Physics - Instrumentation and Methods for Astrophysics"
46
- end
47
- it "should fetch the category's #long_description" do
48
- @manuscript.primary_category.long_description.should == "astro-ph.IM (Physics - Instrumentation and Methods for Astrophysics)"
49
- end
50
-
51
- end
52
-
53
- context "links" do
54
- let(:pdf) {@manuscript.links.last}
55
- it "should fetch the link's content type" do
56
- pdf.content_type.should == 'application/pdf'
57
- end
58
- it "should fetch the link's url" do
59
- pdf.url.should == 'http://arxiv.org/pdf/1202.0819v1'
60
- end
61
- end
62
-
63
- context "instance methods" do
64
- describe "revision?" do
65
- it "should return true if the manuscript has been revised" do
66
- @manuscript.should_not be_revision
67
- end
68
- end
69
- describe "arxiv_versioned_id" do
70
- it "should return the unique document id used by arXiv" do
71
- @manuscript.arxiv_versioned_id.should == '1202.0819v1'
72
- end
73
- end
74
- describe "arxiv_id" do
75
- it "should return the unique document id used by arXiv" do
76
- @manuscript.arxiv_id.should == '1202.0819'
77
- end
78
- end
79
- describe "version" do
80
- it "should return the manuscript's version number" do
81
- @manuscript.version.should == 1
82
- end
83
- end
84
- describe "content_types" do
85
- it "return an array of available content_types" do
86
- @manuscript.content_types.should include("text/html", "application/pdf")
87
- @manuscript.content_types.should have(2).content_types
88
- end
89
- end
90
- describe "available_in_pdf?" do
91
- it "should return true if the manuscript is available to be downloaded in PDF" do
92
- @manuscript.should be_available_in_pdf
93
- end
94
- end
95
- describe "pdf_url" do
96
- it "should return the url to download the manuscript in PDF format" do
97
- @manuscript.pdf_url.should == 'http://arxiv.org/pdf/1202.0819v1'
98
- end
99
- end
100
- end
101
-
102
- end