qspec 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -60,6 +60,24 @@ bundle exec qspec-helper spork
60
60
  bundle exec qspec spec/
61
61
  ```
62
62
 
63
+ ## Configuration
64
+
65
+ All configuration is done through `.qspec.yml`.
66
+ `qspec-helper init` will generate the template, but there are more options.
67
+
68
+ ### redis
69
+
70
+ This option is given to redis's constructor.
71
+ See [redis-rb/README.md](https://github.com/redis/redis-rb/blob/master/README.md) for more details.
72
+
73
+ ```yaml
74
+ redis:
75
+ host: localhost
76
+ port: 6379
77
+ namespace: qspec
78
+ driver: hiredis
79
+ ```
80
+
63
81
  ## Contributing
64
82
 
65
83
  1. Fork it
@@ -9,7 +9,7 @@ require 'qspec/config'
9
9
  require 'qspec/helper'
10
10
 
11
11
  module Qspec
12
- DIRECTORY = File.expand_path('tmp/qspec')
12
+ DIRECTORY = File.expand_path(Config.new['tmp_directory'] || 'tmp/qspec')
13
13
 
14
14
  FileUtils.mkdir_p(DIRECTORY) unless FileTest.exists?(DIRECTORY)
15
15
 
@@ -8,7 +8,7 @@ module Qspec
8
8
 
9
9
  def initialize(options)
10
10
  @config = Config.new()
11
- @ipc = IPC.from_config(@config['ipc'])
11
+ @ipc = IPC.from_config(@config)
12
12
  @id = ENV['qspec_id']
13
13
 
14
14
  super(options)
@@ -32,6 +32,7 @@ ipc: file # 'file' or 'redis', if 'redis', gem and server are required
32
32
  sort_by: time # 'time' or 'size', if 'time', store execution time and use it next time
33
33
  workers: 4 # half of cpu - number of cpu
34
34
  spork_port: 9240 # specified port..port+N-1 are used
35
+ tmp_directory: tmp/qspec # the root directory for temporary files. relative or absolute
35
36
  TMPL
36
37
  end
37
38
  puts "Config file created in #{path}. Check it before run `qspec spec`."
@@ -1,15 +1,16 @@
1
1
  module Qspec
2
2
  # abstract
3
3
  class IPC
4
- def self.from_config(name)
4
+ def self.from_config(config)
5
+ name = config['ipc']
5
6
  @@default =
6
7
  case name
7
8
  when 'redis'
8
9
  require 'qspec/ipc/redis'
9
- IPC::Redis.new
10
+ IPC::Redis.new(config['redis'])
10
11
  when 'file', nil
11
12
  require 'qspec/ipc/file'
12
- IPC::File.new
13
+ IPC::File.new(config['file'])
13
14
  else
14
15
  raise "Unknown IPC method #{name}"
15
16
  end
@@ -3,10 +3,7 @@ require 'fileutils'
3
3
  module Qspec
4
4
  class IPC
5
5
  class File < IPC
6
- DIRECTORY = 'tmp/qspec'
7
-
8
- def initialize
9
- FileUtils.mkdir_p(DIRECTORY) unless FileTest.exists?(DIRECTORY)
6
+ def initialize(config)
10
7
  end
11
8
 
12
9
  def del(key)
@@ -2,13 +2,16 @@ require 'redis'
2
2
  module Qspec
3
3
  class IPC
4
4
  class Redis < IPC
5
- def initialize
6
- @redis = ::Redis.new
5
+ def initialize(config)
6
+ config ||= {}
7
+ @redis = ::Redis.new(config)
8
+ @namespace = config['namespace'] || 'qspec'
7
9
  end
8
10
 
9
11
  [:del, :lpop, :rpush, :llen].each do |method|
10
12
  define_method(method) do |*args|
11
- @redis.send(method, *args)
13
+ key = args.shift
14
+ @redis.send(method, "#{@namespace}:#{key}", *args)
12
15
  end
13
16
  end
14
17
  end
@@ -1,3 +1,3 @@
1
1
  module Qspec
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
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-06-01 00:00:00.000000000 Z
12
+ date: 2013-06-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-core
@@ -71,7 +71,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
71
  version: '0'
72
72
  segments:
73
73
  - 0
74
- hash: -177445891
74
+ hash: 698092429
75
75
  required_rubygems_version: !ruby/object:Gem::Requirement
76
76
  none: false
77
77
  requirements:
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
80
80
  version: '0'
81
81
  segments:
82
82
  - 0
83
- hash: -177445891
83
+ hash: 698092429
84
84
  requirements: []
85
85
  rubyforge_project:
86
86
  rubygems_version: 1.8.23