workflow_rb-mongo 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: 2480f3c7bbaa178bc5e0eb79c9de603af5ed5c91
4
+ data.tar.gz: ff14b46d5258369edd692176e6bb97d4c825f606
5
+ SHA512:
6
+ metadata.gz: fa43df7558c1da7ddf0a7111e8ee80d718739606f433db4567e515752f9dabb5bcdf962e4c97dd10842a24da6901dc9f23c1cc56f1f3b4a773035d5aae90151b
7
+ data.tar.gz: 3bd0fff9f02716d57b011cb7866b06a8f8bb5046bb7503e144012494e86034a2bd140a1e8194497f3c10beb6934c20c80f65f8a4bb064fcea6656364fdb4b8df
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in workflow_rb-mongo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Daniel Gerlag
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,41 @@
1
+ # WorkflowRb::Mongo
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/workflow_rb/mongo`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'workflow_rb-mongo'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install workflow_rb-mongo
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. 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]/workflow_rb-mongo.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "workflow_rb/mongo"
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
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,79 @@
1
+ require 'mongoid'
2
+ require 'yaml'
3
+ require 'workflow_rb'
4
+ require 'workflow_rb/mongo/persisted_workflow'
5
+ require 'workflow_rb/mongo/persisted_event_subscription'
6
+ require 'workflow_rb/mongo/persisted_event_publication'
7
+
8
+ module WorkflowRb
9
+ module Mongo
10
+ class MongoPersistenceProvider
11
+
12
+ def initialize
13
+ end
14
+
15
+ def create_new_workflow(workflow)
16
+ p = PersistedWorkflow.new
17
+ workflow.fill_persisted(p)
18
+ p.save
19
+ workflow.id = p._id
20
+ p._id
21
+ end
22
+
23
+ def persist_workflow(workflow)
24
+ existing = PersistedWorkflow.find(workflow.id)
25
+ workflow.fill_persisted(existing)
26
+ existing.save
27
+ end
28
+
29
+ def get_workflow_instance(id)
30
+ existing = PersistedWorkflow.find(id)
31
+ existing.to_object
32
+ end
33
+
34
+ def get_runnable_instances
35
+ PersistedWorkflow
36
+ .where(status: WorkflowRb::WorkflowStatus::RUNNABLE)
37
+ .and(:next_execution.lte => Time.new)
38
+ end
39
+
40
+ def create_subscription(subscription)
41
+ p = PersistedEventSubscription.new
42
+ subscription.fill_persisted(p)
43
+ p.save
44
+ subscription.id = p._id
45
+ p._id
46
+ end
47
+
48
+ def get_subscriptions(event_name, event_key)
49
+ PersistedEventSubscription
50
+ .where(event_name: event_name)
51
+ .and(event_key: event_key)
52
+ end
53
+
54
+ def terminate_subscription(id)
55
+ existing = PersistedEventSubscription.find(id)
56
+ existing.delete
57
+ end
58
+
59
+ def create_unpublished_event(pub)
60
+ p = PersistedEventPublication.new
61
+ pub.fill_persisted(p)
62
+ p.save
63
+ pub.id = p._id
64
+ p._id
65
+ end
66
+
67
+ def remove_unpublished_event(id)
68
+ existing = PersistedEventPublication.find(id)
69
+ existing.delete
70
+ end
71
+
72
+ def get_unpublished_events
73
+ PersistedEventPublication.all
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+
@@ -0,0 +1,41 @@
1
+ require 'mongoid'
2
+ require 'yaml'
3
+ require 'workflow_rb'
4
+
5
+ module WorkflowRb
6
+ module Mongo
7
+ class PersistedEventPublication
8
+ include Mongoid::Document
9
+ store_in collection: "unpublished_events", client: "workflow_rb"
10
+
11
+ field :workflow_id
12
+ field :step_id
13
+ field :event_name
14
+ field :event_key
15
+ field :event_data
16
+
17
+ def to_object
18
+ result = WorkflowRb::EventPublication.new
19
+ result.id = self._id
20
+ result.workflow_id = self.workflow_id
21
+ result.step_id = self.step_id
22
+ result.event_name = self.event_name
23
+ result.event_key = self.event_key
24
+ result.event_data = self.event_data
25
+ result
26
+ end
27
+ end
28
+ end
29
+
30
+ class EventPublication
31
+ def fill_persisted(result)
32
+ result.workflow_id = @workflow_id
33
+ result.step_id = @step_id
34
+ result.event_name = @event_name
35
+ result.event_key = @event_key
36
+ result.event_data = @event_data
37
+ result
38
+ end
39
+ end
40
+ end
41
+
@@ -0,0 +1,38 @@
1
+ require 'mongoid'
2
+ require 'yaml'
3
+ require 'workflow_rb'
4
+
5
+ module WorkflowRb
6
+ module Mongo
7
+ class PersistedEventSubscription
8
+ include Mongoid::Document
9
+ store_in collection: "subscriptions", client: "workflow_rb"
10
+
11
+ field :workflow_id
12
+ field :step_id
13
+ field :event_name
14
+ field :event_key
15
+
16
+ def to_object
17
+ result = WorkflowRb::EventSubscription.new
18
+ result.id = self._id
19
+ result.workflow_id = self.workflow_id
20
+ result.step_id = self.step_id
21
+ result.event_name = self.event_name
22
+ result.event_key = self.event_key
23
+ result
24
+ end
25
+ end
26
+ end
27
+
28
+ class EventSubscription
29
+ def fill_persisted(result)
30
+ result.workflow_id = @workflow_id
31
+ result.step_id = @step_id
32
+ result.event_name = @event_name
33
+ result.event_key = @event_key
34
+ result
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,56 @@
1
+ require 'mongoid'
2
+ require 'yaml'
3
+ require 'workflow_rb'
4
+
5
+ module WorkflowRb
6
+ module Mongo
7
+ class PersistedWorkflow
8
+ include Mongoid::Document
9
+ store_in collection: "workflows", client: "workflow_rb"
10
+
11
+ field :definition_id
12
+ field :version
13
+ field :description
14
+ field :execution_pointers
15
+ field :next_execution
16
+ field :status
17
+ field :data
18
+ field :create_time
19
+ field :complete_time
20
+
21
+ def to_object
22
+ result = WorkflowRb::WorkflowInstance.new
23
+ result.id = self._id
24
+ result.definition_id = self.definition_id
25
+ result.version = self.version
26
+ result.description = self.description
27
+ result.execution_pointers = YAML.load(self.execution_pointers)
28
+ result.next_execution = self.next_execution
29
+ result.status = self.status
30
+ result.data = YAML.load(self.data)
31
+ result.create_time = self.create_time
32
+ result.complete_time = self.complete_time
33
+ result
34
+ end
35
+
36
+ end
37
+ end
38
+
39
+ class WorkflowInstance
40
+
41
+ def fill_persisted(result)
42
+ #result._id = @id
43
+ result.definition_id = @definition_id
44
+ result.version = @version
45
+ result.description = @description
46
+ result.execution_pointers = YAML.dump(@execution_pointers)
47
+ result.next_execution = @next_execution
48
+ result.status = @status
49
+ result.data = YAML.dump(@data)
50
+ result.create_time = @create_time
51
+ result.complete_time = @complete_time
52
+ result
53
+ end
54
+ end
55
+ end
56
+
@@ -0,0 +1,5 @@
1
+ module WorkflowRb
2
+ module Mongo
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,8 @@
1
+ require 'workflow_rb/mongo/version'
2
+ require 'workflow_rb/mongo/mongo_persistence_provider'
3
+
4
+ module WorkflowRb
5
+ module Mongo
6
+ # Your code goes here...
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'workflow_rb/mongo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "workflow_rb-mongo"
8
+ spec.version = WorkflowRb::Mongo::VERSION
9
+ spec.authors = ["Daniel Gerlag"]
10
+ spec.email = ["daniel@gerlag.ca"]
11
+
12
+ spec.summary = %q{MongoDB persistence provider for workflow_rb}
13
+ spec.homepage = "http://github.com/danielgerlag/workflow_rb"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_dependency "mongoid", "~> 6.0.3"
24
+ spec.add_dependency "workflow_rb", "~> 0.1.0"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.13"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workflow_rb-mongo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Daniel Gerlag
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-12-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mongoid
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: workflow_rb
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.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.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ description:
70
+ email:
71
+ - daniel@gerlag.ca
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - Gemfile
78
+ - LICENSE.txt
79
+ - README.md
80
+ - Rakefile
81
+ - bin/console
82
+ - bin/setup
83
+ - lib/workflow_rb/mongo.rb
84
+ - lib/workflow_rb/mongo/mongo_persistence_provider.rb
85
+ - lib/workflow_rb/mongo/persisted_event_publication.rb
86
+ - lib/workflow_rb/mongo/persisted_event_subscription.rb
87
+ - lib/workflow_rb/mongo/persisted_workflow.rb
88
+ - lib/workflow_rb/mongo/version.rb
89
+ - workflow_rb-mongo.gemspec
90
+ homepage: http://github.com/danielgerlag/workflow_rb
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.6.7
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: MongoDB persistence provider for workflow_rb
114
+ test_files: []