stormwatch-workflows 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/stormwatch/workflows.rb +27 -0
- data/lib/stormwatch/workflows/base.rb +23 -0
- data/lib/stormwatch/workflows/create_board.rb +38 -0
- data/lib/stormwatch/workflows/create_box.rb +48 -0
- data/lib/stormwatch/workflows/registry.rb +9 -0
- data/lib/stormwatch/workflows/requirements.rb +8 -0
- data/lib/stormwatch/workflows/update_box.rb +46 -0
- data/lib/stormwatch/workflows/version.rb +5 -0
- data/stormwatch-workflows.gemspec +34 -0
- metadata +188 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 03a72fc01c89684e76a3aad9155ae2af899c3572
|
4
|
+
data.tar.gz: 99fe5dd239c5f24bfe5fde58afc775380143e527
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7a6d20a72b1907c8763856582d49ac5ba6dcae11cd95abd20693e03c2a907122ae9063d71f7b6b909e68672c2b10cd535f9bbb15927b8fc8ae78dc68d192f48b
|
7
|
+
data.tar.gz: c3fb0758da8400aa6f71072bc5ae820dd5d557ea1b777af041c960e7ada12d40773b9705345f40e9d3abf2b13f9b6057d75e9b00ece65fda0b2bc6900ebd1b0e
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Dennis Walters
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# Stormwatch::Workflows
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'stormwatch-workflows'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install stormwatch-workflows
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
* create_board
|
22
|
+
* add_box
|
23
|
+
* update_box
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/stormwatch-workflows.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "stormwatch/workflows"
|
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,27 @@
|
|
1
|
+
require "stormwatch/workflows/version"
|
2
|
+
require 'stormwatch/workflows/registry'
|
3
|
+
require 'stormwatch/workflows/create_board'
|
4
|
+
require 'stormwatch/workflows/create_box'
|
5
|
+
require 'stormwatch/workflows/update_box'
|
6
|
+
|
7
|
+
module Stormwatch
|
8
|
+
module Workflows
|
9
|
+
|
10
|
+
def self.config(&blk)
|
11
|
+
yield self
|
12
|
+
self
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.board_storage=(storage)
|
16
|
+
Registry.register('storage.boards', storage)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.box_storage=(storage)
|
20
|
+
Registry.register('storage.boxes', storage)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.token_storage=(storage)
|
24
|
+
Registry.register('storage.tokens', storage)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'wisper'
|
2
|
+
require 'dry-struct'
|
3
|
+
require 'dry-types'
|
4
|
+
require 'stormwatch/workflows/registry'
|
5
|
+
require 'stormwatch/workflows/requirements'
|
6
|
+
|
7
|
+
module Stormwatch
|
8
|
+
module Workflows
|
9
|
+
class Base
|
10
|
+
include Wisper::Publisher
|
11
|
+
|
12
|
+
def call(payload:)
|
13
|
+
end
|
14
|
+
|
15
|
+
class Payload < Dry::Struct
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Types
|
20
|
+
include Dry::Types.module
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'stormwatch/workflows/base'
|
2
|
+
|
3
|
+
module Stormwatch
|
4
|
+
module Workflows
|
5
|
+
class CreateBoard < Base
|
6
|
+
include Requirements[
|
7
|
+
'storage.boards',
|
8
|
+
]
|
9
|
+
|
10
|
+
def call(payload:)
|
11
|
+
payload = Payload.new(payload)
|
12
|
+
|
13
|
+
unless board = boards.create_board(payload.name)
|
14
|
+
broadcast(:failure)
|
15
|
+
return
|
16
|
+
end
|
17
|
+
|
18
|
+
broadcast(
|
19
|
+
:success,
|
20
|
+
{
|
21
|
+
uuid: board.uuid,
|
22
|
+
name: board.name,
|
23
|
+
}
|
24
|
+
)
|
25
|
+
end
|
26
|
+
|
27
|
+
class Payload < Base::Payload
|
28
|
+
attribute :name, String
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
Registry.register(
|
34
|
+
'create_board',
|
35
|
+
-> {CreateBoard.new}
|
36
|
+
)
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'stormwatch/workflows/base'
|
2
|
+
|
3
|
+
module Stormwatch
|
4
|
+
module Workflows
|
5
|
+
class CreateBox < Base
|
6
|
+
include Requirements[
|
7
|
+
'storage.boards',
|
8
|
+
'storage.boxes'
|
9
|
+
]
|
10
|
+
|
11
|
+
def call(payload:)
|
12
|
+
payload = Payload.new(payload)
|
13
|
+
|
14
|
+
board = boards.find_board(payload.uuid)
|
15
|
+
|
16
|
+
if board.nil?
|
17
|
+
broadcast(:not_found)
|
18
|
+
return
|
19
|
+
end
|
20
|
+
|
21
|
+
unless box = boxes.create_box(board.id, payload.content)
|
22
|
+
broadcast(:not_created)
|
23
|
+
return
|
24
|
+
end
|
25
|
+
|
26
|
+
broadcast(
|
27
|
+
:success,
|
28
|
+
{
|
29
|
+
uuid: box.uuid,
|
30
|
+
content: box.content,
|
31
|
+
board_uuid: board.uuid
|
32
|
+
}
|
33
|
+
)
|
34
|
+
end
|
35
|
+
|
36
|
+
class Payload < Base::Payload
|
37
|
+
attribute :uuid, Types::String
|
38
|
+
attribute :content, Types::String
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
Registry.register(
|
44
|
+
'create_box',
|
45
|
+
-> {CreateBox.new}
|
46
|
+
)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'stormwatch/workflows/base'
|
2
|
+
|
3
|
+
module Stormwatch
|
4
|
+
module Workflows
|
5
|
+
class UpdateBox < Base
|
6
|
+
include Requirements[
|
7
|
+
'storage.boxes'
|
8
|
+
]
|
9
|
+
|
10
|
+
def call(payload:)
|
11
|
+
payload = Payload.new(payload)
|
12
|
+
box = boxes.find_box(payload.uuid)
|
13
|
+
|
14
|
+
if box.nil?
|
15
|
+
broadcast(:not_found)
|
16
|
+
return
|
17
|
+
end
|
18
|
+
|
19
|
+
unless box = boxes.update_box(box.id, payload.content)
|
20
|
+
broadcast(:not_updated)
|
21
|
+
return
|
22
|
+
end
|
23
|
+
|
24
|
+
broadcast(
|
25
|
+
:success,
|
26
|
+
{
|
27
|
+
uuid: box.uuid,
|
28
|
+
content: box.content,
|
29
|
+
board_uuid: box.board.uuid
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
class Payload < Base::Payload
|
35
|
+
attribute :uuid, Types::String
|
36
|
+
attribute :content, Types::String
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
Registry.register(
|
42
|
+
'update_box',
|
43
|
+
-> {UpdateBox.new}
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "stormwatch/workflows/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "stormwatch-workflows"
|
8
|
+
spec.version = Stormwatch::Workflows::VERSION
|
9
|
+
spec.authors = ["Dennis Walters"]
|
10
|
+
spec.email = ["dwalters@engineyard.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Workflows for Stormwatch}
|
13
|
+
spec.description = %q{Workflows for Stormwatch}
|
14
|
+
spec.homepage = "https://github.com/ess/stormwatch-workflows"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency 'wisper', '~> 2.0'
|
25
|
+
spec.add_dependency 'dry-struct', '~> 0.3'
|
26
|
+
spec.add_dependency 'dry-types', '~> 0.11'
|
27
|
+
spec.add_dependency 'dry-container', '~> 0.6'
|
28
|
+
spec.add_dependency 'dry-auto_inject', '~> 0.4'
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency 'simplecov', '~> 0.15'
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stormwatch-workflows
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dennis Walters
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-10-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: wisper
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dry-struct
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: dry-types
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.11'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.11'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: dry-container
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.6'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: dry-auto_inject
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.4'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.4'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.15'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.15'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: simplecov
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0.15'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0.15'
|
139
|
+
description: Workflows for Stormwatch
|
140
|
+
email:
|
141
|
+
- dwalters@engineyard.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- ".gitignore"
|
147
|
+
- ".rspec"
|
148
|
+
- ".travis.yml"
|
149
|
+
- Gemfile
|
150
|
+
- LICENSE.txt
|
151
|
+
- README.md
|
152
|
+
- Rakefile
|
153
|
+
- bin/console
|
154
|
+
- bin/setup
|
155
|
+
- lib/stormwatch/workflows.rb
|
156
|
+
- lib/stormwatch/workflows/base.rb
|
157
|
+
- lib/stormwatch/workflows/create_board.rb
|
158
|
+
- lib/stormwatch/workflows/create_box.rb
|
159
|
+
- lib/stormwatch/workflows/registry.rb
|
160
|
+
- lib/stormwatch/workflows/requirements.rb
|
161
|
+
- lib/stormwatch/workflows/update_box.rb
|
162
|
+
- lib/stormwatch/workflows/version.rb
|
163
|
+
- stormwatch-workflows.gemspec
|
164
|
+
homepage: https://github.com/ess/stormwatch-workflows
|
165
|
+
licenses:
|
166
|
+
- MIT
|
167
|
+
metadata: {}
|
168
|
+
post_install_message:
|
169
|
+
rdoc_options: []
|
170
|
+
require_paths:
|
171
|
+
- lib
|
172
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
173
|
+
requirements:
|
174
|
+
- - ">="
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
|
+
requirements:
|
179
|
+
- - ">="
|
180
|
+
- !ruby/object:Gem::Version
|
181
|
+
version: '0'
|
182
|
+
requirements: []
|
183
|
+
rubyforge_project:
|
184
|
+
rubygems_version: 2.6.13
|
185
|
+
signing_key:
|
186
|
+
specification_version: 4
|
187
|
+
summary: Workflows for Stormwatch
|
188
|
+
test_files: []
|