mdbm_dist_support 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f6a110b62fc353a860aea95a85a114cfe98a8e12
4
+ data.tar.gz: d084dfa7a45a7933fb150945641d4d8cc1e51bfd
5
+ SHA512:
6
+ metadata.gz: 95ac2310e2fef1acd077915b2283ffe4d616af2aa58d3b2a922d372021a792ed0e405b09f455733317cba7b547a25f587f997366a5c867eb91481fda4305e18e
7
+ data.tar.gz: 37ad18a71b23d25add915c523bfad8c04f23e457340b51a3728e2d8b510ecf2f7326b8366e14fde37097016a5d55aaf84837f70a69fde3f7658fa2b90cb61c8a
data/.gitignore ADDED
@@ -0,0 +1,50 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+ *.bridgesupport
21
+ build-iPhoneOS/
22
+ build-iPhoneSimulator/
23
+
24
+ ## Specific to RubyMotion (use of CocoaPods):
25
+ #
26
+ # We recommend against adding the Pods directory to your .gitignore. However
27
+ # you should judge for yourself, the pros and cons are mentioned at:
28
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
29
+ #
30
+ # vendor/Pods/
31
+
32
+ ## Documentation cache and generated files:
33
+ /.yardoc/
34
+ /_yardoc/
35
+ /doc/
36
+ /rdoc/
37
+
38
+ ## Environment normalization:
39
+ /.bundle/
40
+ /vendor/bundle
41
+ /lib/bundler/man/
42
+
43
+ # for a library or gem, you might want to ignore these files since the code is
44
+ # intended to run in multiple environments; otherwise, check them in:
45
+ # Gemfile.lock
46
+ # .ruby-version
47
+ # .ruby-gemset
48
+
49
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
50
+ .rvmrc
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mdbm_dist_support.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ mdbm_dist_support (0.1.0)
5
+ ruby-mdbm (>= 0.0.2)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ diff-lcs (1.3)
11
+ rake (10.5.0)
12
+ rspec (3.6.0)
13
+ rspec-core (~> 3.6.0)
14
+ rspec-expectations (~> 3.6.0)
15
+ rspec-mocks (~> 3.6.0)
16
+ rspec-core (3.6.0)
17
+ rspec-support (~> 3.6.0)
18
+ rspec-expectations (3.6.0)
19
+ diff-lcs (>= 1.2.0, < 2.0)
20
+ rspec-support (~> 3.6.0)
21
+ rspec-mocks (3.6.0)
22
+ diff-lcs (>= 1.2.0, < 2.0)
23
+ rspec-support (~> 3.6.0)
24
+ rspec-support (3.6.0)
25
+ ruby-mdbm (0.0.2)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ bundler (~> 1.14)
32
+ mdbm_dist_support!
33
+ rake (~> 10.0)
34
+ rspec (~> 3.0)
35
+
36
+ BUNDLED WITH
37
+ 1.14.6
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 mshimizu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # mdbm_dist_support
2
+ mdbm distribution support gem
3
+
4
+ ## Usage
5
+ ```
6
+ #!/usr/bin/env ruby
7
+
8
+ require 'mdbm_dist_support'
9
+
10
+ mds = MdbmDistSupport::Distributer.new do |m|
11
+ m.lock_path = 'lock file path'
12
+ m.meta_path = 'local meta mdbm file path'
13
+ m.local_path = 'local mdbm file path'
14
+ m.dist_path = 'distribution mdbm file path'
15
+ m.cmd_print = 'print command ( command to print Key Value seperated TAB to STDOUT )'
16
+ m.cmd_gen = 'generate mdbm command'
17
+ m.cmd_rep = 'replace mdbm command'
18
+ m.full_mode = true
19
+ m.dist_server_hosts = ['distribution target server hosts array']
20
+ m.meta_incr_key = 'incrementmode key in local meta mdbm'
21
+ end
22
+
23
+ mds.run
24
+ ```
25
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "mdbm_dist_support"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,6 @@
1
+ require 'mdbm_dist_support/version'
2
+ require 'mdbm_dist_support/distributer'
3
+
4
+ module MdbmDistSupport
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,44 @@
1
+ require 'mdbm_dist_support/meta'
2
+ require 'mdbm_dist_support/lock'
3
+ require 'tempfile'
4
+
5
+ module MdbmDistSupport
6
+ # Mdbm distributer
7
+ class Distributer
8
+ attr_accessor :lock_path, :lock, :meta_path, :meta, :local_path,\
9
+ :dist_path, :cmd_print, :cmd_gen, :cmd_rep,\
10
+ :dist_server_hosts, :meta_incr_key, :full_mode
11
+
12
+ def initialize
13
+ yield self if block_given?
14
+ end
15
+
16
+ def run
17
+ @lock = MdbmDistSupport::Lock.new(@lock_path)
18
+ @meta = MdbmDistSupport::Meta.new(@meta_path)
19
+ @lock.try_lock
20
+ local_up
21
+ end
22
+
23
+ private
24
+
25
+ def local_up
26
+ date_b = @meta.fetch(@meta_incr_key)
27
+ Tempfile.create('mdbmdistributesupport') do |f|
28
+ Kernel.system %(#{@cmd_print} #{date_b} > #{f.path})
29
+ date_a = @meta.fetch(@meta_incr_key)
30
+ break if @full_mode == false && date_a <= date_b
31
+ Kernel.system %(cat #{f.path} | #{@cmd_gen} #{@local_path})
32
+ @meta.store(@meta_incr_key, date_a)
33
+ dist
34
+ end
35
+ end
36
+
37
+ def dist
38
+ @dist_server_hosts.each do |s|
39
+ Kernel.exec %(scp -o StrictHostKeychecking=no #{@local_path} #{s}:#{@dist_path}.tmp)
40
+ Kernel.exec %(ssh -o StrictHostKeychecking=no #{s} \" #{@cmd_rep} #{@dist_path} #{@dist_path}.tmp && chmod 777 #{@dist_path}\")
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,14 @@
1
+ module MdbmDistSupport
2
+ # Lockfile manager
3
+ class Lock
4
+ attr_accessor :lock_file, :lock_status
5
+
6
+ def initialize(path)
7
+ @lock_file = open(path, 'w')
8
+ end
9
+
10
+ def try_lock
11
+ @lock_file.flock(File::LOCK_EX | File::LOCK_NB)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ require 'mdbm'
2
+
3
+ module MdbmDistSupport
4
+ # Meta mdbm manager
5
+ class Meta
6
+ attr_accessor :meta
7
+
8
+ def initialize(path)
9
+ @meta ||= Mdbm.new(path, Mdbm::MDBM_O_RDWR | Mdbm::MDBM_O_CREAT, 0644, 0, 0)
10
+ end
11
+
12
+ def fetch(key)
13
+ @meta.fetch(key) || self.store(key, 0)
14
+ end
15
+
16
+ def store(key, val)
17
+ @meta.store(key.to_s, val.to_s, Mdbm::MDBM_REPLACE)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module MdbmDistSupport
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'mdbm_dist_support/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'mdbm_dist_support'
9
+ spec.version = MdbmDistSupport::VERSION
10
+ spec.authors = ['MichinaoShimizu']
11
+ spec.email = ['shimizu.michinao@gmail.com']
12
+ spec.summary = %(mdbm distribution support gem)
13
+ spec.description = %(mdbm distribution support gem)
14
+ spec.homepage = 'https://github.com/MichinaoShimizu/mdbm_dist_support'
15
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
+ f.match(%r{^(test|spec|features)/})
17
+ end
18
+ spec.require_paths = ['lib']
19
+ spec.add_development_dependency 'bundler', '~> 1.14'
20
+ spec.add_development_dependency 'rake', '~> 10.0'
21
+ spec.add_development_dependency 'rspec', '~> 3.0'
22
+ spec.add_runtime_dependency 'ruby-mdbm', '>= 0.0.2'
23
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mdbm_dist_support
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - MichinaoShimizu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-09-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ruby-mdbm
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 0.0.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 0.0.2
69
+ description: mdbm distribution support gem
70
+ email:
71
+ - shimizu.michinao@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - Gemfile.lock
79
+ - LICENSE
80
+ - README.md
81
+ - Rakefile
82
+ - bin/console
83
+ - bin/setup
84
+ - lib/mdbm_dist_support.rb
85
+ - lib/mdbm_dist_support/distributer.rb
86
+ - lib/mdbm_dist_support/lock.rb
87
+ - lib/mdbm_dist_support/meta.rb
88
+ - lib/mdbm_dist_support/version.rb
89
+ - mdbm_dist_support.gemspec
90
+ homepage: https://github.com/MichinaoShimizu/mdbm_dist_support
91
+ licenses: []
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.6.8
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: mdbm distribution support gem
113
+ test_files: []