shinq 0.0.1.alpha1 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.travis.yml +9 -0
- data/README.md +1 -0
- data/lib/shinq/active_job/queue_adapters/shinq_adapter.rb +5 -1
- data/lib/shinq/cli.rb +49 -20
- data/lib/shinq/client.rb +19 -17
- data/lib/shinq/configuration.rb +29 -0
- data/lib/shinq/launcher.rb +19 -13
- data/lib/shinq/rails.rb +2 -2
- data/lib/shinq.rb +16 -15
- data/shinq.gemspec +7 -2
- data/spec/config/database.yml +5 -0
- data/spec/integration_spec.rb +27 -0
- data/spec/shinq/configuration_spec.rb +84 -0
- data/spec/shinq_spec.rb +61 -0
- data/spec/spec_helper.rb +33 -0
- metadata +91 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1e0ce04e84f65b1a4401c166bc1daad509cb36
|
4
|
+
data.tar.gz: bd849b20febda4bbfe700f868ef7e07ed89f0d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c8e957282f8d504a6b528b73dd8c84b8039f9138443bfd82bc7e24ddfa54d6e342dfc20ca1b3aeeb968a3396ad9220d35b7787d3f76b8cc63411293a9b348f8d
|
7
|
+
data.tar.gz: a7478a1c53b357671f3ba197c3d3d57139865abb33c448f9d70dfdea093d33f36423cd7f58dc2cb6133444f9507c21a9651f855a56231959658a94d1fc6d891a
|
data/.rspec
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
- 2.1
|
4
|
+
gemfile:
|
5
|
+
- Gemfile
|
6
|
+
before_install:
|
7
|
+
- mysql -e "create database IF NOT EXISTS shinq_test;" -uroot
|
8
|
+
- mysql -e "use shinq_test; create table queue_test (job_id varchar(255) not null, title varchar(255), enqueued_at datetime not null) ENGINE=QUEUE;" -uroot
|
9
|
+
script: bundle exec rspec
|
data/README.md
CHANGED
@@ -3,7 +3,11 @@ module ActiveJob
|
|
3
3
|
class ShinqAdapter
|
4
4
|
class << self
|
5
5
|
def enqueue(job)
|
6
|
-
Shinq::Client.enqueue(
|
6
|
+
Shinq::Client.enqueue(
|
7
|
+
table_name: job.queue_name,
|
8
|
+
job_id: job.job_id,
|
9
|
+
args: job.arguments.first
|
10
|
+
)
|
7
11
|
end
|
8
12
|
end
|
9
13
|
end
|
data/lib/shinq/cli.rb
CHANGED
@@ -2,65 +2,94 @@ require 'optparse'
|
|
2
2
|
require 'yaml'
|
3
3
|
require 'shinq'
|
4
4
|
require 'shinq/launcher'
|
5
|
+
require 'shinq/configuration'
|
6
|
+
require 'serverengine'
|
5
7
|
|
6
8
|
module Shinq
|
7
9
|
class OptionParseError < StandardError; end
|
8
10
|
|
9
11
|
class CLI
|
10
12
|
def initialize(args=ARGV)
|
11
|
-
|
12
|
-
setup_db_config
|
13
|
+
setup_option(args)
|
13
14
|
bootstrap
|
14
15
|
end
|
15
16
|
|
17
|
+
def setup_option(args)
|
18
|
+
opts = parse_options(args)
|
19
|
+
|
20
|
+
Shinq.configuration = Shinq::Configuration.new(opts)
|
21
|
+
end
|
22
|
+
|
16
23
|
def parse_options(args)
|
17
|
-
|
24
|
+
opts = {}
|
18
25
|
parser = OptionParser.new do |opt|
|
19
|
-
opt.on('
|
20
|
-
|
26
|
+
opt.on('-d', '--daemon') do |v|
|
27
|
+
opts[:daemonize] = v
|
28
|
+
end
|
29
|
+
|
30
|
+
opt.on('--worker value') do |v|
|
31
|
+
opts[:worker_name] = v
|
32
|
+
end
|
33
|
+
|
34
|
+
opt.on('--process VALUE') do |v|
|
35
|
+
opts[:process] = v.to_i
|
36
|
+
end
|
37
|
+
|
38
|
+
opt.on('--queue-timeout VALUE') do |v|
|
39
|
+
opts[:queue_timeout] = v.to_i
|
21
40
|
end
|
22
41
|
|
23
42
|
opt.on('--db-config VALUE') do |v|
|
24
43
|
raise OptionParseError, "#{v} does not exist" unless File.exist?(v)
|
25
|
-
|
44
|
+
opts[:db_config] = YAML.load_file(v)
|
26
45
|
end
|
27
46
|
|
28
47
|
opt.on('--queue-database VALUE') do |v|
|
29
|
-
raise OptionParseError, "#{v}'s settings does not exist" unless
|
30
|
-
|
31
|
-
@opts[:queue_db_settings] = @opts[:db_config][v]
|
48
|
+
raise OptionParseError, "#{v}'s settings does not exist" unless opts[:db_config][v]
|
49
|
+
opts[:queue_db] = v
|
32
50
|
end
|
33
51
|
|
34
52
|
opt.on('--require VALUE') do |v|
|
35
|
-
|
53
|
+
opts[:require] = v
|
54
|
+
end
|
55
|
+
|
56
|
+
opt.on('-v', '--version') do |v|
|
57
|
+
puts "Shinq #{Shinq::VERSION}"
|
58
|
+
exit(0)
|
36
59
|
end
|
37
60
|
end
|
38
61
|
|
39
62
|
parser.parse!(args)
|
40
|
-
|
63
|
+
opts
|
41
64
|
end
|
42
65
|
|
43
|
-
def
|
44
|
-
Shinq.
|
45
|
-
Shinq.db_config = @opts[:db_config]
|
66
|
+
def options
|
67
|
+
Shinq.configuration
|
46
68
|
end
|
47
69
|
|
48
70
|
def bootstrap
|
49
|
-
|
71
|
+
target = options.require
|
50
72
|
|
51
|
-
if File.directory?(
|
73
|
+
if File.directory?(target)
|
52
74
|
require 'rails'
|
53
|
-
require File.expand_path("#{
|
75
|
+
require File.expand_path("#{target}/config/application.rb")
|
54
76
|
|
55
77
|
require 'shinq/rails'
|
56
|
-
require File.expand_path("#{
|
78
|
+
require File.expand_path("#{target}/config/environment.rb")
|
57
79
|
else
|
58
|
-
require
|
80
|
+
require target
|
59
81
|
end
|
60
82
|
end
|
61
83
|
|
62
84
|
def run
|
63
|
-
Shinq::Launcher
|
85
|
+
se = ServerEngine.create(nil, Shinq::Launcher, {
|
86
|
+
daemonize: options.daemonize,
|
87
|
+
worker_type: 'process',
|
88
|
+
pid_file: 'shinq.pid',
|
89
|
+
workers: options.process
|
90
|
+
})
|
91
|
+
|
92
|
+
se.run
|
64
93
|
end
|
65
94
|
end
|
66
95
|
end
|
data/lib/shinq/client.rb
CHANGED
@@ -1,36 +1,38 @@
|
|
1
1
|
require 'sql-maker'
|
2
|
+
require 'sql/maker/quoting'
|
3
|
+
require 'active_support/core_ext/hash/keys'
|
2
4
|
|
3
5
|
module Shinq
|
4
6
|
class Client
|
5
7
|
def self.builder
|
6
|
-
@builder ||= SQL::Maker.new(driver: 'mysql')
|
8
|
+
@builder ||= SQL::Maker.new(driver: 'mysql', auto_bind: true)
|
7
9
|
end
|
8
10
|
|
9
|
-
def self.enqueue(table_name: , args:)
|
11
|
+
def self.enqueue(table_name: , job_id: , args:)
|
10
12
|
case args
|
11
13
|
when Hash
|
12
|
-
sql
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
Shinq.connection.xquery(sql, bind)
|
19
|
-
end
|
14
|
+
sql = builder.insert(table_name, args.merge(
|
15
|
+
job_id: job_id,
|
16
|
+
enqueued_at: Time.now
|
17
|
+
))
|
18
|
+
Shinq.connection.query(sql)
|
20
19
|
else
|
21
|
-
raise ArgumentError, "
|
20
|
+
raise ArgumentError, "Queue should be Hash"
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
def self.dequeue(table_name:)
|
26
|
-
|
25
|
+
quoted = SQL::Maker::Quoting.quote(table_name)
|
26
|
+
queue_timeout_quoted = SQL::Maker::Quoting.quote(Shinq.configuration.queue_timeout)
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
results = Shinq.connection.xquery(sql)
|
31
|
-
end
|
28
|
+
wait_query = "queue_wait(#{quoted}, #{queue_timeout_quoted})"
|
29
|
+
has_queue = Shinq.connection.query("select #{wait_query}").first
|
32
30
|
|
33
|
-
|
31
|
+
unless has_queue[wait_query].to_i == 0
|
32
|
+
sql = builder.select(table_name, ['*'])
|
33
|
+
results = Shinq.connection.query(sql)
|
34
|
+
return results.first.symbolize_keys
|
35
|
+
end
|
34
36
|
end
|
35
37
|
|
36
38
|
def self.done
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Shinq
|
2
|
+
class ConfigurationError < StandardError; end
|
3
|
+
|
4
|
+
class Configuration
|
5
|
+
attr_accessor :require, :worker_name, :db_config, :queue_db, :default_db, :process, :queue_timeout, :daemonize
|
6
|
+
|
7
|
+
DEFAULT = {
|
8
|
+
require: '.',
|
9
|
+
process: 1,
|
10
|
+
queue_timeout: 1,
|
11
|
+
daemonize: false
|
12
|
+
}
|
13
|
+
|
14
|
+
def initialize(opts)
|
15
|
+
%i(require worker_name db_config queue_db default_db process queue_timeout daemonize).each do |k|
|
16
|
+
send(:"#{k}=", opts[k] || DEFAULT[k])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def default_db_config
|
21
|
+
raise ConfigurationError if !(default_db && db_defined?(default_db))
|
22
|
+
db_config[default_db]
|
23
|
+
end
|
24
|
+
|
25
|
+
def db_defined?(db_name)
|
26
|
+
!!(db_config && db_config[db_name])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/shinq/launcher.rb
CHANGED
@@ -2,23 +2,29 @@ require 'shinq/client'
|
|
2
2
|
require 'active_support/inflector'
|
3
3
|
|
4
4
|
module Shinq
|
5
|
-
|
6
|
-
def initialize(worker_name)
|
7
|
-
@worker_name = worker_name
|
8
|
-
@worker_class = @worker_name.camelize.constantize
|
9
|
-
end
|
10
|
-
|
5
|
+
module Launcher
|
11
6
|
def run
|
12
|
-
|
7
|
+
worker_name = Shinq.configuration.worker_name
|
8
|
+
worker_class = worker_name.camelize.constantize
|
9
|
+
|
10
|
+
until @stop
|
11
|
+
queue = Shinq::Client.dequeue(table_name: worker_name.pluralize)
|
12
|
+
#TODO use logger
|
13
|
+
next p "Queue is empty (#{Time.now})" unless queue
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
begin
|
16
|
+
worker_class.new.perform(queue)
|
17
|
+
rescue => e
|
18
|
+
Shinq::Client.abort
|
19
|
+
raise
|
20
|
+
end
|
21
|
+
|
22
|
+
Shinq::Client.done
|
19
23
|
end
|
24
|
+
end
|
20
25
|
|
21
|
-
|
26
|
+
def stop
|
27
|
+
@stop = true
|
22
28
|
end
|
23
29
|
end
|
24
30
|
end
|
data/lib/shinq/rails.rb
CHANGED
@@ -7,8 +7,8 @@ module Shinq
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.rails_bootstrap
|
10
|
-
Shinq.db_config = ActiveRecord::Base.configurations
|
11
|
-
Shinq.default_db = ::Rails.env
|
10
|
+
Shinq.configuration.db_config = ActiveRecord::Base.configurations
|
11
|
+
Shinq.configuration.default_db = ::Rails.env
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
data/lib/shinq.rb
CHANGED
@@ -1,33 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require 'mysql2'
|
2
2
|
require 'shinq/client'
|
3
|
+
require 'shinq/configuration'
|
3
4
|
|
4
5
|
module Shinq
|
5
6
|
VERSION = Gem.loaded_specs['shinq'].version.to_s
|
6
7
|
|
7
|
-
def self.
|
8
|
-
@
|
9
|
-
|
8
|
+
def self.configuration=(config)
|
9
|
+
@configuration = case config
|
10
|
+
when Shinq::Configuration
|
11
|
+
config
|
12
|
+
else
|
13
|
+
Shinq::Configuration.new(config)
|
14
|
+
end
|
10
15
|
end
|
11
16
|
|
12
|
-
def self.
|
13
|
-
@
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.default_db=(db_name)
|
17
|
-
@default_db = db_name
|
17
|
+
def self.configuration
|
18
|
+
@configuration ||= Shinq::Configuration.new({})
|
18
19
|
end
|
19
20
|
|
20
21
|
def self.default_db
|
21
|
-
|
22
|
+
self.configuration.default_db ||= ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development'
|
22
23
|
end
|
23
24
|
|
24
|
-
|
25
25
|
def self.setup_db_connection(db_name)
|
26
|
-
|
27
|
-
@connections[db_name] = Mysql2::Client.new(db_config[db_name])
|
26
|
+
raise Shinq::ConfigurationError unless self.configuration.db_defined?(db_name)
|
27
|
+
@connections[db_name] = Mysql2::Client.new(self.configuration.db_config[db_name])
|
28
28
|
end
|
29
29
|
|
30
|
-
def self.connection(db_name: default_db)
|
30
|
+
def self.connection(db_name: self.default_db)
|
31
|
+
@connections ||= {}
|
31
32
|
@connections[db_name] ||= setup_db_connection(db_name)
|
32
33
|
end
|
33
34
|
end
|
data/shinq.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "shinq"
|
7
|
-
spec.version = '0.0.1
|
7
|
+
spec.version = '0.0.1'
|
8
8
|
spec.authors = ["Ryoichi SEKIGUCHI"]
|
9
9
|
spec.email = ["ryopeko@gmail.com"]
|
10
10
|
spec.summary = %q{Worker and enqueuer for Q4M using the interface of ActiveJob.}
|
@@ -19,8 +19,13 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.7"
|
20
20
|
spec.add_development_dependency "rake", "~> 10.0"
|
21
21
|
spec.add_development_dependency "pry"
|
22
|
+
spec.add_development_dependency "tapp"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec-mocks"
|
25
|
+
spec.add_development_dependency "simplecov"
|
22
26
|
|
23
|
-
spec.add_dependency "mysql2
|
27
|
+
spec.add_dependency "mysql2", "~> 0.3.16"
|
24
28
|
spec.add_dependency "sql-maker", "~> 0.0.4"
|
25
29
|
spec.add_dependency "activesupport", "~> 4.2.0.beta2"
|
30
|
+
spec.add_dependency 'serverengine', '~> 1.5.9'
|
26
31
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shinq'
|
3
|
+
require 'shinq/client'
|
4
|
+
|
5
|
+
describe "Integration" do
|
6
|
+
before do
|
7
|
+
load_database_config(Shinq)
|
8
|
+
end
|
9
|
+
|
10
|
+
context "When create queue", skip: ENV['TRAVIS'] do
|
11
|
+
let(:queue_table) { 'queue_test' }
|
12
|
+
let(:args) { {title: 'foo'} }
|
13
|
+
|
14
|
+
before do
|
15
|
+
Shinq::Client.enqueue(
|
16
|
+
table_name: queue_table,
|
17
|
+
job_id: 'jobid',
|
18
|
+
args: args
|
19
|
+
)
|
20
|
+
|
21
|
+
@queue = Shinq::Client.dequeue(table_name: queue_table)
|
22
|
+
Shinq::Client.done
|
23
|
+
end
|
24
|
+
|
25
|
+
it { expect(@queue[:title]).to eq args[:title] }
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shinq/configuration'
|
3
|
+
|
4
|
+
describe Shinq::Configuration do
|
5
|
+
describe "accessors" do
|
6
|
+
subject { Shinq::Configuration.new({}) }
|
7
|
+
|
8
|
+
it { is_expected.to respond_to(:require) }
|
9
|
+
it { is_expected.to respond_to(:worker_name) }
|
10
|
+
it { is_expected.to respond_to(:db_config) }
|
11
|
+
it { is_expected.to respond_to(:queue_db) }
|
12
|
+
it { is_expected.to respond_to(:default_db) }
|
13
|
+
it { is_expected.to respond_to(:process) }
|
14
|
+
it { is_expected.to respond_to(:queue_timeout) }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe ".new" do
|
18
|
+
context "when key does not have a accessor method" do
|
19
|
+
let(:configuration) { Shinq::Configuration.new(undefined_key_name: 'foo') }
|
20
|
+
|
21
|
+
it { expect {configuration.undefined_key_name}.to raise_error(NoMethodError) }
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when key has a accessor method" do
|
25
|
+
let(:configuration) { Shinq::Configuration.new(worker_name: 'foo') }
|
26
|
+
|
27
|
+
it { expect {configuration.worker_name}.not_to raise_error() }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe "#default_db_config" do
|
32
|
+
context "when default_db is present" do
|
33
|
+
let(:configuration) { Shinq::Configuration.new({}) }
|
34
|
+
|
35
|
+
it {expect { configuration.default_db_config }.to raise_error(Shinq::ConfigurationError)}
|
36
|
+
end
|
37
|
+
|
38
|
+
context "when default_db's config is present" do
|
39
|
+
let(:configuration) { Shinq::Configuration.new(default_db: :foo) }
|
40
|
+
|
41
|
+
it {expect { configuration.default_db_config }.to raise_error(Shinq::ConfigurationError)}
|
42
|
+
end
|
43
|
+
|
44
|
+
context "when default_db's config is present" do
|
45
|
+
let(:configuration) { Shinq::Configuration.new(default_db: :test) }
|
46
|
+
|
47
|
+
it {expect { configuration.default_db_config }.to raise_error(Shinq::ConfigurationError)}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "#db_defined?" do
|
52
|
+
context "when db_config is present" do
|
53
|
+
let (:configuration) { Shinq::Configuration.new({}) }
|
54
|
+
|
55
|
+
it { expect(configuration.db_defined?(:test)).to be false }
|
56
|
+
end
|
57
|
+
|
58
|
+
context "when db_config is not present" do
|
59
|
+
context "when db_config does not have a value by specified key" do
|
60
|
+
let (:configuration) {
|
61
|
+
Shinq::Configuration.new(
|
62
|
+
db_config: {
|
63
|
+
test: 'foo'
|
64
|
+
}
|
65
|
+
)
|
66
|
+
}
|
67
|
+
|
68
|
+
it { expect(configuration.db_defined?(:foo)).to be false }
|
69
|
+
end
|
70
|
+
|
71
|
+
context "when db_config has a value by specified key" do
|
72
|
+
let (:configuration) {
|
73
|
+
Shinq::Configuration.new(
|
74
|
+
db_config: {
|
75
|
+
test: 'foo'
|
76
|
+
}
|
77
|
+
)
|
78
|
+
}
|
79
|
+
|
80
|
+
it { expect(configuration.db_defined?(:test)).to be true }
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/shinq_spec.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'shinq'
|
3
|
+
require 'shinq/configuration'
|
4
|
+
|
5
|
+
def shinq_class
|
6
|
+
Shinq.dup
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Shinq do
|
10
|
+
subject { shinq_class }
|
11
|
+
|
12
|
+
it { is_expected.to respond_to(:configuration) }
|
13
|
+
it { is_expected.to respond_to(:configuration=) }
|
14
|
+
|
15
|
+
describe ".configuration" do
|
16
|
+
context "when configuration is not present" do
|
17
|
+
let(:shinq) { shinq_class }
|
18
|
+
|
19
|
+
it { expect(shinq.configuration).to be_a_kind_of(Shinq::Configuration) }
|
20
|
+
end
|
21
|
+
|
22
|
+
context "when configuration is present" do
|
23
|
+
let(:shinq) {
|
24
|
+
shinq_class.tap {|s|
|
25
|
+
s.configuration = Hash.new
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
it { expect(shinq.configuration).to be_a_kind_of(Shinq::Configuration) }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe ".configuration=" do
|
34
|
+
context "when specify args" do
|
35
|
+
let(:shinq) { shinq_class }
|
36
|
+
let(:args) { Hash.new }
|
37
|
+
|
38
|
+
it 'is expect to return specified args' do
|
39
|
+
expect(shinq.configuration=(args)).to eq args
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe ".connection" do
|
45
|
+
context "when db_config is present" do
|
46
|
+
let(:shinq) { shinq_class }
|
47
|
+
|
48
|
+
it { expect{ shinq.connection(db_name: :unknown) }.to raise_error(Shinq::ConfigurationError) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when db_config is not preset" do
|
52
|
+
let(:shinq) {
|
53
|
+
shinq_class.tap {|s|
|
54
|
+
load_database_config(s)
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
it { expect(shinq.connection(db_name: :test)).to be_a_kind_of(Mysql2::Client) }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'rspec/mocks/standalone'
|
2
|
+
require 'simplecov'
|
3
|
+
require 'yaml'
|
4
|
+
require 'active_support/core_ext/hash'
|
5
|
+
|
6
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
7
|
+
SimpleCov::Formatter::HTMLFormatter
|
8
|
+
]
|
9
|
+
|
10
|
+
SimpleCov.start do
|
11
|
+
add_filter 'spec'
|
12
|
+
end
|
13
|
+
|
14
|
+
RSpec.configure do |config|
|
15
|
+
config.filter_run :focus
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
|
18
|
+
if config.files_to_run.one?
|
19
|
+
config.full_backtrace = true
|
20
|
+
config.default_formatter = 'doc'
|
21
|
+
end
|
22
|
+
|
23
|
+
config.order = :random
|
24
|
+
Kernel.srand config.seed
|
25
|
+
end
|
26
|
+
|
27
|
+
def load_database_config(klass)
|
28
|
+
db_config = YAML.load_file(File.expand_path('./config/database.yml', __dir__)).symbolize_keys
|
29
|
+
klass.configuration = {
|
30
|
+
db_config: db_config,
|
31
|
+
default_db: :test
|
32
|
+
}
|
33
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shinq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryoichi SEKIGUCHI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -53,19 +53,75 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: tapp
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec-mocks
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: simplecov
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mysql2
|
57
113
|
requirement: !ruby/object:Gem::Requirement
|
58
114
|
requirements:
|
59
115
|
- - "~>"
|
60
116
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
117
|
+
version: 0.3.16
|
62
118
|
type: :runtime
|
63
119
|
prerelease: false
|
64
120
|
version_requirements: !ruby/object:Gem::Requirement
|
65
121
|
requirements:
|
66
122
|
- - "~>"
|
67
123
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
124
|
+
version: 0.3.16
|
69
125
|
- !ruby/object:Gem::Dependency
|
70
126
|
name: sql-maker
|
71
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +150,20 @@ dependencies:
|
|
94
150
|
- - "~>"
|
95
151
|
- !ruby/object:Gem::Version
|
96
152
|
version: 4.2.0.beta2
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: serverengine
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 1.5.9
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 1.5.9
|
97
167
|
description:
|
98
168
|
email:
|
99
169
|
- ryopeko@gmail.com
|
@@ -103,6 +173,8 @@ extensions: []
|
|
103
173
|
extra_rdoc_files: []
|
104
174
|
files:
|
105
175
|
- ".gitignore"
|
176
|
+
- ".rspec"
|
177
|
+
- ".travis.yml"
|
106
178
|
- Gemfile
|
107
179
|
- LICENSE.txt
|
108
180
|
- README.md
|
@@ -112,9 +184,15 @@ files:
|
|
112
184
|
- lib/shinq/active_job/queue_adapters/shinq_adapter.rb
|
113
185
|
- lib/shinq/cli.rb
|
114
186
|
- lib/shinq/client.rb
|
187
|
+
- lib/shinq/configuration.rb
|
115
188
|
- lib/shinq/launcher.rb
|
116
189
|
- lib/shinq/rails.rb
|
117
190
|
- shinq.gemspec
|
191
|
+
- spec/config/database.yml
|
192
|
+
- spec/integration_spec.rb
|
193
|
+
- spec/shinq/configuration_spec.rb
|
194
|
+
- spec/shinq_spec.rb
|
195
|
+
- spec/spec_helper.rb
|
118
196
|
homepage: https://github.com/ryopeko/shinq
|
119
197
|
licenses:
|
120
198
|
- MIT
|
@@ -130,13 +208,18 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
208
|
version: '0'
|
131
209
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
132
210
|
requirements:
|
133
|
-
- - "
|
211
|
+
- - ">="
|
134
212
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
213
|
+
version: '0'
|
136
214
|
requirements: []
|
137
215
|
rubyforge_project:
|
138
216
|
rubygems_version: 2.2.2
|
139
217
|
signing_key:
|
140
218
|
specification_version: 4
|
141
219
|
summary: Worker and enqueuer for Q4M using the interface of ActiveJob.
|
142
|
-
test_files:
|
220
|
+
test_files:
|
221
|
+
- spec/config/database.yml
|
222
|
+
- spec/integration_spec.rb
|
223
|
+
- spec/shinq/configuration_spec.rb
|
224
|
+
- spec/shinq_spec.rb
|
225
|
+
- spec/spec_helper.rb
|