zenaton 0.4.0 → 0.4.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
  SHA256:
3
- metadata.gz: a28c9df01efe5b8a7a242e2d25b12ea713b33895104fc28b61e0359c25a38f60
4
- data.tar.gz: a06c860ed8c3c049ab31005369ac84d37d3fe24f3d2cc7501cd4b6314bcfc591
3
+ metadata.gz: 6e51aae796ecf047bcbc9c4b3b4e4fd971191a1ebee24075b9576df8248c9c3a
4
+ data.tar.gz: a53ce602e5edeab270bebb30b11d108c568c35e1994002376989d1e9a1ce1f3d
5
5
  SHA512:
6
- metadata.gz: 15be902a6bcaf15248c3374eb86439f05a59acb0788cadfe05347bbc159925a2cf73596a9d8cd3519e77961789a888ba46cb66df19f69a60a1325999ac531af8
7
- data.tar.gz: 8a1f6f4f34b040a7c10c5b2f52d8999389b0cde4b0c100ece7784e9e13c8443e173c90616a66cce1c1431afe1a86b6f36d533c01f8219f688d67edc199cfb44e
6
+ metadata.gz: 51cef86daef5b85dd46fbc4d98305d58ad277b4ee36360266a66268ecc86a9ec1fd5d3bc1ec0c0e1702af33c1f2998471f80828f52d9e88f5425512d2767d4f5
7
+ data.tar.gz: 73230ed0fa51c178553ed28a39d24f21841b2f825d558453733de02c71a871a7ca29bfb65bd734f7d0f9db71f4e6035f24f5253bd5eec51f7dfdbd951e0e22a4
@@ -4,6 +4,18 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## [Unreleased]
8
+ ### Changes
9
+
10
+ ### Added
11
+
12
+ ## [0.4.1] - 2019-06-04
13
+ ### Changes
14
+ - Fix symbol json encoding breaking compatibility with some gems
15
+
16
+ ### Added
17
+ - Added `event_data` property when sending event
18
+
7
19
  ## [0.4.0] - 2019-03-25
8
20
  ### Added
9
21
  - Calling `#dispatch` on tasks now allows to process tasks asynchronously
@@ -73,8 +85,9 @@ available.
73
85
  ### Added
74
86
  - Initial release.
75
87
 
76
- [Unreleased]: https://github.com/zenaton/zenaton-ruby/compare/v0.4.0...HEAD
77
- [0.3.1]: https://github.com/zenaton/zenaton-ruby/compare/v0.3.1...v0.4.0
88
+ [Unreleased]: https://github.com/zenaton/zenaton-ruby/compare/v0.4.1...HEAD
89
+ [0.4.1]: https://github.com/zenaton/zenaton-ruby/compare/v0.4.0...v0.4.1
90
+ [0.4.0]: https://github.com/zenaton/zenaton-ruby/compare/v0.3.1...v0.4.0
78
91
  [0.3.1]: https://github.com/zenaton/zenaton-ruby/compare/v0.3.0...v0.3.1
79
92
  [0.3.0]: https://github.com/zenaton/zenaton-ruby/compare/v0.2.3...v0.3.0
80
93
  [0.2.3]: https://github.com/zenaton/zenaton-ruby/compare/v0.2.2...v0.2.3
@@ -1,14 +1,14 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- zenaton (0.4.0)
4
+ zenaton (0.4.1)
5
5
  activesupport
6
6
  tzinfo-data
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (5.2.1)
11
+ activesupport (5.2.3)
12
12
  concurrent-ruby (~> 1.0, >= 1.0.2)
13
13
  i18n (>= 0.7, < 2)
14
14
  minitest (~> 5.1)
@@ -17,13 +17,13 @@ GEM
17
17
  public_suffix (>= 2.0.2, < 4.0)
18
18
  ast (2.4.0)
19
19
  coderay (1.1.2)
20
- concurrent-ruby (1.0.5)
20
+ concurrent-ruby (1.1.5)
21
21
  crack (0.4.3)
22
22
  safe_yaml (~> 1.0.0)
23
23
  diff-lcs (1.3)
24
24
  docile (1.3.1)
25
25
  hashdiff (0.3.7)
26
- i18n (1.1.0)
26
+ i18n (1.6.0)
27
27
  concurrent-ruby (~> 1.0)
28
28
  jaro_winkler (1.5.1)
29
29
  json (2.1.0)
@@ -73,7 +73,7 @@ GEM
73
73
  timecop (0.9.1)
74
74
  tzinfo (1.2.5)
75
75
  thread_safe (~> 0.1)
76
- tzinfo-data (1.2018.5)
76
+ tzinfo-data (1.2019.1)
77
77
  tzinfo (>= 1.0.0)
78
78
  unicode-display_width (1.4.0)
79
79
  vcr (4.0.0)
@@ -99,4 +99,4 @@ DEPENDENCIES
99
99
  zenaton!
100
100
 
101
101
  BUNDLED WITH
102
- 1.16.1
102
+ 1.17.2
data/README.md CHANGED
@@ -1,19 +1,58 @@
1
- # Zenaton library for Ruby
2
- [![Gem Version](https://img.shields.io/gem/v/zenaton.svg)](https://rubygems.org/gems/zenaton)
3
- [![Gem Downloads](https://img.shields.io/gem/dt/zenaton.svg)](https://rubygems.org/gems/zenaton)
4
- [![CircleCI](https://img.shields.io/circleci/project/github/zenaton/zenaton-ruby/master.svg)](https://circleci.com/gh/zenaton/zenaton-ruby/tree/master)
5
- [![License](https://img.shields.io/github/license/zenaton/zenaton-ruby.svg)](LICENSE.txt)
6
-
7
- This Zenaton library for Ruby lets you code and launch workflows using Zenaton platform. You can sign up for an account at [https://zenaton/com](http://zenaton.com)
8
-
9
- **DISCLAIMER** The ruby library is currently in public beta. Please open an
10
- issue if you find any bugs.
11
-
12
- ## Requirements
1
+ <p align="center">
2
+ <img src="https://user-images.githubusercontent.com/36400935/58254828-e5176880-7d6b-11e9-9094-3f46d91faeee.png" /><br>
3
+ Easy Asynchronous Jobs Manager for Developers <br>
4
+ <a href="https://zenaton.com/documentation/ruby/getting-started/">
5
+ <strong> Explore the docs » </strong>
6
+ </a> <br>
7
+ <a href="https://zenaton.com"> Website </a>
8
+ ·
9
+ <a href="https://github.com/zenaton/examples-ruby"> Examples in Ruby </a>
10
+ ·
11
+ <a href="https://app.zenaton.com/tutorial/ruby"> Tutorial in Ruby </a>
12
+
13
+ <p align="center">
14
+ <a href="https://rubygems.org/gems/zenaton"><img src="https://img.shields.io/gem/v/zenaton.svg" alt="Gem Version"></a>
15
+ <a href="https://circleci.com/gh/zenaton/zenaton-ruby/tree/master" rel="nofollow" target="_blank"><img src="https://img.shields.io/circleci/project/github/zenaton/zenaton-ruby/master.svg" alt="CircleCI" style="max-width:100%;"></a>
16
+ <a href="/LICENSE" target="_blank"><img src="https://img.shields.io/github/license/zenaton/zenaton-ruby.svg" alt="License" style="max-width:100%;"></a>
17
+ </p>
18
+ </p>
19
+
20
+ <details>
21
+ <summary><strong>Table of contents</strong></summary>
22
+
23
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
24
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
25
+
26
+ - [Getting Started](#getting-started)
27
+ - [Requirements](#requirements)
28
+ - [Installation](#installation)
29
+ - [Setup with Ruby on Rails](#setup-with-ruby-on-rails)
30
+ - [Client initialization](#client-initialization)
31
+ - [Worker Installation](#worker-installation)
32
+ - [Setup with plain Ruby](#setup-with-plain-ruby)
33
+ - [Client Initialization](#client-initialization)
34
+ - [Worker Installation](#worker-installation-1)
35
+ - [Usage](#usage)
36
+ - [Writing a task](#writing-a-task)
37
+ - [Writing a workflow](#writing-a-workflow)
38
+ - [Lauching a workflow](#lauching-a-workflow)
39
+ - [Documentation](#documentation)
40
+ - [Development](#development)
41
+ - [Contributing](#contributing)
42
+ - [License](#license)
43
+ - [Code of Conduct](#code-of-conduct)
44
+
45
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
46
+
47
+ </details>
48
+
49
+ ## Getting Started
50
+
51
+ ### Requirements
13
52
 
14
53
  This gem has been tested with Ruby 2.3 and later.
15
54
 
16
- ## Installation
55
+ ### Installation
17
56
 
18
57
  Add this line to your application's Gemfile:
19
58
 
@@ -29,58 +68,38 @@ Or install it yourself as:
29
68
 
30
69
  $ gem install zenaton
31
70
 
32
- ## Usage in plain Ruby
71
+ ## Setup with Ruby on Rails
33
72
 
34
- For more detailed examples, please check [Zenaton Ruby examples](https://github.com/zenaton/examples-ruby).
35
-
36
- ### Client Initialization
73
+ ### Client initialization
37
74
 
38
- You will need to export three environment variables: `ZENATON_APP_ID`, `ZENATON_API_TOKEN`, `ZENATON_APP_ENV`. You'll find them [here](https://zenaton/app/api).
75
+ 1. Create an initializer in `config/initializers/zenaton.rb` with the following:
39
76
 
40
- Then you can initialize your Zenaton client:
41
77
  ```ruby
42
- require 'dotenv/load' # We are using dotenv to load the variables from a .env file
43
- require 'zenaton'
44
-
45
- app_id = ENV['ZENATON_APP_ID']
46
- api_token = ENV['ZENATON_API_TOKEN']
47
- app_env = ENV['ZENATON_APP_ENV']
48
-
49
- Zenaton::Client.init(app_id, api_token, app_env)
78
+ Zenaton::Client.init(
79
+ ENV['ZENATON_APP_ID'],
80
+ ENV['ZENATON_API_TOKEN'],
81
+ ENV['ZENATON_APP_ENV']
82
+ )
50
83
  ```
51
84
 
52
- ### Writing Workflows and Tasks
53
-
54
- Writing a workflow is as simple as:
85
+ 2. Add a `.env` file at the root of your project with [your credentials](https://app.zenaton.com/api):
55
86
 
56
- ```ruby
57
- class MyWorkflow < Zenaton::Interfaces::Worflow
58
- include Zenatonable
59
-
60
- def handle
61
- # Your workflow implementation
62
- end
63
- end
64
87
  ```
65
- Note that your workflow implementation should be idempotent. See [documentation](https://zenaton.com/app/documentation#workflow-basics-implementation).
88
+ ZENATON_API_URL=...
89
+ ZENATON_APP_ID=...
90
+ ZENATON_API_TOKEN=...
91
+ ```
66
92
 
67
- Writing a task is as simple as:
68
- ```ruby
69
- class MyTask < Zenaton::Interfaces::Task
70
- include Zenatonable
93
+ Don't forget to add it to your `.gitignore`:
71
94
 
72
- def handle
73
- # Your task implementation
74
- end
75
- end
95
+ ```bash
96
+ $ echo ".env" >> .gitignore
76
97
  ```
77
98
 
78
- ### Launching a workflow
79
-
80
- Once your Zenaton client is initialized, you can start a workflow with
99
+ 3. Add the [dotenv gem](https://github.com/bkeepers/dotenv) to your `Gemfile` to easily load these variables in development:
81
100
 
82
101
  ```ruby
83
- MyWorkflow.new.dispatch
102
+ gem 'dotenv-rails', groups: [:development, :test]
84
103
  ```
85
104
 
86
105
  ### Worker Installation
@@ -89,54 +108,58 @@ Your workflow's tasks will be executed on your worker servers. Please install a
89
108
 
90
109
  $ curl https://install.zenaton.com | sh
91
110
 
92
- that you can start and configure with
111
+ that you can start and configure from your application directory with
93
112
 
94
- $ zenaton start && zenaton listen --env=.env --boot=boot.rb
113
+ $ zenaton start && zenaton listen --env=.env --rails
95
114
 
96
- where `.env` is the env file containing your credentials, and `boot.rb` is a file that will be included before each task execution - this file should load all workflow classes.
115
+ where `.env` is the env file containing [your credentials](https://app.zenaton.com/api).
97
116
 
98
- ## Usage inside a Ruby on Rails application
117
+ **Note** In this example we created our workflows and tasks in the `/app`
118
+ folder since Rails will autoload ruby files in that path. If you create your
119
+ workflows and tasks somewhere else, ensure Rails loads them at boot time.
99
120
 
100
- ### Client initialization
121
+ Your are now ready to [write tasks and workflows](#usage) !
101
122
 
102
- Edit your application secrets with `rails credentials:edit` and add your Zenaton
103
- credentials to it (you'll find them [here](https://zenaton/app/api)). For
104
- example:
105
- ```yml
106
- zenaton:
107
- app_id: 123456
108
- api_token: abcdefgh
109
- ```
123
+ ## Setup with plain Ruby
124
+
125
+ ### Client Initialization
126
+
127
+ You will need to export three environment variables: `ZENATON_APP_ID`, `ZENATON_API_TOKEN`, `ZENATON_APP_ENV`. You'll find them [here](https://app.zenaton.com/api).
128
+
129
+ Then you can initialize your Zenaton client:
110
130
 
111
- Then create an initializer in `config/initializers/zenaton.rb` with the
112
- following:
113
131
  ```ruby
132
+ require 'dotenv/load'
133
+ require 'zenaton'
134
+
114
135
  Zenaton::Client.init(
115
- Rails.application.credentials.zenaton[:app_id],
116
- Rails.application.credentials.zenaton[:api_token],
117
- Rails.env.production? ? 'production' : 'dev'
136
+ ENV['ZENATON_APP_ID'],
137
+ ENV['ZENATON_API_TOKEN'],
138
+ ENV['ZENATON_APP_ENV']
118
139
  )
119
140
  ```
120
141
 
121
- ### Writing Workflows and Tasks
142
+ ### Worker Installation
122
143
 
123
- We can create a workflow in `app/workflows/my_workflow.rb`.
144
+ Your workflow's tasks will be executed on your worker servers. Please install a Zenaton worker on it:
124
145
 
125
- ```ruby
126
- class MyWorkflow < Zenaton::Interfaces::Worflow
127
- include Zenatonable
146
+ $ curl https://install.zenaton.com | sh
128
147
 
129
- def handle
130
- # Your workflow implementation
131
- end
132
- end
133
- ```
134
- Note that your workflow implementation should be idempotent. See [documentation](https://zenaton.com/app/documentation#workflow-basics-implementation).
148
+ that you can start and configure with
149
+
150
+ $ zenaton start && zenaton listen --env=.env --boot=boot.rb
151
+
152
+ where `.env` is the env file containing [your credentials](https://app.zenaton.com/api), and `boot.rb` is a file that will be included before each task execution - this file should load all workflow classes.
153
+
154
+ ## Usage
155
+
156
+ For more detailed examples, please check [Zenaton Ruby examples](https://github.com/zenaton/examples-ruby).
157
+
158
+ ### Writing a task
135
159
 
136
- And we can create a task in `app/tasks/my_task.rb`.
137
160
  ```ruby
138
161
  class MyTask < Zenaton::Interfaces::Task
139
- include Zenatonable
162
+ include Zenaton::Traits::Zenatonable
140
163
 
141
164
  def handle
142
165
  # Your task implementation
@@ -144,32 +167,37 @@ class MyTask < Zenaton::Interfaces::Task
144
167
  end
145
168
  ```
146
169
 
147
- ### Lauching a workflow
170
+ [Check the documentation for more details.](https://zenaton.com/documentation/ruby/tasks)
171
+
172
+ ### Writing a workflow
148
173
 
149
- We can start a workflow from anywhere in our application code with:
150
174
  ```ruby
151
- MyWorkflow.new.dispatch
175
+ class MyWorkflow < Zenaton::Interfaces::Workflow
176
+ include Zenaton::Traits::Zenatonable
177
+
178
+ def handle
179
+ # Your workflow implementation
180
+ end
181
+ end
152
182
  ```
153
183
 
154
- ### Worker Installation
184
+ Note that your workflow implementation should be idempotent.
155
185
 
156
- Your workflow's tasks will be executed on your worker servers. Please install a Zenaton worker on it:
186
+ With Ruby on Rails, you may need to run `$ spring stop` to force Spring to load your app fresh.
157
187
 
158
- $ curl https://install.zenaton.com | sh
188
+ [Check the documentation for more details.](https://zenaton.com/documentation/ruby/workflow-basics)
159
189
 
160
- that you can start and configure from your application directory with
161
-
162
- $ zenaton start && zenaton listen --env=.env --rails
190
+ ### Lauching a workflow
163
191
 
164
- where `.env` is the env file containing your credentials.
192
+ We can start a workflow from anywhere in our application code with:
165
193
 
166
- **Note** In this example we created our workflows and tasks in the `/app`
167
- folder since Rails will autoload ruby files in that path. If you create your
168
- workflows and tasks somewhere else, ensure Rails loads them at boot time.
194
+ ```ruby
195
+ MyWorkflow.new.dispatch
196
+ ```
169
197
 
170
198
  ## Documentation
171
199
 
172
- Please see https://zenaton.com/documentation for complete documentation.
200
+ Please see https://zenaton.com/documentation/ruby/getting-started for complete documentation.
173
201
 
174
202
  ## Development
175
203
 
@@ -33,8 +33,9 @@ module Zenaton
33
33
 
34
34
  PROG = 'Ruby' # The current programming language
35
35
 
36
- EVENT_INPUT = 'event_input' # Parameter name for event data
36
+ EVENT_INPUT = 'event_input' # Parameter name for event input
37
37
  EVENT_NAME = 'event_name' # Parameter name for event name
38
+ EVENT_DATA = 'event_data' # Parameter name for event data
38
39
 
39
40
  WORKFLOW_KILL = 'kill' # Worker update mode to stop a worker
40
41
  WORKFLOW_PAUSE = 'pause' # Worker udpate mode to pause a worker
@@ -174,7 +175,8 @@ module Zenaton
174
175
  ATTR_NAME => workflow_name,
175
176
  ATTR_ID => custom_id,
176
177
  EVENT_NAME => event.class.name,
177
- EVENT_INPUT => @serializer.encode(@properties.from(event))
178
+ EVENT_INPUT => @serializer.encode(@properties.from(event)),
179
+ EVENT_DATA => @serializer.encode(event)
178
180
  }
179
181
  @http.post(send_event_url, body)
180
182
  end
@@ -1,7 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'singleton'
4
- require 'json/add/core'
4
+ require 'json/add/date'
5
+ require 'json/add/date_time'
6
+ require 'json/add/exception'
7
+ require 'json/add/range'
8
+ require 'json/add/regexp'
9
+ require 'json/add/struct'
10
+ require 'json/add/time'
5
11
  require 'json/add/rational'
6
12
  require 'json/add/complex'
7
13
  require 'json/add/bigdecimal'
@@ -97,14 +103,22 @@ module Zenaton
97
103
  end
98
104
 
99
105
  def from_complex_type(object)
100
- JSON.parse(object.to_json).tap do |attributes|
101
- attributes.delete('json_class')
106
+ if object.is_a?(Symbol)
107
+ { 's' => object.to_s }
108
+ else
109
+ JSON.parse(object.to_json).tap do |attributes|
110
+ attributes.delete('json_class')
111
+ end
102
112
  end
103
113
  end
104
114
 
105
115
  def set_complex_type(object, props)
106
- props['json_class'] = object.class.name
107
- JSON(props.to_json)
116
+ if object.is_a?(Symbol)
117
+ props['s'].to_sym
118
+ else
119
+ props['json_class'] = object.class.name
120
+ JSON(props.to_json)
121
+ end
108
122
  end
109
123
 
110
124
  def special_case?(object)
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Zenaton
4
4
  # This gem's current version
5
- VERSION = '0.4.0'
5
+ VERSION = '0.4.1'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenaton
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zenaton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-03-25 00:00:00.000000000 Z
11
+ date: 2019-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport