lcclasses 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.0
1
+ 0.0.1
data/lcclasses.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{lcclasses}
8
- s.version = "0.0.0"
8
+ s.version = "0.0.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Melody"]
12
- s.date = %q{2010-02-25}
12
+ s.date = %q{2010-02-26}
13
13
  s.description = %q{Library of Congress Classification classes and subclasses}
14
14
  s.email = %q{hi@williammelody.com}
15
15
  s.extra_rdoc_files = [
data/lib/lcclasses.rb CHANGED
@@ -386,6 +386,10 @@ module LCClasses
386
386
  LCClasses::LCClass.flatten(LCClasses::CLASS_HASH)
387
387
  end
388
388
 
389
+ def self.find_by_code(code)
390
+ LCClasses.flat.detect { |i| i[0] == code.to_s }
391
+ end
392
+
389
393
  # Find an main classe by code.
390
394
  def self.find_main_class_by_code(code)
391
395
  LCClasses.main_classes.detect { |i| i[0] == code.to_s }
@@ -395,7 +399,7 @@ module LCClasses
395
399
  def self.find_subclass_by_code(code)
396
400
  LCClasses.subclasses.detect { |i| i[0] == code.to_s }
397
401
  end
398
-
402
+
399
403
  # Find all main classes and subclass that match or start with a code or character.
400
404
  def self.find_all_by_code(code)
401
405
  LCClasses.flat.select { |i| i[0] if (i[0] =~ /^#{code}[A-Z]?[A-Z]?/) }
@@ -19,8 +19,13 @@ class TestLCClasses < Test::Unit::TestCase
19
19
  assert_equal 223, LCClasses.nested.inject([]) { |r, m| r += m.subclasses }.length
20
20
  end
21
21
 
22
+ should "find main class or subclass by code" do
23
+ assert_equal ["T", "Technology"], LCClasses.find_by_code("T")
24
+ assert_equal ["AM", "Museums. Collectors and collecting"], LCClasses.find_by_code("AM")
25
+ end
26
+
22
27
  should "find main class by code" do
23
- assert_equal ["T", "Technology (General)"], LCClasses.find_subclass_by_code("T")
28
+ assert_equal ["T", "Technology"], LCClasses.find_main_class_by_code("T")
24
29
  end
25
30
 
26
31
  should "find subclass by code" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lcclasses
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Melody
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-02-25 00:00:00 -06:00
12
+ date: 2010-02-26 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency