is_master 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.docker-test +2 -1
- data/.rubocop.yml +4 -1
- data/.travis.yml +6 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +7 -3
- data/VERSION +1 -1
- data/bin/is_slave +37 -0
- data/is_master.gemspec +1 -1
- data/test/{test_cli.rb → test_cli_master.rb} +1 -1
- data/test/test_cli_slave.rb +33 -0
- metadata +9 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8d446a1bbdb34413d0769717d31ba5be21f829b
|
4
|
+
data.tar.gz: 829cc0ec8b33b49ded5dc833922726fbc4fc77c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79fb48be507c41b7913d37ffbd74adb26ae3b0d857e6381091e9a6801f4d51bdd24074818c3cfccbb15a51c63db16ab1f92163ea95a9370a40ba5a0d7c8160d0
|
7
|
+
data.tar.gz: 1460fc60be1aa17ec7a8a35055d1a2add71f140c9e8af0e771002c7011742e54eade8fde2dd99f3713ed0a8aaa7c55e7dc1b300e31a13eb1855c20c79862b5b4
|
data/.docker-test
CHANGED
data/.rubocop.yml
CHANGED
@@ -6,10 +6,13 @@ AllCops:
|
|
6
6
|
- Vagrantfile
|
7
7
|
TargetRubyVersion: 2.3
|
8
8
|
|
9
|
+
Gemspec/RequiredRubyVersion:
|
10
|
+
Enabled: false
|
11
|
+
|
9
12
|
Naming/AccessorMethodName:
|
10
13
|
Enabled: false
|
11
14
|
|
12
|
-
|
15
|
+
Style/RescueStandardError:
|
13
16
|
Enabled: false
|
14
17
|
|
15
18
|
Metrics/LineLength:
|
data/.travis.yml
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
language: ruby
|
2
2
|
dist: precise
|
3
3
|
rvm:
|
4
|
-
- 2.
|
5
|
-
- 2.3
|
6
|
-
- 2.
|
4
|
+
- 2.5.0
|
5
|
+
- 2.4.3
|
6
|
+
- 2.3.6
|
7
|
+
- 2.2.9
|
7
8
|
- 2.1.10
|
8
9
|
install:
|
9
10
|
- bundle install
|
@@ -11,4 +12,5 @@ install:
|
|
11
12
|
- gem install is_master-$(cat VERSION).gem
|
12
13
|
script:
|
13
14
|
- rubocop
|
14
|
-
- ruby ./test/
|
15
|
+
- ruby ./test/test_cli_master.rb
|
16
|
+
- ruby ./test/test_cli_slave.rb
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# is_master
|
2
|
-
[![Version](https://
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/is_master.svg)](https://badge.fury.io/rb/is_master)
|
3
3
|
[![Build Status](https://travis-ci.org/nishiki/is_master.svg?branch=master)](https://travis-ci.org/nishiki/is_master)
|
4
4
|
[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](https://github.com/nishiki/is_master/blob/master/LICENSE)
|
5
5
|
|
@@ -18,10 +18,14 @@ gem install is_master
|
|
18
18
|
It's simple:
|
19
19
|
```
|
20
20
|
is_master 10.0.254.2 ls -l
|
21
|
+
is_master /path/to/file ls -l
|
22
|
+
is_slave 10.0.254.2 ls -l
|
23
|
+
is_slave /path/to/file ls -l
|
21
24
|
```
|
22
|
-
|
25
|
+
|
26
|
+
Output is `ls -l` result or:
|
23
27
|
```
|
24
|
-
|
28
|
+
OK - I am slave, i going to sleep
|
25
29
|
```
|
26
30
|
|
27
31
|
## Development
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.2.0
|
data/bin/is_slave
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one
|
3
|
+
# or more contributor license agreements. See the NOTICE file
|
4
|
+
# distributed with this work for additional information
|
5
|
+
# regarding copyright ownership. The ASF licenses this file
|
6
|
+
# to you under the Apache License, Version 2.0 (the
|
7
|
+
# "License"); you may not use this file except in compliance
|
8
|
+
# with the License. You may obtain a copy of the License at
|
9
|
+
#
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
#
|
12
|
+
# Unless required by applicable law or agreed to in writing,
|
13
|
+
# software distributed under the License is distributed on an
|
14
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
15
|
+
# KIND, either express or implied. See the License for the
|
16
|
+
# specific language governing permissions and limitations
|
17
|
+
# under the License.
|
18
|
+
|
19
|
+
require 'socket'
|
20
|
+
|
21
|
+
if ARGV.length < 2
|
22
|
+
puts 'is_slave execute a command when it determine that server is slave'
|
23
|
+
puts "Usage: #{$PROGRAM_NAME} [VIP|FILE] COMMAND"
|
24
|
+
puts ' VIP - IP address expected to be master'
|
25
|
+
puts ' FILE - File expected to be master'
|
26
|
+
puts ' COMMAND - Command to execute if host is slave'
|
27
|
+
exit 2
|
28
|
+
end
|
29
|
+
|
30
|
+
expected = ARGV[0]
|
31
|
+
command = ARGV[1..-1].join(' ')
|
32
|
+
|
33
|
+
if !Socket.ip_address_list.map(&:ip_address).include?(expected) && !File.exist?(expected)
|
34
|
+
Kernel.exec(command)
|
35
|
+
else
|
36
|
+
puts 'OK - I am master, i going to sleep'
|
37
|
+
end
|
data/is_master.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.license = 'Apache-2.0'
|
12
12
|
|
13
13
|
spec.files = %x(git ls-files -z).split("\x0")
|
14
|
-
spec.executables = [
|
14
|
+
spec.executables = %w[is_master is_slave]
|
15
15
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
|
3
|
+
class TestCliSlave < Test::Unit::TestCase
|
4
|
+
def test_missing_arg
|
5
|
+
output = %x(is_slave 127.0.0.1)
|
6
|
+
assert_match('Usage: ', output)
|
7
|
+
|
8
|
+
output = %x(is_slave)
|
9
|
+
assert_match('Usage: ', output)
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_slave_mode
|
13
|
+
output = %x(is_slave 10.255.255.0 echo 'GOOD!')
|
14
|
+
assert_match('GOOD!', output)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_master_mode
|
18
|
+
output = %x(is_slave 127.0.0.1 echo 'GOOD!')
|
19
|
+
assert_match('I am master', output)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_file_slave_mode
|
23
|
+
output = %x(is_slave /tmp/test.txt echo 'GOOD!')
|
24
|
+
assert_match('GOOD!', output)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_file_master_mode
|
28
|
+
File.write('/tmp/test.txt', '')
|
29
|
+
output = %x(is_slave /tmp/test.txt echo 'GOOD!')
|
30
|
+
assert_match('I am master', output)
|
31
|
+
File.unlink('/tmp/test.txt')
|
32
|
+
end
|
33
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: is_master
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adrien Waksberg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
15
15
|
- is_master@yae.im
|
16
16
|
executables:
|
17
17
|
- is_master
|
18
|
+
- is_slave
|
18
19
|
extensions: []
|
19
20
|
extra_rdoc_files: []
|
20
21
|
files:
|
@@ -29,8 +30,10 @@ files:
|
|
29
30
|
- README.md
|
30
31
|
- VERSION
|
31
32
|
- bin/is_master
|
33
|
+
- bin/is_slave
|
32
34
|
- is_master.gemspec
|
33
|
-
- test/
|
35
|
+
- test/test_cli_master.rb
|
36
|
+
- test/test_cli_slave.rb
|
34
37
|
homepage: https://github.com/nishiki/is_master
|
35
38
|
licenses:
|
36
39
|
- Apache-2.0
|
@@ -51,9 +54,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
54
|
version: '0'
|
52
55
|
requirements: []
|
53
56
|
rubyforge_project:
|
54
|
-
rubygems_version: 2.6.
|
57
|
+
rubygems_version: 2.6.14
|
55
58
|
signing_key:
|
56
59
|
specification_version: 4
|
57
60
|
summary: is_master execute a command when it determine that server is master
|
58
61
|
test_files:
|
59
|
-
- test/
|
62
|
+
- test/test_cli_master.rb
|
63
|
+
- test/test_cli_slave.rb
|