taxonifi 0.3.4 → 0.3.5

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: 8a47e76270c05d20bb7414449757319b5af4a3c6
4
- data.tar.gz: fcb516b17b9da22f5962b01c0577a91b49abad30
3
+ metadata.gz: efd49fd749d76dd0908917d714c62bed112a4987
4
+ data.tar.gz: b7930e884f2cb2cfb7d8e5fdc67a74ccecdccd5a
5
5
  SHA512:
6
- metadata.gz: 7b9c31fdabfa563e59698be112bbf98859f0dd4ce12638c2b53d430a72b4b8961994b8a34f95cbfbf979ae98a97ab20317256ac59ba43d020aa7bcee38c92acf
7
- data.tar.gz: e468168cc2fe3bbbde2387443faba9f82a6baa5a8ae72396901015483801edcec9480f4ca7b6bb86c9a45a0b6a8dd83a37d31cbee8f89db6217c35b0e3557c63
6
+ metadata.gz: ddd9ef1022f9292b5fddce37b9252d4cea0206c731e120e26d36ccc9ead91d4a0bfdb62c69e65c786a6e69d04e385753af69683a3cfb0801bc13a256bbc6ffc4
7
+ data.tar.gz: 18ab6ba3076b826ccaf268d8b07efbcfde316480ae9b501c188d6cc35d68209c669689cc40945fadcd1c5d481060754f18e3e572adc77edf4784780499c4fb78
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- taxonifi (0.3.4)
4
+ taxonifi (0.3.5)
5
5
  byebug (~> 5.0)
6
6
  rake (~> 10.4)
7
7
  require_all (~> 1.3)
@@ -14,10 +14,10 @@ GEM
14
14
  byebug (5.0.0)
15
15
  columnize (= 0.9.0)
16
16
  columnize (0.9.0)
17
- did_you_mean (0.9.8)
17
+ did_you_mean (0.9.10)
18
18
  interception
19
19
  interception (0.5)
20
- json (1.8.2)
20
+ json (1.8.3)
21
21
  rake (10.4.2)
22
22
  rdoc (4.2.0)
23
23
  json (~> 1.4)
@@ -33,3 +33,6 @@ DEPENDENCIES
33
33
  did_you_mean (~> 0.9)
34
34
  rdoc (~> 4.2)
35
35
  taxonifi!
36
+
37
+ BUNDLED WITH
38
+ 1.10.6
data/lib/taxonifi.rb CHANGED
@@ -30,10 +30,8 @@ module Taxonifi
30
30
  species
31
31
  subspecies
32
32
  variety
33
-
34
33
  }
35
34
 
36
35
  require_rel 'taxonifi'
37
36
 
38
-
39
37
  end
@@ -52,7 +52,7 @@ module Taxonifi::Lumper
52
52
  end
53
53
 
54
54
 
55
- # Return a Taxonifi::Model::NameCollection from a csv file.
55
+ # return [Taxonifi::Model::NameCollection] from a csv file.
56
56
  def self.create_name_collection(options = {})
57
57
  opts = {
58
58
  :csv => [],
@@ -159,7 +159,7 @@ module Taxonifi::Lumper
159
159
  nc
160
160
  end
161
161
 
162
- # Return a Taxonifi::Model::RefCollection from a CSV file.
162
+ # return [Taxonifi::Model::RefCollection] from a CSV file.
163
163
  def self.create_ref_collection(options = {})
164
164
  opts = {
165
165
  :csv => nil,
@@ -119,8 +119,17 @@ module Taxonifi
119
119
  @parent = parent
120
120
  end
121
121
 
122
- # Returns a formatted string, including parens for the name
122
+ # Returns just the name and author year, no parens, no parents.
123
+ # Like:
124
+ # foo Smith, 1927
125
+ # Foo Smith, 1927
126
+ # Fooidae
127
+ def name_author_year_string
128
+ [name, author_year_string].compact.join(" ")
129
+ end
130
+
123
131
  # TODO: rename to reflect parens
132
+ # return [String] an author/year string, including parens for the name
124
133
  def author_year
125
134
  au = author_year_string
126
135
  return nil if au.nil?
@@ -128,25 +137,34 @@ module Taxonifi
128
137
  end
129
138
 
130
139
 
131
- # Return the author year string.
132
- def author_year_string
133
- # Build based on People
140
+ # return [String] an author string, including parens for the name
141
+ def author_with_parens
142
+ au = author_string
143
+ return nil if au.nil?
144
+ (self.parens == true) ? "(#{au})" : au
145
+ end
134
146
 
147
+ # return [String] an author string
148
+ def author_string
135
149
  auth = nil
136
- if authors.size > 0
150
+ if authors.size > 0 # Build based on People
137
151
  case authors.size
138
152
  when 1
139
- auth = self.author
153
+ auth = authors.first.last_name # self.author
140
154
  when 2
141
155
  auth = authors.map(&:last_name).join(" & ")
142
- when 2...100
156
+ when 3...100
143
157
  auth = authors[0..-1].map(&:last_name).join(", ") + " & " + authors.last.last_name
144
158
  end
145
- # Build based on string
146
- else
159
+ else # Build based on string
147
160
  auth = self.author
148
161
  end
149
- au = [auth, self.year].compact.join(", ")
162
+ auth
163
+ end
164
+
165
+ # Return the author year string.
166
+ def author_year_string
167
+ au = [author_string, self.year].compact.join(", ")
150
168
  return nil if au.size == 0
151
169
  au
152
170
  end
@@ -196,15 +214,6 @@ module Taxonifi
196
214
  def genus_group_parent
197
215
  [ parent_at_rank('subgenus'), parent_at_rank('genus')].compact.first
198
216
  end
199
-
200
- # Returns just the name and author year, no parens, no parents.
201
- # Like:
202
- # foo Smith, 1927
203
- # Foo Smith, 1927
204
- # Fooidae
205
- def name_author_year_string
206
- [name, author_year_string].compact.join(" ")
207
- end
208
217
 
209
218
  # Return the name of a parent at a given rank.
210
219
  # TODO: move method to Base?
@@ -1,3 +1,3 @@
1
1
  module Taxonifi
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -85,7 +85,7 @@ class Test_TaxonifiLumperNames < Test::Unit::TestCase
85
85
  string = CSV.generate() do |csv|
86
86
  csv << %w{family genus species author_year}
87
87
  csv << ["Fooidae", "Foo", "bar", "Smith, 1854"]
88
- csv << ["Fooidae", "Foo", "foo", "(Smith, 1854)"]
88
+ csv << ["Fooidae", "Foo", "foo", "(Smith and Jones, 1854)"]
89
89
  end
90
90
 
91
91
  # 0 Fooidae
@@ -95,9 +95,15 @@ class Test_TaxonifiLumperNames < Test::Unit::TestCase
95
95
 
96
96
  csv = CSV.parse(string, {headers: true})
97
97
  nc = Taxonifi::Lumper.create_name_collection(:csv => csv)
98
- assert_equal 1, nc.collection[3].authors.size
98
+ assert_equal 2, nc.collection[3].authors.size
99
99
  assert_equal 'Smith', nc.collection[3].authors.first.last_name
100
100
  assert_equal 1854, nc.collection[3].year
101
+
102
+ assert_equal 'Smith, 1854', nc.collection[2].author_year
103
+ assert_equal 'Smith', nc.collection[2].author_with_parens
104
+
105
+ assert_equal '(Smith & Jones, 1854)', nc.collection[3].author_year
106
+ assert_equal '(Smith & Jones)', nc.collection[3].author_with_parens
101
107
 
102
108
  # Name only applies to the "last" name in the order.
103
109
  assert_equal nil, nc.collection[0].author
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: taxonifi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - mjy