industrialist 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
+ SHA256:
3
+ metadata.gz: a5fad57e56ea6791a1f65cb7b0751863fbd1604b36fb460a2409630e8ac72028
4
+ data.tar.gz: 835a243f150b84d0246c89512dd33fc568ad06e639ba7383815ee293b678a909
5
+ SHA512:
6
+ metadata.gz: 28e72909b4878081fe486b24d6ce9508c6f085f7ed1cd19641fe0ce3a918723b65daa98522ece1b4ff93d53d1914bde7d5c1ffd51b76c3dc586e2299697755ac
7
+ data.tar.gz: 51974cba6400f2935906580ee713afdd54d018f592b67c0479ceaa798c96f74365c392957fe77f7b66fe679d592618db0278b345a089641ac08978716faad593
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/.rubocop.yml ADDED
@@ -0,0 +1,336 @@
1
+ # inherit_from: .rubocop_todo.yml
2
+ require: rubocop-rspec
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - bin/**/*
7
+ - .bundle/**/*
8
+ DisplayCopNames: true
9
+ DisplayStyleGuide: true
10
+ TargetRubyVersion: 2.6
11
+
12
+ Documentation:
13
+ Enabled: false
14
+
15
+ RSpec/LetSetup:
16
+ Description: Checks unreferenced `let!` calls being used for test setup.
17
+ Enabled: false
18
+
19
+ RSpec/MultipleExpectations:
20
+ Max: 5
21
+
22
+ Style/RaiseArgs:
23
+ EnforcedStyle: compact
24
+
25
+ Layout/AlignHash:
26
+ EnforcedColonStyle: key
27
+ EnforcedHashRocketStyle: key
28
+
29
+ Layout/AlignParameters:
30
+ EnforcedStyle: with_first_parameter
31
+
32
+ Layout/CaseIndentation:
33
+ EnforcedStyle: case
34
+ SupportedStyles:
35
+ - case
36
+ - end
37
+ IndentOneStep: false
38
+
39
+ Style/CollectionMethods:
40
+ Description: Preferred collection methods.
41
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
42
+ Enabled: false
43
+ PreferredMethods:
44
+ collect: map
45
+ collect!: map!
46
+ detect: find
47
+ find_all: select
48
+ reduce: inject
49
+
50
+ Style/SafeNavigation:
51
+ Enabled: false
52
+
53
+ Style/StringLiterals:
54
+ Enabled: false
55
+ EnforcedStyle: single_quotes
56
+ SupportedStyles:
57
+ - single_quotes
58
+ - double_quotes
59
+
60
+ Layout/DotPosition:
61
+ EnforcedStyle: leading
62
+
63
+ Layout/MultilineMethodCallIndentation:
64
+ EnforcedStyle: indented
65
+
66
+ Naming/FileName:
67
+ Description: Use snake_case for source file names.
68
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
69
+ Enabled: true
70
+
71
+ Style/GuardClause:
72
+ Description: Check for conditionals that can be replaced with guard clauses
73
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
74
+ Enabled: true
75
+ MinBodyLength: 1
76
+
77
+ Style/IfUnlessModifier:
78
+ Description: Favor modifier if/unless usage when you have a single-line body.
79
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
80
+ Enabled: true
81
+
82
+ Style/OptionHash:
83
+ Description: Dont use option hashes when you can use keyword arguments.
84
+ Enabled: false
85
+
86
+ Style/PercentLiteralDelimiters:
87
+ Description: Use `%`-literal delimiters consistently
88
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#percent-literal-braces
89
+ Enabled: true
90
+ PreferredDelimiters:
91
+ "%": "()"
92
+ "%i": "()"
93
+ "%q": "()"
94
+ "%Q": "()"
95
+ "%r": "{}"
96
+ "%s": "()"
97
+ "%w": "()"
98
+ "%W": "()"
99
+ "%x": "()"
100
+
101
+ Naming/PredicateName:
102
+ Description: Check the names of predicate methods.
103
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
104
+ Enabled: true
105
+ NamePrefix:
106
+ - is_
107
+ - has_
108
+ - have_
109
+ NamePrefixBlacklist:
110
+ - is_
111
+ Exclude:
112
+ - spec/**/*
113
+
114
+ Style/FrozenStringLiteralComment:
115
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#magic-comments
116
+ Enabled: false
117
+
118
+ Style/SingleLineMethods:
119
+ Description: Avoid single-line methods.
120
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
121
+ Enabled: true
122
+ AllowIfMethodIsEmpty: true
123
+
124
+ Style/SymbolArray:
125
+ Enabled: false
126
+
127
+ Style/TrailingCommaInArguments:
128
+ Description: 'Checks for trailing comma in argument lists.'
129
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
130
+ Enabled: true
131
+ EnforcedStyleForMultiline: no_comma
132
+ SupportedStylesForMultiline:
133
+ - comma
134
+ - consistent_comma
135
+ - no_comma
136
+
137
+ Style/TrailingCommaInArrayLiteral:
138
+ Description: 'Checks for trailing comma in array literals.'
139
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
140
+ Enabled: true
141
+ EnforcedStyleForMultiline: no_comma
142
+ SupportedStylesForMultiline:
143
+ - comma
144
+ - consistent_comma
145
+ - no_comma
146
+
147
+ Style/TrailingCommaInHashLiteral:
148
+ Description: 'Checks for trailing comma in hash literals.'
149
+ StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
150
+ Enabled: true
151
+ EnforcedStyleForMultiline: no_comma
152
+ SupportedStylesForMultiline:
153
+ - comma
154
+ - consistent_comma
155
+ - no_comma
156
+
157
+ Metrics/AbcSize:
158
+ Description: A calculated magnitude based on number of assignments, branches, and conditions.
159
+ Enabled: true
160
+ Max: 25
161
+
162
+ Metrics/LineLength:
163
+ Enabled: true
164
+ Max: 140
165
+
166
+ Metrics/BlockLength:
167
+ ExcludedMethods:
168
+ - context
169
+ - describe
170
+ Exclude:
171
+ - spec/**/*
172
+
173
+ Metrics/ClassLength:
174
+ Description: Avoid classes longer than 150 lines of code.
175
+ Enabled: true
176
+ CountComments: false
177
+ Max: 150
178
+
179
+ Metrics/ModuleLength:
180
+ Description: Avoid modules longer than 150 lines of code.
181
+ Enabled: true
182
+ CountComments: false
183
+ Max: 150
184
+
185
+ Metrics/CyclomaticComplexity:
186
+ Description: A complexity metric that is strongly correlated to the number of test cases needed to validate a method.
187
+ Enabled: true
188
+ Max: 6
189
+
190
+ Metrics/MethodLength:
191
+ Description: Avoid methods longer than 50 lines of code.
192
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
193
+ Enabled: true
194
+ CountComments: false
195
+ Max: 50
196
+
197
+ Metrics/ParameterLists:
198
+ Description: Avoid parameter lists longer than three or four parameters.
199
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
200
+ Enabled: true
201
+ Max: 5
202
+ CountKeywordArgs: true
203
+
204
+ Metrics/PerceivedComplexity:
205
+ Description: A complexity metric geared towards measuring complexity for a human reader.
206
+ Enabled: true
207
+ Max: 7
208
+
209
+ Lint/AssignmentInCondition:
210
+ Description: Dont use assignment in conditions.
211
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
212
+ Enabled: true
213
+ AllowSafeAssignment: true
214
+
215
+ Naming/AccessorMethodName:
216
+ Description: Check the naming of accessor methods for get_/set_.
217
+ Enabled: true
218
+
219
+ Style/Alias:
220
+ Description: Use alias_method instead of alias.
221
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
222
+ EnforcedStyle: prefer_alias_method
223
+
224
+ Style/ClassAndModuleChildren:
225
+ # Checks the style of children definitions at classes and modules.
226
+ #
227
+ # Basically there are two different styles:
228
+ #
229
+ # `nested` - have each child on a separate line
230
+ # class Foo
231
+ # class Bar
232
+ # end
233
+ # end
234
+ #
235
+ # `compact` - combine definitions as much as possible
236
+ # class Foo::Bar
237
+ # end
238
+ #
239
+ # The compact style is only forced, for classes / modules with one child.
240
+ EnforcedStyle: nested
241
+ SupportedStyles:
242
+ - nested
243
+ - compact
244
+
245
+ Style/DoubleNegation:
246
+ Description: Checks for uses of double negation (!!).
247
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
248
+ Enabled: true
249
+
250
+ Style/EachWithObject:
251
+ Description: Prefer `each_with_object` over `inject` or `reduce`.
252
+ Enabled: true
253
+
254
+ Style/EmptyLiteral:
255
+ Description: Prefer literals to Array.new/Hash.new/String.new.
256
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
257
+ Enabled: true
258
+
259
+ Style/ModuleFunction:
260
+ Description: Checks for usage of `extend self` in modules.
261
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
262
+ Enabled: true
263
+
264
+ Style/OneLineConditional:
265
+ Description: Favor the ternary operator(?:) over if/then/else/end constructs.
266
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
267
+ Enabled: true
268
+
269
+ Style/PerlBackrefs:
270
+ Description: Avoid Perl-style regex back references.
271
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
272
+ Enabled: true
273
+
274
+ Style/Send:
275
+ Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods.
276
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
277
+ Enabled: true
278
+
279
+ Style/SpecialGlobalVars:
280
+ Description: Avoid Perl-style global variables.
281
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
282
+ Enabled: true
283
+
284
+ Style/VariableInterpolation:
285
+ Description: Dont interpolate global, instance and class variables directly in strings.
286
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
287
+ Enabled: true
288
+
289
+ Style/WhenThen:
290
+ Description: Use when x then ... for one-line cases.
291
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
292
+ Enabled: true
293
+
294
+ Lint/EachWithObjectArgument:
295
+ Description: Check for immutable argument given to each_with_object.
296
+ Enabled: true
297
+
298
+ Layout/EmptyLineAfterMagicComment:
299
+ Enabled: false
300
+
301
+ Style/NumericLiterals:
302
+ Enabled: false
303
+
304
+ Lint/HandleExceptions:
305
+ Description: Dont suppress exception.
306
+ StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
307
+ Enabled: true
308
+
309
+ Lint/LiteralAsCondition:
310
+ Description: Checks of literals used in conditions.
311
+ Enabled: true
312
+
313
+ Lint/LiteralInInterpolation:
314
+ Description: Checks for literals used in interpolation.
315
+ Enabled: true
316
+
317
+ Lint/AmbiguousBlockAssociation:
318
+ Description: Checks for ambiguous block association with method when param passed without parentheses.
319
+ Enabled: false
320
+
321
+ RSpec/NestedGroups:
322
+ Enabled: false
323
+
324
+ RSpec/ExampleLength:
325
+ Max: 15
326
+
327
+ RSpec/MessageSpies:
328
+ Description: have_received over to receive
329
+ Enabled: false
330
+
331
+ RSpec/ContextWording:
332
+ Prefixes:
333
+ - when
334
+ - with
335
+ - without
336
+ - and
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.0
7
+ before_install: gem install bundler -v 2.0.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 dev@entelo.com. 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,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ industrialist (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.8.0)
12
+ rspec-core (~> 3.8.0)
13
+ rspec-expectations (~> 3.8.0)
14
+ rspec-mocks (~> 3.8.0)
15
+ rspec-core (3.8.0)
16
+ rspec-support (~> 3.8.0)
17
+ rspec-expectations (3.8.2)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.8.0)
20
+ rspec-mocks (3.8.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.8.0)
23
+ rspec-support (3.8.0)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 2.0)
30
+ industrialist!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 2.0.1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Fito von Zastrow
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,62 @@
1
+ # Industrialist
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/industrialist`. 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 'industrialist'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install industrialist
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ class Automobile
27
+ include Industrialist::FactoryRegistrar
28
+ factory_name :AutomobileFactory
29
+ end
30
+
31
+ class Sedan < Automobile
32
+ corresponds_to :sedan
33
+ end
34
+
35
+ class Coupe < Automobile
36
+ corresponds_to :coupe
37
+ end
38
+
39
+ class Convertible < Automobile
40
+ corresponds_to :convertible
41
+ end
42
+
43
+ AutomobileFactory.build(:convertible)
44
+ ```
45
+
46
+ ## Development
47
+
48
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
49
+
50
+ 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).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/entelo/industrialist. 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.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
59
+
60
+ ## Code of Conduct
61
+
62
+ Everyone interacting in the Industrialist project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/industrialist/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 "industrialist"
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
@@ -0,0 +1,32 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "industrialist/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "industrialist"
7
+ spec.version = Industrialist::VERSION
8
+ spec.platform = Gem::Platform::RUBY
9
+ spec.authors = ["Alan Ridlehoover", "Fito von Zastrow"]
10
+ spec.email = ["dev@entelo.com"]
11
+
12
+ spec.summary = "Industrialist provides dynamic factory registration"
13
+ spec.homepage = "https://github.com/entelo/industrialist"
14
+ spec.license = "MIT"
15
+
16
+ spec.metadata = {
17
+ "bug_tracker_uri" => "https://github.com/entelo/industrialist/issues",
18
+ "homepage_uri" => spec.homepage,
19
+ "source_code_uri" => "https://github.com/entelo/industrialist"
20
+ }
21
+
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_development_dependency "bundler", "~> 2.0"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ end
@@ -0,0 +1,2 @@
1
+ require "industrialist/version"
2
+ require "industrialist/factory_registrar"
@@ -0,0 +1,18 @@
1
+ module Industrialist
2
+ class Factory
3
+ attr_reader :registry
4
+
5
+ def initialize
6
+ @registry = {}
7
+ end
8
+
9
+ def register(key, klass)
10
+ registry[key&.to_sym] = klass
11
+ end
12
+
13
+ def build(event_type, *args)
14
+ klass = registry[event_type&.to_sym]
15
+ klass&.new(*args)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ require 'industrialist/factory'
2
+
3
+ module Industrialist
4
+ module FactoryRegistrar
5
+ def self.included(base)
6
+ base.extend ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ @@factory = Industrialist::Factory.new
11
+
12
+ def factory_name(identifier)
13
+ Object.const_set(identifier, @@factory)
14
+ end
15
+
16
+ def corresponds_to(key)
17
+ @@factory.register(key, self)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Industrialist
2
+ VERSION = '0.1.0'.freeze
3
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: industrialist
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Alan Ridlehoover
8
+ - Fito von Zastrow
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2019-03-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '2.0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '2.0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ description:
57
+ email:
58
+ - dev@entelo.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
66
+ - ".travis.yml"
67
+ - CODE_OF_CONDUCT.md
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE.txt
71
+ - README.md
72
+ - Rakefile
73
+ - bin/console
74
+ - bin/setup
75
+ - industrialist.gemspec
76
+ - lib/industrialist.rb
77
+ - lib/industrialist/factory.rb
78
+ - lib/industrialist/factory_registrar.rb
79
+ - lib/industrialist/version.rb
80
+ homepage: https://github.com/entelo/industrialist
81
+ licenses:
82
+ - MIT
83
+ metadata:
84
+ bug_tracker_uri: https://github.com/entelo/industrialist/issues
85
+ homepage_uri: https://github.com/entelo/industrialist
86
+ source_code_uri: https://github.com/entelo/industrialist
87
+ post_install_message:
88
+ rdoc_options: []
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ requirements: []
102
+ rubygems_version: 3.0.2
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Industrialist provides dynamic factory registration
106
+ test_files: []