pollex 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 4/2/2013 version 0.2.0
2
+ * SemanticField changes
3
+ * code -> id
4
+ * find -> find_by_name
5
+ * New method: id - returns Pollex's internal ID
6
+ * New method: self.find - finds SemanticField by id
7
+
1
8
  3/28/2013 version 0.1.1
2
9
  * Source.grammar now includes information on all Pollex sources
3
10
 
@@ -3,8 +3,13 @@ module Pollex
3
3
  class SemanticField < PollexObject
4
4
  extend PollexClass
5
5
 
6
- attr_accessor :id, :name, :path, :count
7
- attr_inspector :id, :name, :count, :path
6
+ attr_accessor :code, :name, :path, :count
7
+ attr_inspector :id, :code, :name, :count, :path
8
+
9
+ # @return [Integer] Pollex's internal ID for this SemanticField
10
+ def id
11
+ @path.split('/').last.to_i
12
+ end
8
13
 
9
14
  # Returns all Reconstructions corresponding to this SemanticField
10
15
  # @return [Array<Reconstruction>] array of Reconstructions corresponding to this SemanticField
@@ -21,7 +26,7 @@ module Pollex
21
26
  # @return [Array<SemanticField>] array of SemanticFields in Pollex
22
27
  def self.all
23
28
  @semantic_fields ||= Scraper.instance.get_all(SemanticField, "/category/", [
24
- [:id, 'td[1]/a/text()'],
29
+ [:code, 'td[1]/a/text()'],
25
30
  [:path, 'td[1]/a/@href'],
26
31
  [:name, 'td[2]/a/text()'],
27
32
  [:count, 'td[3]/text()']
@@ -34,12 +39,19 @@ module Pollex
34
39
  self.all.count
35
40
  end
36
41
 
42
+ # Looks up SemanticField corresponding to a given internal ID
43
+ # @param id [Integer] ID of SemanticField to find
44
+ # @return [SemanticField]
45
+ def self.find(id)
46
+ self.all.select { |sf| sf.id == id }
47
+ end
48
+
37
49
  # Looks up all SemanticFields matching a given name.
38
50
  # @note Pollex has no built-in search for SemanticFields, so this method is
39
51
  # simply a filter over SemanticField.all.
40
52
  # @param name [String] term to search for
41
53
  # @return [Array<SemanticField>] array of SemanticFields matching the search term
42
- def self.find(name)
54
+ def self.find_by_name(name)
43
55
  self.all.select { |sf| sf.name.downcase.include?(name.downcase) }
44
56
  end
45
57
  end
@@ -1,3 +1,3 @@
1
1
  module Pollex
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pollex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-28 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  version: '0'
116
116
  requirements: []
117
117
  rubyforge_project:
118
- rubygems_version: 1.8.25
118
+ rubygems_version: 1.8.23
119
119
  signing_key:
120
120
  specification_version: 3
121
121
  summary: Ruby wrapper for scraping pollex (the Polynesian Lexicon Project)