shapkeep 0.1.1 → 0.2.0

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: 42a409d68391b2cd3a73f0ff77a34461e480ba9f
4
- data.tar.gz: 4698ba91202caf2f00258adf5d5d5e64f24abd38
3
+ metadata.gz: 951c93596aa79ede4f7e34b0441173b20d1044c4
4
+ data.tar.gz: 83a0d9c01ae1545d2fc7edbd55a24cd59f58783d
5
5
  SHA512:
6
- metadata.gz: 12e8131fa44874503d0b98c69d8198a7df4e85dff8733f9731e9397396ac8581b406c76d0707611725ca6a441f8425df73f31afb4cb9eec8fe1e8c53a41dd655
7
- data.tar.gz: 16e81ec97d51b03911bb3c31d92ebed3b00472e60efcc622ebca8531ddceb86c781b26564ddab77172f250d62a3aaf27a36a78fd87debfa91ca044329e1fea9b
6
+ metadata.gz: 2d4555f19fc6c4c5bb77bd1cc142f986b99e8d5e33c68fa0c04036692d48cc67cd241a258d9c7c92df200b4135b468c10b68a310d5c4f7baad94e921fca3bfc7
7
+ data.tar.gz: b840c5d5a614dfaf4216884be29245fcc08e9131933adc1cd9c774439ee2e5824b676575169fdc7ba016c771968ca7ff079ad6fc32f1e15d410f04b8939cf572
@@ -4,10 +4,12 @@ require 'shapkeep/version'
4
4
  class Shapkeep
5
5
  InvalidScriptNameError = Class.new(StandardError)
6
6
 
7
+ attr_accessor :lua_root
7
8
  attr_reader :sha_file
8
9
 
9
10
  def initialize(sha_file)
10
11
  @sha_file = sha_file
12
+ @lua_root = script_store.delete(:lua_root) { Dir.pwd }
11
13
  end
12
14
 
13
15
  def eval(redis, name, keys = [], args = [])
@@ -49,7 +51,7 @@ class Shapkeep
49
51
 
50
52
  return potential_script unless lua_filename?(potential_script)
51
53
 
52
- File.read(potential_script)
54
+ File.read(File.join(lua_root, potential_script))
53
55
  end
54
56
 
55
57
  def lua_filename?(string)
@@ -1,3 +1,3 @@
1
1
  class Shapkeep
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -0,0 +1,8 @@
1
+ ---
2
+ :lua_root: /dev/null/
3
+ :zero:
4
+ :script: return 0
5
+ :one:
6
+ :script: return 1
7
+ :file:
8
+ :script: spec/fixtures/return_two.lua
@@ -21,6 +21,22 @@ describe Shapkeep do
21
21
  end
22
22
  end
23
23
 
24
+ describe 'lua_root' do
25
+ context 'loads from yaml' do
26
+ subject { Shapkeep.new('spec/fixtures/store_with_lua_root.yml') }
27
+ specify { expect(subject.lua_root).to eq('/dev/null/') }
28
+ specify { expect(subject.script_store.has_key?(:lua_root)).to be_false }
29
+ end
30
+
31
+ it 'loads scripts from there' do
32
+ subject.lua_root = Dir.pwd
33
+ expect(subject.send(:script_for_name, :file)).to be_a(String)
34
+
35
+ subject.lua_root = '/tmp'
36
+ expect(-> {subject.send(:script_for_name, :file)}).to raise_error(Errno::ENOENT)
37
+ end
38
+ end
39
+
24
40
  describe 'eval' do
25
41
  context 'invalid script name' do
26
42
  specify do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shapkeep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - j-wilkins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-08-08 00:00:00.000000000 Z
11
+ date: 2013-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis
@@ -100,6 +100,7 @@ files:
100
100
  - spec/fixtures/return_two.lua
101
101
  - spec/fixtures/store.yml
102
102
  - spec/fixtures/store_error.yml
103
+ - spec/fixtures/store_with_lua_root.yml
103
104
  - spec/shapkeep/wrapper_spec.rb
104
105
  - spec/shapkeep_spec.rb
105
106
  - spec/spec_helper.rb
@@ -131,6 +132,7 @@ test_files:
131
132
  - spec/fixtures/return_two.lua
132
133
  - spec/fixtures/store.yml
133
134
  - spec/fixtures/store_error.yml
135
+ - spec/fixtures/store_with_lua_root.yml
134
136
  - spec/shapkeep/wrapper_spec.rb
135
137
  - spec/shapkeep_spec.rb
136
138
  - spec/spec_helper.rb