ruby-quilt 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/quilt.rb +7 -2
  2. metadata +2 -2
data/lib/quilt.rb CHANGED
@@ -4,6 +4,7 @@ require 'net/http'
4
4
  require 'popen4'
5
5
  require 'fileutils'
6
6
  require 'ecology'
7
+ require "#{File.join(File.dirname(__FILE__), "lru_cache")}"
7
8
 
8
9
  class Quilt
9
10
  HEADER_KEY = "header"
@@ -14,14 +15,14 @@ class Quilt
14
15
  DEBUG_PREFIX_KEY = "debug_prefix"
15
16
  ARCHIVE_SUFFIX = ".tgz"
16
17
 
17
- def initialize(config = "quilt", log = Logger.new(STDOUT))
18
+ def initialize(config = "quilt", size = 10, log = Logger.new(STDOUT))
18
19
  @config = {
19
20
  :local_path => Ecology.property("#{config ? "#{config}:" : ""}local_path"),
20
21
  :remote_host => Ecology.property("#{config ? "#{config}:" : ""}remote_host"),
21
22
  :remote_path => Ecology.property("#{config ? "#{config}:" : ""}remote_path"),
22
23
  :remote_port => Ecology.property("#{config ? "#{config}:" : ""}remote_port")
23
24
  };
24
- @versions = {};
25
+ @versions = LRUCache.new(size)
25
26
  @log = log
26
27
 
27
28
  if (@config[:local_path])
@@ -186,6 +187,10 @@ class Quilt
186
187
 
187
188
  def get_version(name)
188
189
  return @versions[name] if @versions[name]
190
+ # check local path
191
+ @versions[name] = load_version(@config[:local_path], name)
192
+ return @versions[name] if @versions[name]
193
+ # check remote path
189
194
  if (!@config[:remote_host] || !@config[:remote_path])
190
195
  log_error("unable to load from host: #{@config[:remote_host]}, path: #{@config[:remote_path]}")
191
196
  return nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-quilt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
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: 2012-04-30 00:00:00.000000000 Z
12
+ date: 2012-05-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json