bonito 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.
@@ -0,0 +1,94 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bonito
4
+ class Timeline # :nodoc:
5
+ include Enumerable
6
+
7
+ class << self
8
+ attr_reader :scheduler_class
9
+
10
+ def schedule_with(klass)
11
+ @scheduler_class = klass
12
+ end
13
+ end
14
+
15
+ attr_reader :duration
16
+
17
+ def initialize(duration)
18
+ @duration = duration
19
+ @timelines = []
20
+ end
21
+
22
+ def each
23
+ @timelines.each { |timeline| yield timeline }
24
+ end
25
+
26
+ def size
27
+ @timelines.size
28
+ end
29
+
30
+ def scheduler(starting_offset, scope, opts = {})
31
+ self.class.scheduler_class.new self, starting_offset, scope, opts
32
+ end
33
+
34
+ private
35
+
36
+ attr_writer :duration
37
+
38
+ def <<(timeline)
39
+ @timelines << timeline
40
+ end
41
+ end
42
+
43
+ class OffsetTimeline < SimpleDelegator # :nodoc:
44
+ attr_reader :offset
45
+ def initialize(timeline, offset)
46
+ @offset = offset
47
+ super timeline
48
+ end
49
+
50
+ def ==(other)
51
+ offset == other.offset && __getobj__ == other.__getobj__
52
+ end
53
+
54
+ def <=>(other)
55
+ offset <=> other.offset
56
+ end
57
+
58
+ def schedule(starting_offset, scope, opts = {})
59
+ __getobj__.scheduler(starting_offset + offset, scope, opts)
60
+ end
61
+ end
62
+
63
+ class ScopedMoment < OffsetTimeline # :nodoc:
64
+ def initialize(moment, offset, scope)
65
+ @scope = scope
66
+ super moment, offset
67
+ end
68
+
69
+ def evaluate
70
+ freeze { @scope.instance_eval(&self) }
71
+ end
72
+
73
+ private
74
+
75
+ def freeze
76
+ Timecop.freeze(offset) { yield }
77
+ end
78
+ end
79
+
80
+ class Scheduler # :nodoc:
81
+ include Enumerable
82
+
83
+ def initialize(timeline, starting_offset, scope, opts = {})
84
+ @timeline = timeline
85
+ @starting_offset = starting_offset
86
+ @scope = scope
87
+ @opts = opts
88
+ end
89
+
90
+ private
91
+
92
+ attr_reader :timeline, :starting_offset, :scope, :opts
93
+ end
94
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Bonito
4
+ VERSION = '0.1.0'
5
+ end
metadata ADDED
@@ -0,0 +1,251 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bonito
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Finill
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-07-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: algorithms
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-progressbar
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: timecop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '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: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: factory_bot
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: faker
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 1.9.1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 1.9.1
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '12.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '12.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rdoc
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
+ - !ruby/object:Gem::Dependency
140
+ name: reek
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rubocop
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: simplecov
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: Create realistic demo data by simulating events occurring over some time
196
+ period
197
+ email:
198
+ - tomfinill@gmail.com
199
+ executables: []
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - ".codeclimate.yml"
204
+ - ".gitignore"
205
+ - ".reek.yml"
206
+ - ".rspec"
207
+ - ".rubocop.yml"
208
+ - ".ruby-gemset"
209
+ - ".travis.yml"
210
+ - CODE_OF_CONDUCT.md
211
+ - Gemfile
212
+ - LICENSE.txt
213
+ - README.md
214
+ - Rakefile
215
+ - _config.yml
216
+ - bin/console
217
+ - bin/setup
218
+ - bonito.gemspec
219
+ - lib/bonito.rb
220
+ - lib/bonito/moment.rb
221
+ - lib/bonito/parallel_timeline.rb
222
+ - lib/bonito/progress.rb
223
+ - lib/bonito/runner.rb
224
+ - lib/bonito/scope.rb
225
+ - lib/bonito/serial_timeline.rb
226
+ - lib/bonito/timeline.rb
227
+ - lib/bonito/version.rb
228
+ homepage: https://github.com/TomFinill/bonito
229
+ licenses:
230
+ - MIT
231
+ metadata: {}
232
+ post_install_message:
233
+ rdoc_options: []
234
+ require_paths:
235
+ - lib
236
+ required_ruby_version: !ruby/object:Gem::Requirement
237
+ requirements:
238
+ - - ">="
239
+ - !ruby/object:Gem::Version
240
+ version: '0'
241
+ required_rubygems_version: !ruby/object:Gem::Requirement
242
+ requirements:
243
+ - - ">="
244
+ - !ruby/object:Gem::Version
245
+ version: '0'
246
+ requirements: []
247
+ rubygems_version: 3.0.4
248
+ signing_key:
249
+ specification_version: 4
250
+ summary: A simple tool to create demo data
251
+ test_files: []