ols 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,7 +1,14 @@
1
+ === 0.3.3 2011-11-11
2
+
3
+ * Minor cache modification - hold the marshaled strings in ram rather than repeadedly
4
+ read off disk. This should ease pain when there are lots of concurrent requests to
5
+ a slow file system.
6
+
1
7
  === 0.3.2 2011-11-09
2
8
 
3
9
  * Bugfix - the term_name was getting lost off of the new nodes when we merged two graphs.
4
- * Small feature enhancement - when printing the graph to stdout, add an option to print out the term_name too.
10
+ * Small feature enhancement - when printing the graph to stdout, add an option to print
11
+ out the term_name too.
5
12
 
6
13
  === 0.3.1 2011-11-08
7
14
 
data/README.rdoc CHANGED
@@ -12,16 +12,16 @@ It provides an easy lookup of ontology terms and automagically builds up ontolog
12
12
  == Basic Usage
13
13
 
14
14
  Include the module in your code:
15
-
15
+
16
16
  require 'rubygems'
17
17
  require 'ols'
18
-
18
+
19
19
  Then, to lookup an ontology term:
20
-
20
+
21
21
  ont = OLS.find_by_id('EMAP:3018')
22
-
22
+
23
23
  This will create a simple tree object for the EMAP term EMAP:3018
24
-
24
+
25
25
  ont.term_id # => "EMAP:3018"
26
26
  ont.term_name # => "TS18,nose"
27
27
 
@@ -142,4 +142,5 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
142
142
  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
143
143
  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
144
144
  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
145
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
145
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
146
+
data/lib/ols/cache.rb CHANGED
@@ -23,10 +23,10 @@ module OLS
23
23
  # @return [OLS::Term] The found OLS::Term object or +nil+
24
24
  def find_by_id(term_id)
25
25
  found_term = nil
26
- filename = @term_id_to_files[term_id].to_s
26
+ filename = @term_id_to_files[term_id]
27
27
 
28
28
  unless filename.nil? || filename.empty?
29
- root_term = Marshal.load( File.open("#{@cache_directory}/#{filename}") )
29
+ root_term = Marshal.load( @the_cache[filename] )
30
30
  found_term = root_term.send(:find_in_graph,term_id)
31
31
  end
32
32
 
@@ -49,7 +49,7 @@ module OLS
49
49
 
50
50
  new_filenames = []
51
51
 
52
- OLS.root_terms(ontology).each do |term|
52
+ OLS.root_terms(ontology).each do |term|
53
53
  term_filename = "#{term.term_id.gsub(':','')}.marshal"
54
54
  term.focus_graph!
55
55
  File.open("#{@cache_directory}/#{term_filename}",'w') { |f| f << Marshal.dump(term) }
@@ -93,6 +93,7 @@ module OLS
93
93
  def prepare_cache
94
94
  @cached_ontologies = {}
95
95
  @term_id_to_files = {}
96
+ @the_cache = {}
96
97
 
97
98
  Dir.mkdir(@cache_directory) unless Dir.exists?(@cache_directory)
98
99
 
@@ -100,8 +101,11 @@ module OLS
100
101
 
101
102
  @cached_ontologies.each do |ontology,details|
102
103
  details[:filenames].each do |filename|
103
- root_term = Marshal.load( File.open("#{@cache_directory}/#{filename}") )
104
+ file_contents = File.new("#{@cache_directory}/#{filename}",'rb').read
105
+ root_term = Marshal.load( file_contents )
104
106
  next unless root_term.is_a? OLS::Term
107
+
108
+ @the_cache[ filename.to_sym ] = file_contents
105
109
  @term_id_to_files[ root_term.term_id ] = filename.to_sym
106
110
  root_term.all_child_ids.each { |term_id| @term_id_to_files[term_id] = filename.to_sym }
107
111
  end
data/lib/ols/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module OLS
4
4
  # OLS::VERSION - The OLS gem version
5
- VERSION = "0.3.2"
5
+ VERSION = "0.3.3"
6
6
  end
data/test/test_helper.rb CHANGED
@@ -43,7 +43,8 @@ VCR.config do |c|
43
43
  c.stub_with :webmock
44
44
  c.ignore_localhost = true
45
45
  c.default_cassette_options = {
46
- :record => :new_episodes,
47
- :match_requests_on => [:uri, :method, :body]
46
+ :record => :new_episodes,
47
+ :re_record_interval => 604800, # 7 days in seconds
48
+ :match_requests_on => [:uri, :method, :body]
48
49
  }
49
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ols
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-09 00:00:00.000000000 Z
12
+ date: 2011-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: savon
16
- requirement: &2156771440 !ruby/object:Gem::Requirement
16
+ requirement: &2153022560 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2156771440
24
+ version_requirements: *2153022560
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &2156771000 !ruby/object:Gem::Requirement
27
+ requirement: &2153022120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2156771000
35
+ version_requirements: *2153022120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &2156770580 !ruby/object:Gem::Requirement
38
+ requirement: &2153021700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2156770580
46
+ version_requirements: *2153021700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: vcr
49
- requirement: &2156770160 !ruby/object:Gem::Requirement
49
+ requirement: &2153021280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2156770160
57
+ version_requirements: *2153021280
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: webmock
60
- requirement: &2156769740 !ruby/object:Gem::Requirement
60
+ requirement: &2153020860 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *2156769740
68
+ version_requirements: *2153020860
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
- requirement: &2156769320 !ruby/object:Gem::Requirement
71
+ requirement: &2153020440 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *2156769320
79
+ version_requirements: *2153020440
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov-rcov
82
- requirement: &2156768900 !ruby/object:Gem::Requirement
82
+ requirement: &2153020020 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *2156768900
90
+ version_requirements: *2153020020
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: mocha
93
- requirement: &2156768480 !ruby/object:Gem::Requirement
93
+ requirement: &2153019600 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,7 +98,7 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *2156768480
101
+ version_requirements: *2153019600
102
102
  description: ! "\n OLS provides a simple interface to the EBI's Ontology Lookup
103
103
  Service (http://www.ebi.ac.uk/ontology-lookup/).\n It provides an easy lookup
104
104
  of ontology terms and automagically builds up ontology trees for you.\n "