sequel_db_config 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 497369b03ba36d3a55bf46a78dd1beb05934e59b
4
- data.tar.gz: 65a754a30f0cb7e31177a7ba46f991ae7f8d5242
2
+ SHA256:
3
+ metadata.gz: 4c8f1e585659cacdc110419ccfc74a9775e97738bb927ba291522a9d9317f27f
4
+ data.tar.gz: 2f0a9cf019f2a81e9c351edde9355f7d57a598cba58ccd131f6390b8a8064ed1
5
5
  SHA512:
6
- metadata.gz: d360edb0a628aef9851f846209f5683af3b02ae518cf784c1fd2ef1bb554c1b5d3c271e9128e395b6e1a5933859e1e4e7643d0a2404c8c06b2d9ec37da9aa8da
7
- data.tar.gz: 15a8aad9c24407f6a1ae3762b31221d0132339763695aea11981b2605acca7e4b67172e5a37d2bb20894e174bec0de1cb09e314cb75cdcc195f5c209f94fc1f5
6
+ metadata.gz: cfc46e8dfabd823458f2b795318c349973de107ae1b83377b98b1930b6811f7fea722664f51e184ea3e46cd258322be566de33a6daaf8110b4658c3e0077dfe3
7
+ data.tar.gz: 796738306cfe9e5ac13dd613cb21e2bd0302fcad514b43732082361448f715b8b5c12a9f503fdf5b0f781fdff87d386f06d913ad57a8c74d69812b803fbf9300
data/.gitignore CHANGED
@@ -12,3 +12,5 @@
12
12
  *.a
13
13
  mkmf.log
14
14
  dbconfig.yaml
15
+ .ruby-version
16
+ /pkg
data/README.md CHANGED
@@ -41,6 +41,7 @@ dbconfig = SequelDbConfig::Config.instance
41
41
  ### Method
42
42
  * connection_string : get database connection string for Sequel.
43
43
  * load(file) : load configuration from specified YAML file.
44
+ * migrate(path, version) : exec migration on specified path.
44
45
 
45
46
  ## Contributing
46
47
 
@@ -1,3 +1,3 @@
1
1
  module SequelDbConfig
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "sequel_db_config/version"
2
2
  require "singleton"
3
3
  require "yaml"
4
+ require "sequel"
4
5
 
5
6
  module SequelDbConfig
6
7
  # Your code goes here...
@@ -28,11 +29,50 @@ module SequelDbConfig
28
29
  db_name = conf["db_name"]
29
30
  db_user = conf["db_user"]
30
31
  db_password = conf["db_password"]
31
- @connection_string = "#{db_driver}://#{db_user}:#{db_password}@#{db_host}/#{db_name}"
32
+ options = {
33
+ max_connections: conf["max_connections"],
34
+ pool_timeout: conf["pool_timeout"]
35
+ }
36
+ option_string = self.make_options(options)
37
+
38
+ @connection_string = "#{db_driver}://#{db_user}:#{db_password}@#{db_host}/#{db_name}#{option_string}"
32
39
  end
33
40
  rescue
34
41
  raise "Cannot open configuration file."
35
42
  end
36
43
  end
44
+
45
+ def make_options(opts)
46
+ option_string = ""
47
+ opts.each do |key, value|
48
+ if value
49
+ if option_string == ""
50
+ option_string = "?"
51
+ else
52
+ option_string += "&"
53
+ end
54
+ option_string += "#{key}=#{value}"
55
+ end
56
+ end
57
+ option_string
58
+ end
59
+
60
+ # Execute migration
61
+ # If version is nil, sequel will migrate to the latest version.
62
+ def migrate(path, version = nil)
63
+ if @connection_string == ""
64
+ raise "Configuration is not loaded."
65
+ end
66
+ unless Dir.exist?(path)
67
+ raise "Migration dir not exists. (#{path})"
68
+ end
69
+ Sequel.extension :migration
70
+ db = Sequel.connect(@connection_string)
71
+ if version
72
+ Sequel::Migrator.run(db, path, target: version.to_i)
73
+ else
74
+ Sequel::Migrator.run(db, path)
75
+ end
76
+ end
37
77
  end
38
78
  end
@@ -18,8 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_development_dependency "bundler", "~> 2.4"
22
+ spec.add_development_dependency "rake", "~> 13.0"
23
23
 
24
24
  spec.add_dependency "sequel"
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_db_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kikuchi Ken
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-04 00:00:00.000000000 Z
11
+ date: 2024-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '2.4'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '2.4'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: sequel
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -66,13 +66,12 @@ files:
66
66
  - Rakefile
67
67
  - lib/sequel_db_config.rb
68
68
  - lib/sequel_db_config/version.rb
69
- - pkg/sequel_db_config-0.0.1.gem
70
69
  - sequel_db_config.gemspec
71
70
  homepage: ''
72
71
  licenses:
73
72
  - MIT
74
73
  metadata: {}
75
- post_install_message:
74
+ post_install_message:
76
75
  rdoc_options: []
77
76
  require_paths:
78
77
  - lib
@@ -87,9 +86,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
86
  - !ruby/object:Gem::Version
88
87
  version: '0'
89
88
  requirements: []
90
- rubyforge_project:
91
- rubygems_version: 2.2.2
92
- signing_key:
89
+ rubygems_version: 3.4.6
90
+ signing_key:
93
91
  specification_version: 4
94
92
  summary: Sequel database configuration settings.
95
93
  test_files: []
Binary file