serf_handler 0.1 → 0.1.1

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
2
  SHA1:
3
- metadata.gz: f17b68c3011b7a593e3139a84d8d42f1497d2c47
4
- data.tar.gz: 6cac6c6d4fc7b3aa827a04290ea1ae00d54caaef
3
+ metadata.gz: c4381f72083c0b8c045b85e2d394eb05768e7ea6
4
+ data.tar.gz: 57d31e2825da8617e2f6f8b94843a44d03269da4
5
5
  SHA512:
6
- metadata.gz: 8c276d31d860b4f99ca2532bd7abe725ba1dedada3a1317aa11f0781ce35280f0ac4931ca849f3a415d47e36ba217c8c96f543cff20a5b098825daab529b2ba9
7
- data.tar.gz: 56c44c998e2b118cc595ecc13d899b7e0a8f24ba0a17833efa72cee7e12f1fbbae84d1b338540d43c3e432e5011f9389f034b4bbb998793752d44fd7646fa6c0
6
+ metadata.gz: e898353f579b8bb641768ed3e12950dd5f31587fd5f464b4146ecd2b57aa6958f2db736f957c6d9ac734fd4a43ee918f9958b7f0fcb087a829a94445a95d4f20
7
+ data.tar.gz: d7f63cef8c8a35b124978a806afb8263d80da55f5aca6e31c852469f2f475747692bc6a4052270184c0e5bd0d47ddc03c4890b7802b55f9799807423e411f921
data/README.md CHANGED
@@ -2,7 +2,7 @@ serf_handler
2
2
  ============
3
3
  [![Build Status](https://travis-ci.org/konchan/serf_handler.svg?branch=master)](https://travis-ci.org/konchan/serf_handler)
4
4
 
5
- [Serf](http://www.serfdom.io/) is a cluster orchestration framework which developed by [HashiCorp](http://www.hashicorp.com/). Serf allows you to execute your scripts when serf event occur.
5
+ [Serf](http://www.serfdom.io/) is a cluster orchestration framework which developed by [HashiCorp](http://www.hashicorp.com/). Serf allows you to execute your scripts when serf event occurs.
6
6
  You can simply extend SerfHandler and process serf events. Serf_handler is a very simple Ruby framework with no dependencies.
7
7
  I have a lot in reference to [this code](https://github.com/garethr/serf-master).
8
8
 
@@ -14,14 +14,20 @@ gem install serf_handler
14
14
 
15
15
  ### how to use
16
16
 
17
- ```sample.rb
17
+ ```ruby
18
+ #!/usr/bin/env ruby
18
19
  require 'serf_handler'
19
20
 
20
- class MyEventHandler
21
- # called by SerfHandler when member-join event occur
21
+ class MyEventHandler < SerfHandler
22
+ # called by SerfHandler when member-join event occurs
22
23
  def member_join
23
24
  # write your code
24
25
  end
26
+
27
+ # called by SerfHandler when your custome event occurs
28
+ def your_custome_event
29
+ # write your code
30
+ end
25
31
  end
26
32
 
27
33
  if __FILE__ == $0
@@ -32,8 +38,8 @@ end
32
38
  ```
33
39
 
34
40
  ### Contributing
35
- - Fork it
36
- - Create your feature branch (```git checkout -b my-new-feature```)
37
- - Commit your changes (```git commit -am 'Add some feature'```)
38
- - Push to the branch (```git push origin my-new-feature```)
39
- - Create new Pull Request
41
+ 1. Fork it
42
+ 2. Create your feature branch (```git checkout -b my-new-feature```)
43
+ 3. Commit your changes (```git commit -am 'Add some feature'```)
44
+ 4. Push to the branch (```git push origin my-new-feature```)
45
+ 5. Create new Pull Request
data/build/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/build/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in build.gemspec
4
+ gemspec
data/build/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 konchan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/build/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Build
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'build'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install build
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/build/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/build/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'build/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "build"
8
+ spec.version = Build::VERSION
9
+ spec.authors = ["konchan"]
10
+ spec.email = ["konno.katsuyuki@nifty.com"]
11
+ spec.summary = %q{TODO: Write a short summary. Required.}
12
+ spec.description = %q{TODO: Write a longer description. Optional.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
@@ -0,0 +1,3 @@
1
+ module Build
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,5 @@
1
+ require "build/version"
2
+
3
+ module Build
4
+ # Your code goes here...
5
+ end
data/lib/serf_handler.rb CHANGED
@@ -6,9 +6,13 @@ require "logger"
6
6
  class SerfHandler
7
7
  attr :name, :role, :event
8
8
 
9
- def initialize(logger=nil)
10
- if logger
11
- @logger = logger
9
+ def initialize(log=nil)
10
+ if log
11
+ if log.kind_of?(String)
12
+ @logger = Logger.new(log)
13
+ else
14
+ @logger = log
15
+ end
12
16
  else
13
17
  @logger = Logger.new(STDOUT)
14
18
  @logger.level = Logger::INFO
@@ -24,8 +28,8 @@ class SerfHandler
24
28
  end
25
29
 
26
30
  class SerfHandlerProxy < SerfHandler
27
- def initialize(logger=nil)
28
- super(logger)
31
+ def initialize(log_file=nil)
32
+ super(log_file)
29
33
  @handlers = {}
30
34
  end
31
35
 
@@ -50,7 +54,7 @@ class SerfHandlerProxy < SerfHandler
50
54
  begin
51
55
  klass.send @event
52
56
  rescue NoMethodError => e
53
- log "event not implemented by class"
57
+ log "#{@event} event not implemented by class"
54
58
  end
55
59
  end
56
60
  end
data/serf_handler.gemspec CHANGED
@@ -5,11 +5,11 @@ require 'serf_handler'
5
5
 
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'serf_handler'
8
- gem.version = '0.1'
8
+ gem.version = '0.1.1'
9
9
  gem.authors = ['KONNO Katsuyuki']
10
10
  gem.email = 'konno.katsuyuki@nifty.com'
11
- gem.description = 'Serf event handlers for ruby'
12
- gem.summary = 'Serf event handlers for ruby'
11
+ gem.description = 'Serf event handler for ruby'
12
+ gem.summary = 'Serf event handler for ruby'
13
13
  gem.homepage = 'http://github.com/konchan/serf_handler'
14
14
  gem.licenses = ['MIT']
15
15
 
@@ -70,7 +70,7 @@ describe "SerfHandlerProxy" do
70
70
 
71
71
  it "has no method implemented" do
72
72
  logger = double('Logger')
73
- expect(logger).to receive(:info).with("event not implemented by class").and_return(true)
73
+ expect(logger).to receive(:info).with("member_join event not implemented by class").and_return(true)
74
74
  handler = SerfHandlerProxy.new(logger)
75
75
  handler.register('default', SerfHandler.new)
76
76
  handler.run
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: serf_handler
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - KONNO Katsuyuki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-02 00:00:00.000000000 Z
11
+ date: 2014-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logger
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.2.8
27
- description: Serf event handlers for ruby
27
+ description: Serf event handler for ruby
28
28
  email: konno.katsuyuki@nifty.com
29
29
  executables: []
30
30
  extensions: []
@@ -38,6 +38,14 @@ files:
38
38
  - LICENSE
39
39
  - README.md
40
40
  - Rakefile
41
+ - build/.gitignore
42
+ - build/Gemfile
43
+ - build/LICENSE.txt
44
+ - build/README.md
45
+ - build/Rakefile
46
+ - build/build.gemspec
47
+ - build/lib/build.rb
48
+ - build/lib/build/version.rb
41
49
  - lib/serf_handler.rb
42
50
  - serf_handler.gemspec
43
51
  - spec/serf_handler_spec.rb
@@ -65,7 +73,7 @@ rubyforge_project:
65
73
  rubygems_version: 2.0.14
66
74
  signing_key:
67
75
  specification_version: 4
68
- summary: Serf event handlers for ruby
76
+ summary: Serf event handler for ruby
69
77
  test_files:
70
78
  - spec/serf_handler_spec.rb
71
79
  - spec/spec_helper.rb