sequins 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 14c15143764376e5ecb64708ec4c9670c90875a1
4
+ data.tar.gz: 7083d2dc1f443fe4e2a0d8567c93473c4350d37d
5
+ SHA512:
6
+ metadata.gz: affb4f22e0d4b666c5f34ff088ec1c543e6d7f78f8123e54024da1abf3f546e94d2abbfa373f3af045aafd19d8411e51755e662f205f890c86088fcebead83ab
7
+ data.tar.gz: 7c70de46d724f2a97c511f0d7e4c41e477ee4a1f060ded4c82bf2d2981bf36e3729000bf30a404ca2b77e8335c52d313689e05a190d0161f7c42d45e98a366f4
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at pete@petekeen.net. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in sequins.gemspec
6
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,159 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ sequins (0.1.0)
5
+ autoloaded (~> 2)
6
+ docile
7
+ rails (>= 5.0)
8
+ tod
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ actioncable (5.2.1)
14
+ actionpack (= 5.2.1)
15
+ nio4r (~> 2.0)
16
+ websocket-driver (>= 0.6.1)
17
+ actionmailer (5.2.1)
18
+ actionpack (= 5.2.1)
19
+ actionview (= 5.2.1)
20
+ activejob (= 5.2.1)
21
+ mail (~> 2.5, >= 2.5.4)
22
+ rails-dom-testing (~> 2.0)
23
+ actionpack (5.2.1)
24
+ actionview (= 5.2.1)
25
+ activesupport (= 5.2.1)
26
+ rack (~> 2.0)
27
+ rack-test (>= 0.6.3)
28
+ rails-dom-testing (~> 2.0)
29
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
30
+ actionview (5.2.1)
31
+ activesupport (= 5.2.1)
32
+ builder (~> 3.1)
33
+ erubi (~> 1.4)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
36
+ activejob (5.2.1)
37
+ activesupport (= 5.2.1)
38
+ globalid (>= 0.3.6)
39
+ activemodel (5.2.1)
40
+ activesupport (= 5.2.1)
41
+ activerecord (5.2.1)
42
+ activemodel (= 5.2.1)
43
+ activesupport (= 5.2.1)
44
+ arel (>= 9.0)
45
+ activestorage (5.2.1)
46
+ actionpack (= 5.2.1)
47
+ activerecord (= 5.2.1)
48
+ marcel (~> 0.3.1)
49
+ activesupport (5.2.1)
50
+ concurrent-ruby (~> 1.0, >= 1.0.2)
51
+ i18n (>= 0.7, < 2)
52
+ minitest (~> 5.1)
53
+ tzinfo (~> 1.1)
54
+ arel (9.0.0)
55
+ autoloaded (2.2.1)
56
+ builder (3.2.3)
57
+ concurrent-ruby (1.0.5)
58
+ crass (1.0.4)
59
+ diff-lcs (1.3)
60
+ docile (1.3.1)
61
+ erubi (1.7.1)
62
+ globalid (0.4.1)
63
+ activesupport (>= 4.2.0)
64
+ i18n (1.1.0)
65
+ concurrent-ruby (~> 1.0)
66
+ loofah (2.2.2)
67
+ crass (~> 1.0.2)
68
+ nokogiri (>= 1.5.9)
69
+ mail (2.7.0)
70
+ mini_mime (>= 0.1.1)
71
+ marcel (0.3.2)
72
+ mimemagic (~> 0.3.2)
73
+ method_source (0.9.0)
74
+ mimemagic (0.3.2)
75
+ mini_mime (1.0.1)
76
+ mini_portile2 (2.3.0)
77
+ minitest (5.11.3)
78
+ nio4r (2.3.1)
79
+ nokogiri (1.8.4)
80
+ mini_portile2 (~> 2.3.0)
81
+ rack (2.0.5)
82
+ rack-test (1.1.0)
83
+ rack (>= 1.0, < 3)
84
+ rails (5.2.1)
85
+ actioncable (= 5.2.1)
86
+ actionmailer (= 5.2.1)
87
+ actionpack (= 5.2.1)
88
+ actionview (= 5.2.1)
89
+ activejob (= 5.2.1)
90
+ activemodel (= 5.2.1)
91
+ activerecord (= 5.2.1)
92
+ activestorage (= 5.2.1)
93
+ activesupport (= 5.2.1)
94
+ bundler (>= 1.3.0)
95
+ railties (= 5.2.1)
96
+ sprockets-rails (>= 2.0.0)
97
+ rails-dom-testing (2.0.3)
98
+ activesupport (>= 4.2.0)
99
+ nokogiri (>= 1.6)
100
+ rails-html-sanitizer (1.0.4)
101
+ loofah (~> 2.2, >= 2.2.2)
102
+ railties (5.2.1)
103
+ actionpack (= 5.2.1)
104
+ activesupport (= 5.2.1)
105
+ method_source
106
+ rake (>= 0.8.7)
107
+ thor (>= 0.19.0, < 2.0)
108
+ rake (10.5.0)
109
+ rspec (3.8.0)
110
+ rspec-core (~> 3.8.0)
111
+ rspec-expectations (~> 3.8.0)
112
+ rspec-mocks (~> 3.8.0)
113
+ rspec-core (3.8.0)
114
+ rspec-support (~> 3.8.0)
115
+ rspec-expectations (3.8.1)
116
+ diff-lcs (>= 1.2.0, < 2.0)
117
+ rspec-support (~> 3.8.0)
118
+ rspec-mocks (3.8.0)
119
+ diff-lcs (>= 1.2.0, < 2.0)
120
+ rspec-support (~> 3.8.0)
121
+ rspec-rails (3.8.0)
122
+ actionpack (>= 3.0)
123
+ activesupport (>= 3.0)
124
+ railties (>= 3.0)
125
+ rspec-core (~> 3.8.0)
126
+ rspec-expectations (~> 3.8.0)
127
+ rspec-mocks (~> 3.8.0)
128
+ rspec-support (~> 3.8.0)
129
+ rspec-support (3.8.0)
130
+ sprockets (3.7.2)
131
+ concurrent-ruby (~> 1.0)
132
+ rack (> 1, < 3)
133
+ sprockets-rails (3.2.1)
134
+ actionpack (>= 4.0)
135
+ activesupport (>= 4.0)
136
+ sprockets (>= 3.0.0)
137
+ thor (0.20.0)
138
+ thread_safe (0.3.6)
139
+ timecop (0.9.1)
140
+ tod (2.1.1)
141
+ tzinfo (1.2.5)
142
+ thread_safe (~> 0.1)
143
+ websocket-driver (0.7.0)
144
+ websocket-extensions (>= 0.1.0)
145
+ websocket-extensions (0.1.3)
146
+
147
+ PLATFORMS
148
+ ruby
149
+
150
+ DEPENDENCIES
151
+ bundler (~> 1.16)
152
+ rake (~> 10.0)
153
+ rspec (~> 3.5)
154
+ rspec-rails (~> 3.5)
155
+ sequins!
156
+ timecop
157
+
158
+ BUNDLED WITH
159
+ 1.16.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 egghead.io LLC
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,104 @@
1
+ # Sequins
2
+
3
+ Sequences allows you to define temporal sequences of actions.
4
+ A sequence is one or more steps that run in any order you choose with any delay between them you choose.
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'sequins'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install sequins
21
+
22
+ ## Usage
23
+
24
+ ### Create a Sequence Class
25
+
26
+ A basic sequence class looks like this:
27
+
28
+ ```ruby
29
+ class ExampleSequence < Sequins::Base
30
+ sequence do
31
+ step :start, initial: true do
32
+ ExampleMailer.example_message(target.id).deliver_later
33
+
34
+ delay 3.days, then: :step_2
35
+ end
36
+
37
+ step :step2 do
38
+ ExampleMailer.example_step_2(target.id).deliver_later
39
+ end_sequence
40
+ end
41
+ end
42
+ end
43
+ ```
44
+
45
+ ### Delay Options
46
+
47
+ The first argument to `delay` is always an interval, usually expressed as a number of days. Ex: `3.days`.
48
+ In addition, it can take these arguments:
49
+
50
+ * `then` (always required) this tells delay which step to run next
51
+ * `at` specifies a time relative to the user's local timezone to run the next step
52
+ * `only` limits what days to send on. Currently the only valid option is `:weekdays`
53
+
54
+ ### Trigger a Sequence
55
+
56
+ To trigger a sequence, call the `trigger` class method and pass in the target.
57
+ For example, if we want to trigger the example sequence for Joel, we'd do this:
58
+
59
+ ```ruby
60
+ ExampleSequence.trigger(User.find_by(email: 'joel@egghead.io'))
61
+ ```
62
+
63
+ ### Hooks
64
+
65
+ Sequences can define hooks. The available hooks are:
66
+
67
+ ```
68
+ before_each_step # runs before every step.
69
+ before_sequence # runs before the sequence starts.
70
+ after_sequence # runs after the sequence ends with an explicit `end_sequence`
71
+ ```
72
+
73
+ Hooks are run in the same way steps are, so you have access to the `user` object if you want it.
74
+
75
+ ## Configuration
76
+
77
+ ```ruby
78
+ # in config/initializers/sequins.rb
79
+
80
+ Sequins.configure do |config|
81
+ # Specify the default time zone in tz format.
82
+ # If you are using Sequins inside Rails this will be set to Rails.configuration.time_zone.
83
+ # You can also change this per-target by providing a `local_time_zone` method on your target.
84
+ config.default_time_zone = 'America/Chicago'
85
+ end
86
+ ```
87
+
88
+ ## Development
89
+
90
+ 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.
91
+
92
+ 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).
93
+
94
+ ## Contributing
95
+
96
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eggheadio/sequins. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
97
+
98
+ ## License
99
+
100
+ Copyright (c) egghead.io LLC. The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
101
+
102
+ ## Code of Conduct
103
+
104
+ Everyone interacting in the Sequins project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/eggheadio/sequins/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "sequins"
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,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
data/lib/sequins.rb ADDED
@@ -0,0 +1,26 @@
1
+ require 'docile'
2
+ require 'tod'
3
+ require 'tod/core_extensions'
4
+ require 'active_job'
5
+ require 'active_support'
6
+ require 'autoloaded'
7
+
8
+ module Sequins
9
+ Autoloaded.module { }
10
+
11
+ class << self
12
+ attr_writer :configuration
13
+ end
14
+
15
+ def self.configuration
16
+ @configuration ||= Configuration.new
17
+ end
18
+
19
+ def self.reset
20
+ @configuration = Configuration.new
21
+ end
22
+
23
+ def self.configure
24
+ yield configuration
25
+ end
26
+ end
@@ -0,0 +1,28 @@
1
+ module Sequins
2
+ class Base
3
+ def self.sequence(&block)
4
+ if block_given?
5
+ @_sequence = Docile.dsl_eval(SequenceBuilder.new(self), &block).build
6
+ after_sequence_build(@_sequence) if respond_to?(:after_sequence_build)
7
+ else
8
+ @_sequence
9
+ end
10
+ end
11
+
12
+ def self.sequence_name
13
+ self.to_s.underscore.gsub(/_sequence$/, '')
14
+ end
15
+
16
+ def self.trigger(target)
17
+ sequence.trigger(target)
18
+ end
19
+
20
+ def trigger(target)
21
+ self.class.trigger(target)
22
+ end
23
+
24
+ def run_step_for_target(step_name, target)
25
+ self.class.sequence.run_step_for_target(step_name, target)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,13 @@
1
+ module Sequins
2
+ class Configuration
3
+ attr_accessor :default_time_zone
4
+
5
+ def initialize
6
+ if Object.const_defined?('Rails') && !Rails.configuration.time_zone.nil?
7
+ self.default_time_zone = Rails.configuration.time_zone
8
+ else
9
+ self.default_time_zone = 'America/Chicago'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module Sequins
2
+ class DelayWorker < ActiveJob::Base
3
+ def perform(sequence_class_name, target_class_name, target_id, next_step)
4
+ sequence_class = sequence_class_name.constantize
5
+ target = target_class_name.constantize.find(target_id)
6
+
7
+ sequence_class.new.run_step_for_target(next_step.to_sym, target)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,4 @@
1
+ module Sequins
2
+ class UnknownStepError < StandardError; end
3
+ end
4
+
@@ -0,0 +1,108 @@
1
+ module Sequins
2
+ class Sequence
3
+ StepProxy = Struct.new(:options, :block)
4
+
5
+ attr_reader :klass
6
+
7
+ def initialize(klass)
8
+ @klass = klass
9
+ @steps = {}
10
+ @before_each_step_hooks = []
11
+ @before_sequence_hooks = []
12
+ @after_sequence_hooks = []
13
+ end
14
+
15
+ def add_step(name, options={}, &block)
16
+ @steps[name] = StepProxy.new(options, block)
17
+ end
18
+
19
+ def add_before_each_step_hook(&block)
20
+ @before_each_step_hooks << StepProxy.new({}, block)
21
+ end
22
+
23
+ def add_before_sequence_hook(&block)
24
+ @before_sequence_hooks << StepProxy.new({}, block)
25
+ end
26
+
27
+ def add_after_sequence_hook(&block)
28
+ @after_sequence_hooks << StepProxy.new({}, block)
29
+ end
30
+
31
+ def run_step_for_target(step_name, target)
32
+ proxy = @steps[step_name]
33
+ raise UnknownStepError.new(step_name) if proxy.nil?
34
+
35
+ unless run_before_each_step_hooks_for_target(target)
36
+ run_after_sequence_hooks_for_target(target)
37
+ return false
38
+ end
39
+
40
+ step = Docile.dsl_eval(Step.new(target, self), &(proxy.block))
41
+ if step.sequence_ended?
42
+ run_after_sequence_hooks_for_target(target)
43
+ return false
44
+ end
45
+ end
46
+
47
+ def run_before_each_step_hooks_for_target(target)
48
+ @before_each_step_hooks.each do |hook|
49
+ step = Docile.dsl_eval(Step.new(target, self), &(hook.block))
50
+ return false if step.sequence_ended?
51
+ end
52
+ end
53
+
54
+ def run_before_sequence_hooks_for_target(target)
55
+ @before_sequence_hooks.each do |hook|
56
+ step = Docile.dsl_eval(Step.new(target, self), &(hook.block))
57
+ return false if step.sequence_ended?
58
+ end
59
+ end
60
+
61
+ def run_after_sequence_hooks_for_target(target)
62
+ @after_sequence_hooks.each do |hook|
63
+ step = Docile.dsl_eval(Step.new(target, self), &(hook.block))
64
+ return false if step.sequence_ended?
65
+ end
66
+ end
67
+
68
+ def delay(duration, target, options)
69
+ if target.respond_to?(:local_time_zone)
70
+ zone = ActiveSupport::TimeZone[target.local_time_zone]
71
+ else
72
+ zone = ActiveSupport::TimeZone[Sequins.configuration.default_time_zone]
73
+ end
74
+
75
+ delay_until = zone.now + duration
76
+
77
+ if options[:only] == :weekdays
78
+ current_wday = delay_until.wday
79
+
80
+ if current_wday == 0
81
+ delay_until += 1.day
82
+ elsif current_wday == 6
83
+ delay_until += 2.days
84
+ end
85
+ end
86
+
87
+ if !options[:at].nil?
88
+ tod = Tod::TimeOfDay.parse(options[:at])
89
+ delay_until = delay_until.to_date.at(tod, zone)
90
+ end
91
+
92
+ next_step = options[:then]
93
+
94
+ Sequins::DelayWorker.set(wait_until: delay_until).perform_later(@klass.to_s, target.class.to_s, target.id, next_step.to_s)
95
+ end
96
+
97
+ def trigger(target)
98
+ unless run_before_sequence_hooks_for_target(target)
99
+ run_after_sequence_hooks_for_target(target)
100
+ return false
101
+ end
102
+
103
+ step_name, _ = @steps.detect { |_, s| s.options[:initial] }
104
+ run_step_for_target(step_name, target)
105
+ end
106
+
107
+ end
108
+ end
@@ -0,0 +1,29 @@
1
+ module Sequins
2
+ class SequenceBuilder
3
+ def initialize(klass)
4
+ @seq = Sequence.new(klass)
5
+ @klass = klass
6
+ end
7
+
8
+ def step(name, options={}, &block)
9
+ @seq.add_step(name, options, &block)
10
+ self
11
+ end
12
+
13
+ def before_each_step(&block)
14
+ @seq.add_before_each_step_hook(&block)
15
+ end
16
+
17
+ def before_sequence(&block)
18
+ @seq.add_before_sequence_hook(&block)
19
+ end
20
+
21
+ def after_sequence(&block)
22
+ @seq.add_after_sequence_hook(&block)
23
+ end
24
+
25
+ def build
26
+ @seq
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,22 @@
1
+ module Sequins
2
+ class Step
3
+ attr_reader :target
4
+
5
+ def initialize(target, sequence)
6
+ @target = target
7
+ @sequence = sequence
8
+ end
9
+
10
+ def end_sequence
11
+ @ended = true
12
+ end
13
+
14
+ def delay(duration, options)
15
+ @sequence.delay(duration, target, options)
16
+ end
17
+
18
+ def sequence_ended?
19
+ @ended
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module Sequins
2
+ VERSION = "0.1.0"
3
+ end
data/sequins.gemspec ADDED
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "sequins/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "sequins"
8
+ spec.version = Sequins::VERSION
9
+ spec.authors = ["Pete Keen"]
10
+ spec.email = ["pete@egghead.io"]
11
+
12
+ spec.summary = %q{Sequins allows you to define temporal sequences of actions}
13
+ spec.description = %q{Set up sequences of actions that are delayed in time}
14
+ spec.homepage = "https://opensource.egghead.io/sequins"
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 "docile"
25
+ spec.add_dependency "tod"
26
+ spec.add_dependency "autoloaded", "~> 2"
27
+ spec.add_dependency "rails", ">= 5.0"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.16"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.5"
32
+ spec.add_development_dependency "rspec-rails", "~> 3.5"
33
+ spec.add_development_dependency "timecop"
34
+ end
metadata ADDED
@@ -0,0 +1,191 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sequins
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Pete Keen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-08-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: docile
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: tod
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: autoloaded
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '5.0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '5.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.16'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.16'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec-rails
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.5'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.5'
125
+ - !ruby/object:Gem::Dependency
126
+ name: timecop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Set up sequences of actions that are delayed in time
140
+ email:
141
+ - pete@egghead.io
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".gitignore"
147
+ - ".rspec"
148
+ - ".travis.yml"
149
+ - CODE_OF_CONDUCT.md
150
+ - Gemfile
151
+ - Gemfile.lock
152
+ - LICENSE.txt
153
+ - README.md
154
+ - Rakefile
155
+ - bin/console
156
+ - bin/setup
157
+ - lib/sequins.rb
158
+ - lib/sequins/base.rb
159
+ - lib/sequins/configuration.rb
160
+ - lib/sequins/delay_worker.rb
161
+ - lib/sequins/errors.rb
162
+ - lib/sequins/sequence.rb
163
+ - lib/sequins/sequence_builder.rb
164
+ - lib/sequins/step.rb
165
+ - lib/sequins/version.rb
166
+ - sequins.gemspec
167
+ homepage: https://opensource.egghead.io/sequins
168
+ licenses:
169
+ - MIT
170
+ metadata: {}
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubyforge_project:
187
+ rubygems_version: 2.6.13
188
+ signing_key:
189
+ specification_version: 4
190
+ summary: Sequins allows you to define temporal sequences of actions
191
+ test_files: []