observed-clockwork 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 +15 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +53 -0
- data/Rakefile +1 -0
- data/bin/clockwork +16 -0
- data/bin/clockworkd +16 -0
- data/bin/observed-clockwork +16 -0
- data/bin/rake +16 -0
- data/examples/clockwork/clockwork.rb +9 -0
- data/examples/clockwork/foo_plugin.rb +19 -0
- data/examples/clockwork/observed.conf +6 -0
- data/features/run_observed_inside_clockwork.feature +59 -0
- data/features/support/env.rb +8 -0
- data/lib/observed/clockwork.rb +20 -0
- data/lib/observed/clockwork/version.rb +5 -0
- data/observed-clockwork.gemspec +29 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZGRmMzRjMjE1OWVjZTM2MTllZjQ3YjM0YTkyNTlkYjMwZGE4MzQ1OQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MGEwYjlhYzZkNjk5OTcxOGE2YjVlN2U2OGJkMTNmMDNjNDE5NGU2MA==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
OWY2OWQyY2ZhNmQzYzk0ZDAzYjQzZGYxNTJiNmNlMzY3YTI0YzVhOWM0Y2M2
|
10
|
+
NmZjMTU1Y2VlYzkyOWI3NTMxZTA5NmQ3MTk4NzJlNjUwNWNkZjdkMTRiZjQw
|
11
|
+
YjM4NzA1ODM4YzM1ZjM5ZWVhZTNkMTRmNGQ3ZjEwZWQ2MWZhNGQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NzczNjAzYjE3NDljMWVmNTVjMmM4OTYyYTExZmZiOWM1ZTBkYzZhYjljMzU3
|
14
|
+
ZDc4ZTZmNjVhMGYyMjAxOWNlYTY0NzUzMTQ3YTZjYTE4M2EzMjBhMmQ1ZTAz
|
15
|
+
OWM3NjY1NmM2NWY2ZWFjMzA2YzBjMWY5ZDhhNDE4M2E2ZGIwZjU=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 GREE, Inc.
|
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/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# observed-clockwork
|
2
|
+
|
3
|
+
observed-clockwork is an integration of Observed and Clockwork.
|
4
|
+
In the integration, we can define jobs in Observed and schedule those to run by Clockwork.
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'observed-clockwork'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install observed-clockwork
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
### With Bundler
|
23
|
+
|
24
|
+
$ bundle install
|
25
|
+
$ bundle exec clockwork examples/clockwork/clockwork.rb
|
26
|
+
|
27
|
+
Or with daemonizing:
|
28
|
+
|
29
|
+
$ bundle install (Note that we need to add the dependency to 'daemons' gem in our Gemfile or gemspec)
|
30
|
+
$ bundle exec clockworkd -c examples/clockwork/clockwork.rb -l start
|
31
|
+
$ tail -f tmp/clockworkd.clockwork.output
|
32
|
+
$ bundle exec clockworkd -c examples/clockwork/clockwork.rb -l stop
|
33
|
+
|
34
|
+
### Without Bundler
|
35
|
+
|
36
|
+
$ gem install observed-clockwork
|
37
|
+
$ clockwork clockwork.rb
|
38
|
+
|
39
|
+
Or with daemonizing:
|
40
|
+
|
41
|
+
$ gem install observed-clockwork
|
42
|
+
$ gem install daemons
|
43
|
+
$ clockworkd -c examples/clockwork/clockwork.rb -l start
|
44
|
+
$ tail -f tmp/clockworkd.clockwork.output
|
45
|
+
$ clockworkd -c examples/clockwork/clockwork.rb -l stop
|
46
|
+
|
47
|
+
## Contributing
|
48
|
+
|
49
|
+
1. Fork it
|
50
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
51
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
52
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
53
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/clockwork
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'clockwork' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('clockwork', 'clockwork')
|
data/bin/clockworkd
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'clockworkd' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('clockwork', 'clockworkd')
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'observed-clockwork' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('observed-clockwork', 'observed-clockwork')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module OneshotSpec
|
2
|
+
class FooPlugin < Observed::Observer
|
3
|
+
|
4
|
+
plugin_name 'foo'
|
5
|
+
|
6
|
+
default timeout_in_milliseconds: 5000
|
7
|
+
default number_of_trials: 10
|
8
|
+
|
9
|
+
def observe
|
10
|
+
sleep_duration = rand / 20
|
11
|
+
sleep sleep_duration
|
12
|
+
system.report(tag, "Foo #{sleep_duration}")
|
13
|
+
end
|
14
|
+
|
15
|
+
def logger
|
16
|
+
@logger ||= Logger.new(STDOUT)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
Feature: Running Observed inside Clockwork
|
2
|
+
|
3
|
+
In order to integrate Observed with Clockwork,
|
4
|
+
I want to configure Clockwork to run Observed.
|
5
|
+
|
6
|
+
Scenario: Create a .rb file containing Observed code and run it with the ruby command
|
7
|
+
Given a file named "observed.conf" with:
|
8
|
+
"""
|
9
|
+
require 'observed/builtin_plugins'
|
10
|
+
require_relative 'foo_plugin'
|
11
|
+
|
12
|
+
observe 'foo_1', via: 'foo'
|
13
|
+
|
14
|
+
report /foo_1/, via: 'stdout'
|
15
|
+
"""
|
16
|
+
Given a file named "foo_plugin.rb" with:
|
17
|
+
"""
|
18
|
+
module OneshotSpec
|
19
|
+
class FooPlugin < Observed::Observer
|
20
|
+
|
21
|
+
plugin_name 'foo'
|
22
|
+
|
23
|
+
default timeout_in_milliseconds: 5000
|
24
|
+
default number_of_trials: 10
|
25
|
+
|
26
|
+
def observe
|
27
|
+
sleep_duration = rand / 20
|
28
|
+
sleep sleep_duration
|
29
|
+
system.report(tag, "Foo #{sleep_duration}")
|
30
|
+
|
31
|
+
# For testing purpose,
|
32
|
+
# we want the `clockwork` process to exit as soon as we ran Observed to report the test
|
33
|
+
# output to the stdout
|
34
|
+
exit
|
35
|
+
end
|
36
|
+
|
37
|
+
def logger
|
38
|
+
@logger ||= Logger.new(STDOUT)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
"""
|
43
|
+
Given a file named "clockwork.rb" with:
|
44
|
+
"""
|
45
|
+
require 'clockwork'
|
46
|
+
require 'observed/clockwork'
|
47
|
+
|
48
|
+
include Clockwork
|
49
|
+
include Observed::Clockwork
|
50
|
+
|
51
|
+
register_observed_handler :config_file => File.dirname(__FILE__) + '/observed.conf'
|
52
|
+
|
53
|
+
every(10.seconds, 'foo_1')
|
54
|
+
"""
|
55
|
+
When I run `clockwork clockwork.rb`
|
56
|
+
Then the output should contain:
|
57
|
+
"""
|
58
|
+
foo_1 Foo
|
59
|
+
"""
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'clockwork'
|
2
|
+
require 'observed'
|
3
|
+
require "observed/clockwork/version"
|
4
|
+
require "observed/application"
|
5
|
+
|
6
|
+
module Observed
|
7
|
+
module Clockwork
|
8
|
+
extend self
|
9
|
+
|
10
|
+
def register_observed_handler(args)
|
11
|
+
Observed.init!
|
12
|
+
Observed.configure args
|
13
|
+
Observed.load! args[:config_file]
|
14
|
+
::Clockwork.handler do |job|
|
15
|
+
Observed.run job
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'observed/clockwork/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "observed-clockwork"
|
8
|
+
spec.version = Observed::Clockwork::VERSION
|
9
|
+
spec.authors = ["KUOKA Yusuke"]
|
10
|
+
spec.email = ["yusuke.kuoka@gree.net"]
|
11
|
+
spec.description = %q{Observed Clockwork Integration}
|
12
|
+
spec.summary = %q{An integration of Observed with Clockwork}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'clockwork'
|
23
|
+
spec.add_dependency 'daemons'
|
24
|
+
spec.add_dependency 'observed', "~> 0.1.0"
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
26
|
+
spec.add_development_dependency "rake"
|
27
|
+
spec.add_development_dependency "cucumber"
|
28
|
+
spec.add_development_dependency "aruba"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: observed-clockwork
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- KUOKA Yusuke
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: clockwork
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ! '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ! '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: daemons
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: observed
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.1.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.3'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: cucumber
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: aruba
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Observed Clockwork Integration
|
112
|
+
email:
|
113
|
+
- yusuke.kuoka@gree.net
|
114
|
+
executables: []
|
115
|
+
extensions: []
|
116
|
+
extra_rdoc_files: []
|
117
|
+
files:
|
118
|
+
- .gitignore
|
119
|
+
- Gemfile
|
120
|
+
- LICENSE.txt
|
121
|
+
- README.md
|
122
|
+
- Rakefile
|
123
|
+
- bin/clockwork
|
124
|
+
- bin/clockworkd
|
125
|
+
- bin/observed-clockwork
|
126
|
+
- bin/rake
|
127
|
+
- examples/clockwork/clockwork.rb
|
128
|
+
- examples/clockwork/foo_plugin.rb
|
129
|
+
- examples/clockwork/observed.conf
|
130
|
+
- features/run_observed_inside_clockwork.feature
|
131
|
+
- features/support/env.rb
|
132
|
+
- lib/observed/clockwork.rb
|
133
|
+
- lib/observed/clockwork/version.rb
|
134
|
+
- observed-clockwork.gemspec
|
135
|
+
homepage: ''
|
136
|
+
licenses:
|
137
|
+
- MIT
|
138
|
+
metadata: {}
|
139
|
+
post_install_message:
|
140
|
+
rdoc_options: []
|
141
|
+
require_paths:
|
142
|
+
- lib
|
143
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
requirements: []
|
154
|
+
rubyforge_project:
|
155
|
+
rubygems_version: 2.0.5
|
156
|
+
signing_key:
|
157
|
+
specification_version: 4
|
158
|
+
summary: An integration of Observed with Clockwork
|
159
|
+
test_files:
|
160
|
+
- features/run_observed_inside_clockwork.feature
|
161
|
+
- features/support/env.rb
|