em-sequel-async 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a5399cd6ad77a994a587abef2eab6a322715f48e
4
+ data.tar.gz: c8eec55d2a1d547d42f8aff73c4d75b81be5e5ea
5
+ SHA512:
6
+ metadata.gz: 403adb2e0bce5e000a853f7f740c6f452d55a59ce090a4f5984d593c8f43fa08c1a4a19cf087a0848af134a9844facafd345ebf2aa3ba9d8f127eba18c852b54
7
+ data.tar.gz: 8ff23de7750af0b74e3f4fc8019edfdc624a2f7b7c1896a85f7f70ad307263c22d5d76e1e64c250efc2319bf1861282ab54f57bd50f43043158866215193b377
@@ -0,0 +1 @@
1
+ services: mysql
data/Gemfile CHANGED
@@ -5,6 +5,7 @@ gem 'mysql2'
5
5
  gem 'eventmachine'
6
6
 
7
7
  group :development do
8
+ gem 'test-unit'
8
9
  gem 'await'
9
10
  gem 'bundler'
10
11
  gem 'jeweler'
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Scott Tadman, The Working Group Inc.
1
+ Copyright (c) 2012-2016 Scott Tadman, The Working Group Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,8 +1,25 @@
1
1
  # em-sequel-async
2
2
 
3
- Updated mysql2 driven replacement for tmm1/em-mysql
3
+ This is an EventMachine compatible adapter layer for [Sequel](http://sequel.jeremyevans.net)
4
+ that's intended to be a drop-in replacement for [tmm1/em-mysql](https://github.com/tmm1/em-mysql).
5
+
6
+ Only the `mysql2` driver is supported at this time.
7
+
8
+ ## Dependencies
9
+
10
+ This library requires Ruby 1.9.3 or better.
11
+
12
+ ## Testing
13
+
14
+ To configure the test environment create a defaults file `.database.yml`
15
+ in the root of the project. The user defined here will need to have
16
+ `CREATE DATABASE` priviliges.
17
+
18
+ To test:
19
+
20
+ rake test
4
21
 
5
22
  ## Copyright
6
23
 
7
- Copyright (c) 2012-2013 Scott Tadman, The Working Group Inc.
24
+ Copyright (c) 2012-2016 Scott Tadman, The Working Group Inc.
8
25
  See LICENSE.txt for further details.
@@ -1,9 +1,7 @@
1
+ 0.1.6
2
+ - Integrated fix from @yhara to pass through time-zone configuration options.
1
3
  0.1.5
2
4
  - Resolved issue with stale connections not being removed from pools
3
5
  correctly. Will retry dead connections every ten seconds.
4
- 0.1.4
5
- 0.1.3
6
- 0.1.2
7
- 0.1.1
8
6
  0.1.0
9
7
  - Initial version
data/Rakefile CHANGED
@@ -20,8 +20,9 @@ Jeweler::Tasks.new do |gem|
20
20
  gem.license = "MIT"
21
21
  gem.summary = %Q{Asynchronous Helper Methods for Sequel}
22
22
  gem.description = %Q{Implements a number of asynchronous helper methods for Sequel}
23
- gem.email = "scott@twg.ca"
23
+ gem.email = "tadman@postageapp.com"
24
24
  gem.authors = [ "Scott Tadman" ]
25
+ gem.required_ruby_version = '>=1.9.3'
25
26
  end
26
27
 
27
28
  Jeweler::RubygemsDotOrgTasks.new
@@ -33,3 +34,5 @@ Rake::TestTask.new(:test) do |test|
33
34
  test.pattern = 'test/**/test_*.rb'
34
35
  test.verbose = true
35
36
  end
37
+
38
+ task default: :test
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.1.6
@@ -2,22 +2,25 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
+ # stub: em-sequel-async 0.1.6 ruby lib
5
6
 
6
7
  Gem::Specification.new do |s|
7
8
  s.name = "em-sequel-async"
8
- s.version = "0.1.5"
9
+ s.version = "0.1.6"
9
10
 
10
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
11
13
  s.authors = ["Scott Tadman"]
12
- s.date = "2013-09-10"
14
+ s.date = "2016-05-11"
13
15
  s.description = "Implements a number of asynchronous helper methods for Sequel"
14
- s.email = "scott@twg.ca"
16
+ s.email = "tadman@postageapp.com"
15
17
  s.extra_rdoc_files = [
16
18
  "LICENSE.txt",
17
19
  "README.md"
18
20
  ]
19
21
  s.files = [
20
22
  ".document",
23
+ ".travis.yml",
21
24
  "Gemfile",
22
25
  "LICENSE.txt",
23
26
  "README.md",
@@ -34,17 +37,18 @@ Gem::Specification.new do |s|
34
37
  ]
35
38
  s.homepage = "http://github.com/tadman/em-sequel-async"
36
39
  s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "1.8.23"
40
+ s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
41
+ s.rubygems_version = "2.5.1"
39
42
  s.summary = "Asynchronous Helper Methods for Sequel"
40
43
 
41
44
  if s.respond_to? :specification_version then
42
- s.specification_version = 3
45
+ s.specification_version = 4
43
46
 
44
47
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
48
  s.add_runtime_dependency(%q<sequel>, [">= 0"])
46
49
  s.add_runtime_dependency(%q<mysql2>, [">= 0"])
47
50
  s.add_runtime_dependency(%q<eventmachine>, [">= 0"])
51
+ s.add_development_dependency(%q<test-unit>, [">= 0"])
48
52
  s.add_development_dependency(%q<await>, [">= 0"])
49
53
  s.add_development_dependency(%q<bundler>, [">= 0"])
50
54
  s.add_development_dependency(%q<jeweler>, [">= 0"])
@@ -52,6 +56,7 @@ Gem::Specification.new do |s|
52
56
  s.add_dependency(%q<sequel>, [">= 0"])
53
57
  s.add_dependency(%q<mysql2>, [">= 0"])
54
58
  s.add_dependency(%q<eventmachine>, [">= 0"])
59
+ s.add_dependency(%q<test-unit>, [">= 0"])
55
60
  s.add_dependency(%q<await>, [">= 0"])
56
61
  s.add_dependency(%q<bundler>, [">= 0"])
57
62
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -60,6 +65,7 @@ Gem::Specification.new do |s|
60
65
  s.add_dependency(%q<sequel>, [">= 0"])
61
66
  s.add_dependency(%q<mysql2>, [">= 0"])
62
67
  s.add_dependency(%q<eventmachine>, [">= 0"])
68
+ s.add_dependency(%q<test-unit>, [">= 0"])
63
69
  s.add_dependency(%q<await>, [">= 0"])
64
70
  s.add_dependency(%q<bundler>, [">= 0"])
65
71
  s.add_dependency(%q<jeweler>, [">= 0"])
@@ -26,9 +26,10 @@ class EmSequelAsync::Mysql
26
26
  # == Instance Methods ===================================================
27
27
 
28
28
  def initialize(db)
29
+ @db = db
29
30
  @options = {
30
- :symbolize_keys => true,
31
- :cast_booleans => true
31
+ symbolize_keys: true,
32
+ cast_booleans: true
32
33
  }
33
34
 
34
35
  db.opts.each do |key, value|
@@ -105,7 +106,11 @@ class EmSequelAsync::Mysql
105
106
  @connections[connection] = [ query, callback ]
106
107
 
107
108
  start = Time.now
108
- deferrable = connection.query(query)
109
+ deferrable = connection.query(
110
+ query,
111
+ database_timezone: @db.timezone,
112
+ application_timezone: Sequel.application_timezone
113
+ )
109
114
 
110
115
  deferrable.callback do |result|
111
116
  log(:debug, "(%.6fs) [OK] %s" % [ Time.now - start, query ])
@@ -47,8 +47,8 @@ module EmSequelAsync::SequelExtensions
47
47
 
48
48
  module InstanceMethods
49
49
  STOCK_COUNT_OPTS = {
50
- :select => [ Sequel::LiteralString.new("COUNT(*)").freeze ],
51
- :order => nil
50
+ select: [ Sequel::LiteralString.new("COUNT(*)").freeze ],
51
+ order: nil
52
52
  }.freeze
53
53
 
54
54
  def async_insert(*args)
@@ -3,6 +3,7 @@ require 'bundler'
3
3
 
4
4
  begin
5
5
  Bundler.setup(:default, :development)
6
+
6
7
  rescue Bundler::BundlerError => e
7
8
  $stderr.puts e.message
8
9
  $stderr.puts "Run `bundle install` to install missing gems"
@@ -12,7 +13,7 @@ end
12
13
 
13
14
  require 'test/unit'
14
15
 
15
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.expand_path(File.join('..', 'lib'), File.dirname(__FILE__)))
16
17
  $LOAD_PATH.unshift(File.dirname(__FILE__))
17
18
 
18
19
  require 'em-sequel-async'
@@ -23,6 +24,8 @@ require 'eventmachine'
23
24
 
24
25
  Sequel.extension(:em_sequel_async)
25
26
 
27
+ DATABASE_DEFAULTS_PATH = File.expand_path('../.database.yml', File.dirname(__FILE__))
28
+
26
29
  require 'await'
27
30
 
28
31
  class Test::Unit::TestCase
@@ -38,3 +41,40 @@ class Test::Unit::TestCase
38
41
  end
39
42
  end
40
43
  end
44
+
45
+ def database_defaults
46
+ @database_defaults ||= begin
47
+ config = if (File.exist?(DATABASE_DEFAULTS_PATH))
48
+ require 'yaml'
49
+
50
+ Hash[
51
+ YAML.load(File.open(DATABASE_DEFAULTS_PATH)).collect do |key, value|
52
+ [ key.to_sym, value ]
53
+ end
54
+ ]
55
+ else
56
+ { }
57
+ end
58
+
59
+ {
60
+ adapter: 'mysql2',
61
+ host: 'localhost',
62
+ username: 'root',
63
+ password: ''
64
+ }.merge(config)
65
+ end
66
+ end
67
+
68
+ def database_config
69
+ @database_config ||= {
70
+ default: database_defaults.merge(
71
+ database: 'emsa_test_default'
72
+ ),
73
+ a: database_defaults.merge(
74
+ database: 'emsa_test_a'
75
+ ),
76
+ b: database_defaults.merge(
77
+ database: 'emsa_test_b'
78
+ )
79
+ }
80
+ end
@@ -1,38 +1,18 @@
1
- require File.expand_path('helper', File.dirname(__FILE__))
2
-
3
- DB_CONFIG = {
4
- :default => {
5
- :adapter => 'mysql2',
6
- :username => 'test',
7
- :password => 'JAQv0RM6xFVb8yz06GiQ7mOq',
8
- :database => 'emsa_test_default'
9
- },
10
- :a => {
11
- :adapter => 'mysql2',
12
- :username => 'test',
13
- :password => 'JAQv0RM6xFVb8yz06GiQ7mOq',
14
- :database => 'emsa_test_a'
15
- },
16
- :b => {
17
- :adapter => 'mysql2',
18
- :username => 'test',
19
- :password => 'JAQv0RM6xFVb8yz06GiQ7mOq',
20
- :database => 'emsa_test_b'
21
- }
22
- }.freeze
23
-
24
- DB = Hash[DB_CONFIG.collect { |db, config| [ db, Sequel.connect(config) ] }]
1
+ require_relative './helper'
2
+
3
+ DB = Hash[database_config.collect { |db, config| [ db, Sequel.connect(config) ] }]
25
4
 
26
5
  {
27
- :default => %w[ db_default_a_models db_default_b_models ],
28
- :a => %w[ example_as ],
29
- :b => %w[ example_bs ]
6
+ default: %w[ db_default_a_models db_default_b_models ],
7
+ a: %w[ example_as ],
8
+ b: %w[ example_bs ]
30
9
  }.each do |db, tables|
31
- create_config = DB_CONFIG[db].dup
10
+ create_config = database_config[db].dup
32
11
  db_name = create_config.delete(:database)
33
12
 
34
13
  handle = Mysql2::Client.new(create_config)
35
- db_name = DB_CONFIG[db][:database]
14
+
15
+ db_name = database_config[db][:database]
36
16
 
37
17
  handle.query("DROP DATABASE IF EXISTS `#{db_name}`")
38
18
  handle.query("CREATE DATABASE `#{db_name}`")
@@ -79,7 +59,7 @@ class TestEmSequelAsync < Test::Unit::TestCase
79
59
  em do
80
60
  await do
81
61
  DbDefaultAModel.async_insert(
82
- :data => 'Test Name',
62
+ data: 'Test Name',
83
63
  &defer do |id|
84
64
  inserted_id = id
85
65
  end
@@ -102,21 +82,21 @@ class TestEmSequelAsync < Test::Unit::TestCase
102
82
  em do
103
83
  await do
104
84
  DbDefaultAModel.async_insert(
105
- :data => 'Test Name',
85
+ data: 'Test Name',
106
86
  &defer do |id|
107
87
  inserted_id = id
108
88
 
109
89
  assert inserted_id > 0
110
90
 
111
- DbDefaultAModel.where(:id => inserted_id).async_count(
91
+ DbDefaultAModel.where(id: inserted_id).async_count(
112
92
  &defer do |count|
113
93
  found_count = count
114
94
  end
115
95
  )
116
96
 
117
97
  DbDefaultAModel.async_insert_ignore(
118
- :id => inserted_id,
119
- :data => 'Duplicate',
98
+ id: inserted_id,
99
+ data: 'Duplicate',
120
100
  &defer do |count|
121
101
  inserted_count = count
122
102
  end
@@ -131,25 +111,25 @@ class TestEmSequelAsync < Test::Unit::TestCase
131
111
 
132
112
  em do
133
113
  found_count = nil
134
- delete_count = nil
114
+ deleted_count = nil
135
115
  inserted_count = nil
136
116
 
137
117
  await do |a|
138
- DbDefaultAModel.where(:id => inserted_id).async_delete(
118
+ DbDefaultAModel.where(id: inserted_id).async_delete(
139
119
  &defer do |count|
140
120
  deleted_count = count
141
121
 
142
122
  assert_equal 1, deleted_count
143
123
 
144
- DbDefaultAModel.where(:id => inserted_id).async_count(
145
- &defer do |count|
146
- found_count = count
124
+ DbDefaultAModel.where(id: inserted_id).async_count(
125
+ &defer do |_count|
126
+ found_count = _count
147
127
 
148
128
  DbDefaultAModel.async_insert_ignore(
149
- :id => inserted_id,
150
- :data => 'Duplicate',
151
- &defer do |count|
152
- inserted_count = count
129
+ id: inserted_id,
130
+ data: 'Duplicate',
131
+ &defer do |__count|
132
+ inserted_count = __count
153
133
  end
154
134
  )
155
135
  end
@@ -187,13 +167,13 @@ class TestEmSequelAsync < Test::Unit::TestCase
187
167
 
188
168
  await do
189
169
  DbDefaultAModel.async_insert(
190
- :data => 'Test Name',
170
+ data: 'Test Name',
191
171
  &defer do |id|
192
172
  inserted_id = id
193
173
 
194
174
  DbDefaultAModel.async_insert(
195
- :id => inserted_id,
196
- :data => 'Duplicate',
175
+ id: inserted_id,
176
+ data: 'Duplicate',
197
177
  &defer do |*f|
198
178
  duplicate_id = f[0]
199
179
  end
metadata CHANGED
@@ -1,121 +1,123 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: em-sequel-async
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
5
- prerelease:
4
+ version: 0.1.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Scott Tadman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-09-10 00:00:00.000000000 Z
11
+ date: 2016-05-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sequel
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: mysql2
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: eventmachine
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
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
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  - !ruby/object:Gem::Dependency
63
70
  name: await
64
71
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
72
  requirements:
67
- - - ! '>='
73
+ - - ">="
68
74
  - !ruby/object:Gem::Version
69
75
  version: '0'
70
76
  type: :development
71
77
  prerelease: false
72
78
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
79
  requirements:
75
- - - ! '>='
80
+ - - ">="
76
81
  - !ruby/object:Gem::Version
77
82
  version: '0'
78
83
  - !ruby/object:Gem::Dependency
79
84
  name: bundler
80
85
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
86
  requirements:
83
- - - ! '>='
87
+ - - ">="
84
88
  - !ruby/object:Gem::Version
85
89
  version: '0'
86
90
  type: :development
87
91
  prerelease: false
88
92
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
93
  requirements:
91
- - - ! '>='
94
+ - - ">="
92
95
  - !ruby/object:Gem::Version
93
96
  version: '0'
94
97
  - !ruby/object:Gem::Dependency
95
98
  name: jeweler
96
99
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
100
  requirements:
99
- - - ! '>='
101
+ - - ">="
100
102
  - !ruby/object:Gem::Version
101
103
  version: '0'
102
104
  type: :development
103
105
  prerelease: false
104
106
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
107
  requirements:
107
- - - ! '>='
108
+ - - ">="
108
109
  - !ruby/object:Gem::Version
109
110
  version: '0'
110
111
  description: Implements a number of asynchronous helper methods for Sequel
111
- email: scott@twg.ca
112
+ email: tadman@postageapp.com
112
113
  executables: []
113
114
  extensions: []
114
115
  extra_rdoc_files:
115
116
  - LICENSE.txt
116
117
  - README.md
117
118
  files:
118
- - .document
119
+ - ".document"
120
+ - ".travis.yml"
119
121
  - Gemfile
120
122
  - LICENSE.txt
121
123
  - README.md
@@ -132,26 +134,25 @@ files:
132
134
  homepage: http://github.com/tadman/em-sequel-async
133
135
  licenses:
134
136
  - MIT
137
+ metadata: {}
135
138
  post_install_message:
136
139
  rdoc_options: []
137
140
  require_paths:
138
141
  - lib
139
142
  required_ruby_version: !ruby/object:Gem::Requirement
140
- none: false
141
143
  requirements:
142
- - - ! '>='
144
+ - - ">="
143
145
  - !ruby/object:Gem::Version
144
- version: '0'
146
+ version: 1.9.3
145
147
  required_rubygems_version: !ruby/object:Gem::Requirement
146
- none: false
147
148
  requirements:
148
- - - ! '>='
149
+ - - ">="
149
150
  - !ruby/object:Gem::Version
150
151
  version: '0'
151
152
  requirements: []
152
153
  rubyforge_project:
153
- rubygems_version: 1.8.23
154
+ rubygems_version: 2.5.1
154
155
  signing_key:
155
- specification_version: 3
156
+ specification_version: 4
156
157
  summary: Asynchronous Helper Methods for Sequel
157
158
  test_files: []