jats 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1 @@
1
+ <p>Many seasonal breeders undergo seasonal cycles of gonadal growth and regression, accompanied by changes in sex steroid production and gamete maturation. (<xref ref-type="bibr" rid="ref-20">Dawson et al., 2001</xref>).</p>
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Affiliation do
5
+ def aff
6
+ Jats::Affiliation.from_xml(fixture('affiliation.xml'))
7
+ end
8
+
9
+ it "should cast to hash correctly" do
10
+ aff.to_hash.should == {
11
+ label: '1',
12
+ department: 'Laboratory of Reproductive Neuroendocrinology, Department of Integrative Biology',
13
+ address: 'University of California at Berkeley',
14
+ country: 'USA'
15
+ }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Annotation do
5
+ def annotation
6
+ Jats::Annotation.from_xml(fixture('annotation.xml').at('xref'))
7
+ end
8
+
9
+ it "should have the correct attributes" do
10
+ ann = annotation
11
+
12
+ ann.source = 'source'
13
+
14
+ ann.attributes.should == {
15
+ source: 'source',
16
+ content: 'Dawson et al., 2001',
17
+ target: 'article:bib20'
18
+ }
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Article do
5
+ it "should parse a xml" do
6
+ article = double("Article")
7
+ Article.should_receive(:new).with('xml').and_return article
8
+ article.should_receive(:parse).and_return 'parsed'
9
+ Article.from_xml('xml').should == 'parsed'
10
+ end
11
+
12
+ it "add a node to the outline" do
13
+ article = Article.new
14
+
15
+ node = double("Node", name: 'name')
16
+ article.add_to_outline node
17
+
18
+ article.doc[:views][:content].should include('name')
19
+ end
20
+
21
+ it "should add a node to the nodes" do
22
+ article = Article.new
23
+
24
+ node = double("Node", to_hash: { name: 'name' })
25
+ article.add_node node
26
+
27
+ article.doc[:nodes].should include(name: 'name')
28
+ end
29
+
30
+ it "should parse the front, body and back" do
31
+ article = Article.new
32
+
33
+ article.should_receive(:parse_front)
34
+ article.should_receive(:parse_body)
35
+ article.should_receive(:parse_back)
36
+
37
+ article.parse
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jats::Body do
4
+ def body
5
+ xml = fixture('peerj.xml')
6
+ Jats::Article.from_xml(xml)
7
+ end
8
+
9
+ it "should map the headings" do
10
+ nodes = body[:nodes]
11
+
12
+ nodes['heading:1'].should == {
13
+ type: 'heading',
14
+ id: 'heading:1',
15
+ content: 'Introduction',
16
+ level: 1
17
+ }
18
+
19
+ nodes['heading:2'].should == {
20
+ type: 'heading',
21
+ id: 'heading:2',
22
+ content: 'Materials and Methods',
23
+ level: 1
24
+ }
25
+
26
+ nodes['heading:3'].should == {
27
+ type: 'heading',
28
+ id: 'heading:3',
29
+ content: 'Gonad culture',
30
+ level: 2
31
+ }
32
+ end
33
+
34
+ it "should map the paragraphs" do
35
+ nodes = body[:nodes]
36
+
37
+ nodes['text:27'].should == {
38
+ type: 'text',
39
+ id: 'text:27',
40
+ content: 'In sum, the evidence provided by our model shows that the testes and ovaries of European starlings respond directly to chronically elevated corticosterone and metabolic stress independently of the brain by modulating testosterone and estradiol secretion. This modulation is season- and sex-specific: it occurs only while birds are deciding to breed, and it appears to involve the gonadal GnIH system. It is likely that this direct modulation of gonadal function in response to stress is most important prior to the onset of breeding because the gonads are not already maximally stimulated by components of the HPG axis and fully recrudesced. Taken together, our data indicate that photosensitive temperate songbird testes and ovaries are capable of responding directly to corticosterone and metabolic stress, in addition to GnRH-induced gonadotropin release, by increasing GnIH expression and decreasing testosterone and estradiol secretion. Thus, we suggest that the GnRH system is not the only pathway for integration of cues into a gonadal response.'
41
+ }
42
+ end
43
+
44
+ it "should map the figures" do
45
+ nodes = body[:nodes]
46
+
47
+ nodes['figure:fig-1'].should == {
48
+ doi: '10.7717/peerj.139/fig-1',
49
+ id: 'figure:fig-1',
50
+ label: 'Figure 1',
51
+ type: 'figure',
52
+ url: 'https://peerj.com/articles/139/fig-1.png',
53
+ caption: {
54
+ title: 'Seasonal differences in response to corticosterone and metabolic stress in European starling (Sturnus vulgaris) testes.',
55
+ content: '(A) In testes collected from photostimulated male starlings, testosterone secretion is significantly increased in culture by incubation with LH/FSH compared to media alone. Corticosterone and the metabolic inhibitors 2DG/MA do not attenuate LH/FSH-stimulated testosterone levels in photostimulated starlings. (B) In testes collected from photosensitive male starlings, testosterone secretion is significantly increased in culture by incubation with LH/FSH compared to media alone. Corticosterone and the metabolic inhibitors 2DG/MA significantly attenuate LH/FSH-stimulated testosterone levels. Bars are mean testosterone secreted +- S.E.M. Different letters above columns indicate statistically significant differences.'
56
+ }
57
+ }
58
+ end
59
+
60
+ it "should map the annotation" do
61
+ nodes = body[:nodes]
62
+ nodes['annotation:1'].should == {
63
+ type: 'annotation',
64
+ content: 'Dawson et al., 2001',
65
+ id: 'annotation:1',
66
+ target: 'article:bib20',
67
+ source: 'text:1',
68
+ }
69
+
70
+ nodes['annotation:15'].should == {
71
+ type: 'annotation',
72
+ content: 'Calisi, Perfito & Bentley, 2010',
73
+ id: 'annotation:15',
74
+ target: 'article:bib16',
75
+ source: 'text:2',
76
+ }
77
+ end
78
+ end
@@ -0,0 +1,41 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Figure do
5
+ def figure
6
+ Jats::Figure.from_xml(fixture('figure.xml'))
7
+ end
8
+
9
+ it "should have the correct doi" do
10
+ figure.doi.should == '10.7717/peerj.139/fig-1'
11
+ end
12
+
13
+ it "should have the correct label" do
14
+ figure.label.should == 'Figure 1'
15
+ end
16
+
17
+ it "should have the correct url" do
18
+ figure.url.should == 'https://peerj.com/articles/139/fig-1.png'
19
+ end
20
+
21
+ it "should have the correct caption" do
22
+ figure.caption.should == {
23
+ title: 'Seasonal differences',
24
+ content: 'In testes collected from photostimulated male starlings.'
25
+ }
26
+ end
27
+
28
+ it "should return the correct attributes" do
29
+ figure.attributes.should == {
30
+ doi: '10.7717/peerj.139/fig-1',
31
+ label: 'Figure 1',
32
+ url: 'https://peerj.com/articles/139/fig-1.png',
33
+ caption: {
34
+ title: 'Seasonal differences',
35
+ content: 'In testes collected from photostimulated male starlings.'
36
+ }
37
+ }
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,65 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jats::Front do
4
+ def article
5
+ xml = fixture('peerj.xml')
6
+ Jats::Article.from_xml(xml)
7
+ end
8
+
9
+ describe "properties" do
10
+ def props
11
+ article[:properties]
12
+ end
13
+
14
+ it "should set the correct title" do
15
+ props[:title].should == 'The direct response of the gonads to cues of stress in a temperate songbird species is season-dependent'
16
+ end
17
+
18
+ it "should set the correct doi" do
19
+ props[:doi].should == '10.7717/peerj.139'
20
+ end
21
+
22
+ it "should set the correct history" do
23
+ props[:received_on].should == '2012-11-29'
24
+ props[:accepted_on].should == '2013-07-31'
25
+ props[:published_on].should == '2013-08-15'
26
+ end
27
+
28
+ it "should set the correct categories" do
29
+ props[:categories].should == [
30
+ 'Ecology', 'Zoology', 'Diabetes and Endocrinology'
31
+ ]
32
+ end
33
+
34
+ it "should set the authors" do
35
+ props[:authors].should == [
36
+ "person:author-1",
37
+ "person:author-2",
38
+ "person:author-3",
39
+ "person:editor-1"
40
+ ]
41
+ end
42
+
43
+ it "should set the authors affiliations" do
44
+ person = article[:nodes]['person:author-1'].to_hash
45
+ person[:affiliations].should == [
46
+ {
47
+ label: '1',
48
+ department: 'Laboratory of Reproductive Neuroendocrinology, Department of Integrative Biology',
49
+ address: 'University of California at Berkeley',
50
+ country: 'USA'
51
+ }
52
+ ]
53
+ end
54
+
55
+ it "should set the keywords" do
56
+ props[:keywords].should == [
57
+ 'Stress', 'Gonadotropin inhibitory hormone (GnIH)', 'Corticosterone',
58
+ 'Gonadotropin releasing hormone (GnRH)', 'Testes', 'Estradiol',
59
+ 'Testosterone', 'Avian', 'Supplementary cues', 'Photoperiod', 'Ovary'
60
+ ]
61
+ end
62
+ end
63
+
64
+ end
65
+
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Heading do
5
+ def heading
6
+ Jats::Heading.from_xml(fixture('heading.xml').at_css('sec[id="this-one"]'))
7
+ end
8
+
9
+ it "should have the correct content" do
10
+ heading.content.should == 'Materials and methods'
11
+ end
12
+
13
+ it "should have the correct level" do
14
+ heading.level.should == 2
15
+ end
16
+
17
+ it "should have the correct attributes" do
18
+ {
19
+ content: 'Materials and methods',
20
+ level: 2
21
+ }
22
+ end
23
+ end
24
+ end
25
+
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Node do
5
+ def node
6
+ Jats::Node.from_xml(fixture('text.xml'))
7
+ end
8
+
9
+ describe "indices" do
10
+ it "should return the correct index for a type" do
11
+ Node.index_for('moo').should == 1
12
+ Node.index_for('moo').should == 2
13
+ Node.index_for('zar').should == 1
14
+ end
15
+
16
+ it "should reset the indices correctly" do
17
+ Node.index_for('moo').should == 1
18
+ Node.index_for('moo').should == 2
19
+ Node.reset_indices
20
+ Node.index_for('moo').should == 1
21
+ end
22
+ end
23
+
24
+ it "should return the correct type" do
25
+ Node.new.type.should == 'node'
26
+ end
27
+
28
+ it "should have the correct name" do
29
+ node.name.should == 'node:1'
30
+ end
31
+
32
+ it "should have the correct attributes" do
33
+ node.attributes.should == {}
34
+ end
35
+
36
+ it "should cast to hash correctly" do
37
+ nod = node
38
+ nod.stub(:attributes).and_return({'attr' => 'value'})
39
+
40
+ nod.to_hash.should == {
41
+ 'node:1' => {
42
+ type: 'node',
43
+ id: 'node:1',
44
+ 'attr' => 'value'
45
+ }
46
+ }
47
+ end
48
+ end
49
+ end
50
+
@@ -0,0 +1,34 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Person do
5
+ def person
6
+ Jats::Person.from_xml(fixture('person.xml').at('contrib'))
7
+ end
8
+
9
+ it "should set the correct given_names" do
10
+ person.given_names.should == 'Nicolette L.'
11
+ end
12
+
13
+ it "should set the correct last_name" do
14
+ person.last_name.should == 'McGuire'
15
+ end
16
+
17
+ it "should set the correct role" do
18
+ person.role.should == 'author'
19
+ end
20
+
21
+ it "should set the correct aff_rids" do
22
+ person.affiliation_ids.should == ['aff-1']
23
+ end
24
+
25
+ it "should set the correct attributes" do
26
+ person.attributes.should == {
27
+ affiliations: [],
28
+ given_names: 'Nicolette L.',
29
+ last_name: 'McGuire',
30
+ role: 'author'
31
+ }
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module Jats
4
+ describe Text do
5
+ def text
6
+ Jats::Text.from_xml(fixture('text.xml'))
7
+ end
8
+
9
+ it "should return the correct content" do
10
+ text.content.should == 'Many seasonal breeders undergo seasonal cycles of gonadal growth and regression, accompanied by changes in sex steroid production and gamete maturation. (Dawson et al., 2001).'
11
+ end
12
+
13
+ it "should generate the correct annotations" do
14
+ text.annotations.size.should == 1
15
+ text.annotations.first.source.should == "text:2"
16
+ end
17
+
18
+ it "should return the correct attributes" do
19
+ text.attributes.should == {
20
+ content: 'Many seasonal breeders undergo seasonal cycles of gonadal growth and regression, accompanied by changes in sex steroid production and gamete maturation. (Dawson et al., 2001).'
21
+ }
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ require 'jats'
4
+
5
+ describe Jats do
6
+ end
7
+
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+ #
3
+ require 'jats'
4
+
5
+ require 'nokogiri'
6
+ require 'json'
7
+
8
+ def fixture(file)
9
+ doc = Nokogiri::XML(open("spec/fixtures/#{file}").read) do |config|
10
+ config.noblanks
11
+ end
12
+ end
13
+
14
+ RSpec.configure do |config|
15
+ config.treat_symbols_as_metadata_keys_with_true_values = true
16
+ config.run_all_when_everything_filtered = true
17
+ config.filter_run :focus
18
+
19
+ config.order = 'random'
20
+
21
+ config.before do
22
+ Jats::Node::reset_indices
23
+ end
24
+ end