archfiend 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.github/PULL_REQUEST_TEMPLATE.md +18 -0
  3. data/.gitignore +12 -0
  4. data/.rspec +4 -0
  5. data/.rubocop.yml +323 -0
  6. data/.travis.yml +11 -0
  7. data/CHANGES.md +12 -0
  8. data/CODE_OF_CONDUCT.md +74 -0
  9. data/Gemfile +7 -0
  10. data/Gemfile.lock +122 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +114 -0
  13. data/ROADMAP.md +11 -0
  14. data/Rakefile +6 -0
  15. data/archfiend.gemspec +35 -0
  16. data/bin/console +14 -0
  17. data/bin/setup +8 -0
  18. data/exe/archfiend +4 -0
  19. data/lib/archfiend.rb +18 -0
  20. data/lib/archfiend/application.rb +132 -0
  21. data/lib/archfiend/cli.rb +9 -0
  22. data/lib/archfiend/generators/daemon.rb +144 -0
  23. data/lib/archfiend/generators/daemon/templates/.rspec +4 -0
  24. data/lib/archfiend/generators/daemon/templates/.rubocop.yml +323 -0
  25. data/lib/archfiend/generators/daemon/templates/Gemfile.tt +32 -0
  26. data/lib/archfiend/generators/daemon/templates/README.md.tt +23 -0
  27. data/lib/archfiend/generators/daemon/templates/Rakefile.tt +13 -0
  28. data/lib/archfiend/generators/daemon/templates/app/clockwork/clockwork.rb.tt +14 -0
  29. data/lib/archfiend/generators/daemon/templates/app/models/application_record.rb +3 -0
  30. data/lib/archfiend/generators/daemon/templates/app/subprocess_loops/foo_subprocess_loop.rb +13 -0
  31. data/lib/archfiend/generators/daemon/templates/app/thread_loops/bar_thread_loop.rb +8 -0
  32. data/lib/archfiend/generators/daemon/templates/bin/console +3 -0
  33. data/lib/archfiend/generators/daemon/templates/bin/start.tt +6 -0
  34. data/lib/archfiend/generators/daemon/templates/config/application.rb.tt +27 -0
  35. data/lib/archfiend/generators/daemon/templates/config/boot.rb.tt +3 -0
  36. data/lib/archfiend/generators/daemon/templates/config/daemon.rb.tt +18 -0
  37. data/lib/archfiend/generators/daemon/templates/config/database.yml.example.tt +26 -0
  38. data/lib/archfiend/generators/daemon/templates/config/environment.rb.tt +4 -0
  39. data/lib/archfiend/generators/daemon/templates/config/settings.yml.tt +8 -0
  40. data/lib/archfiend/generators/daemon/templates/config/settings/development.yml.tt +2 -0
  41. data/lib/archfiend/generators/daemon/templates/config/settings/production.yml.tt +2 -0
  42. data/lib/archfiend/generators/daemon/templates/config/settings/staging.yml.tt +5 -0
  43. data/lib/archfiend/generators/daemon/templates/config/settings/test.yml.tt +0 -0
  44. data/lib/archfiend/generators/daemon/templates/db/migrate/.gitkeep +0 -0
  45. data/lib/archfiend/generators/daemon/templates/lib/tasks/.gitkeep +0 -0
  46. data/lib/archfiend/generators/daemon/templates/log/.gitkeep +0 -0
  47. data/lib/archfiend/generators/daemon/templates/spec/factories/.gitkeep +0 -0
  48. data/lib/archfiend/generators/daemon/templates/spec/models/.gitkeep +0 -0
  49. data/lib/archfiend/generators/daemon/templates/spec/spec_helper.rb +43 -0
  50. data/lib/archfiend/generators/daemon/templates/spec/subprocess_loops/foo_subprocess_loop_spec.rb +5 -0
  51. data/lib/archfiend/generators/daemon/templates/spec/support/factory_bot.rb +9 -0
  52. data/lib/archfiend/generators/daemon/templates/spec/support/timecop.rb +9 -0
  53. data/lib/archfiend/generators/daemon/templates/spec/thread_loops/bar_thread_loop_spec.rb +5 -0
  54. data/lib/archfiend/generators/daemon/templates/tmp/.gitkeep +0 -0
  55. data/lib/archfiend/generators/extensions.rb +119 -0
  56. data/lib/archfiend/generators/options.rb +51 -0
  57. data/lib/archfiend/generators/utils.rb +37 -0
  58. data/lib/archfiend/logging.rb +38 -0
  59. data/lib/archfiend/logging/base_formatter.rb +35 -0
  60. data/lib/archfiend/logging/default_formatter.rb +12 -0
  61. data/lib/archfiend/logging/json_formatter.rb +21 -0
  62. data/lib/archfiend/logging/multi_logger.rb +31 -0
  63. data/lib/archfiend/shared_loop/runnable.rb +26 -0
  64. data/lib/archfiend/subprocess_loop.rb +46 -0
  65. data/lib/archfiend/thread_loop.rb +35 -0
  66. data/lib/archfiend/version.rb +3 -0
  67. data/scripts/travis/install +13 -0
  68. data/scripts/travis/script +43 -0
  69. metadata +280 -0
@@ -0,0 +1,9 @@
1
+ require 'thor'
2
+
3
+ module Archfiend
4
+ class CLI < Thor
5
+ package_name "Archfiend (#{Archfiend::VERSION})"
6
+
7
+ register(Generators::Daemon, 'new', 'new DAEMON_NAME', 'Bootstraps a new daemon named DAEMON_NAME')
8
+ end
9
+ end
@@ -0,0 +1,144 @@
1
+ require 'active_support/inflector'
2
+ require 'thor'
3
+
4
+ module Archfiend
5
+ module Generators
6
+ class Daemon < Thor::Group
7
+ include Thor::Actions
8
+
9
+ argument :daemon_name
10
+
11
+ # @return Path to templates, used by Thor
12
+ def self.source_root
13
+ File.join(File.dirname(__FILE__), 'daemon', 'templates')
14
+ end
15
+
16
+ # Creates a new daemon
17
+ def create
18
+ # Init phase, creating directory structure and applying templates
19
+ extensions.run_with_init_callbacks do
20
+ create_from_templates
21
+ end
22
+ # Exec phase, running any due setup
23
+ extensions.run_with_exec_callbacks do
24
+ bundle_install unless skip_bundle_install?
25
+ end
26
+ end
27
+
28
+ no_commands do
29
+ # @param source [String] relative path to the template to be processed
30
+ # @return [String] the evaluated template contents
31
+ def processed_template_contents(source)
32
+ context = instance_eval('binding')
33
+ source = File.expand_path(find_in_source_paths(source))
34
+ CapturableERB.new(::File.binread(source), nil, '-', '@output_buffer').tap do |erb|
35
+ erb.filename = source
36
+ end.result(context)
37
+ end
38
+
39
+ # @return [Pathname] The absolute path of the newly created daemon
40
+ def daemon_destination_dir
41
+ Pathname.new(File.expand_path(File.join(Dir.pwd, daemon_name)))
42
+ end
43
+
44
+ # @return [Pathname] Path from which Archfiend was started
45
+ def current_dir
46
+ Pathname.new(File.expand_path(Dir.pwd))
47
+ end
48
+
49
+ def daemon_path
50
+ Pathname.new(daemon_name)
51
+ end
52
+ end
53
+
54
+ private
55
+
56
+ def generator_options
57
+ @generator_options ||= Options.new(args)
58
+ end
59
+
60
+ def extensions
61
+ @extensions ||= Extensions.new(generator_options, self, 'daemon')
62
+ end
63
+
64
+ def create_from_templates
65
+ %w[readme rakefile gemfile app bin config_directory db lib log spec tmp rubocop].each { |action| __send__(action) }
66
+ end
67
+
68
+ def camelized_daemon_name
69
+ @camelized_daemon_name ||= daemon_name.camelize
70
+ end
71
+
72
+ # @return Relative path to this gem, to be used in the Gemfile
73
+ def relative_archfiend_path
74
+ gem_dir = Pathname.new(File.expand_path(File.join('..', '..', '..'), __dir__))
75
+
76
+ gem_dir.relative_path_from(daemon_destination_dir)
77
+ end
78
+
79
+ def readme
80
+ template 'README.md', daemon_path.join('Readme.md')
81
+ end
82
+
83
+ def rakefile
84
+ template 'Rakefile', daemon_path.join('Rakefile')
85
+ end
86
+
87
+ def gemfile
88
+ template 'Gemfile', daemon_path.join('Gemfile')
89
+ end
90
+
91
+ def app
92
+ directory 'app', daemon_path.join('app')
93
+ end
94
+
95
+ def bin
96
+ directory 'bin', daemon_path.join('bin')
97
+
98
+ chmod daemon_path.join('bin', 'start'), 'a+x'
99
+ chmod daemon_path.join('bin', 'console'), 'a+x'
100
+ end
101
+
102
+ def config_directory
103
+ directory 'config', daemon_path.join('config')
104
+ end
105
+
106
+ def db
107
+ directory 'db', daemon_path.join('db')
108
+ end
109
+
110
+ def lib
111
+ directory 'lib', daemon_path.join('lib')
112
+ end
113
+
114
+ def log
115
+ directory 'log', daemon_path.join('log')
116
+ end
117
+
118
+ def spec
119
+ template '.rspec', daemon_path.join('.rspec')
120
+ directory 'spec', daemon_path.join('spec')
121
+ end
122
+
123
+ def rubocop
124
+ template '.rubocop.yml', daemon_path.join('.rubocop.yml')
125
+ end
126
+
127
+ def tmp
128
+ empty_directory daemon_path.join('tmp')
129
+ end
130
+
131
+ def bundle_install
132
+ Bundler.with_clean_env do
133
+ inside daemon_name do
134
+ run 'bundle install'
135
+ end
136
+ end
137
+ end
138
+
139
+ def skip_bundle_install?
140
+ false
141
+ end
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,4 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
4
+ --order random
@@ -0,0 +1,323 @@
1
+ require:
2
+ - rubocop-rspec
3
+
4
+ AllCops:
5
+ Exclude:
6
+ - 'db/**/*'
7
+ - 'log/**/*'
8
+ - 'script/**/*'
9
+ - 'tmp/**/*'
10
+ DisplayCopNames: true
11
+ TargetRubyVersion: 2.4
12
+
13
+ ClassAndModuleChildren:
14
+ Enabled: false
15
+
16
+ ClassLength:
17
+ Enabled: false
18
+
19
+ Documentation:
20
+ Enabled: false
21
+
22
+ EmptyLinesAroundClassBody:
23
+ Enabled: false
24
+
25
+ EmptyLinesAroundModuleBody:
26
+ Enabled: false
27
+
28
+ LineLength:
29
+ Enabled: false
30
+
31
+ MethodLength:
32
+ Enabled: false
33
+
34
+ MultilineMethodCallIndentation:
35
+ EnforcedStyle: indented
36
+
37
+ MultilineOperationIndentation:
38
+ EnforcedStyle: indented
39
+
40
+ PercentLiteralDelimiters:
41
+ PreferredDelimiters:
42
+ '%r': '{}'
43
+ '%i': '[]'
44
+ '%w': '[]'
45
+ '%W': '[]'
46
+ '%Q': '{}'
47
+
48
+ PredicateName:
49
+ Enabled: false
50
+
51
+ Rails:
52
+ Enabled: true
53
+
54
+ SignalException:
55
+ EnforcedStyle: semantic
56
+
57
+ SpaceBeforeFirstArg:
58
+ Enabled: false
59
+
60
+ SpaceInsideHashLiteralBraces:
61
+ EnforcedStyle: no_space
62
+
63
+ TrailingCommaInArguments:
64
+ EnforcedStyleForMultiline: no_comma
65
+
66
+ Style/TrailingCommaInArrayLiteral:
67
+ EnforcedStyleForMultiline: no_comma
68
+
69
+ Style/TrailingCommaInHashLiteral:
70
+ EnforcedStyleForMultiline: no_comma
71
+
72
+ Bundler/OrderedGems:
73
+ Enabled: false
74
+
75
+ Lint/AmbiguousBlockAssociation:
76
+ Enabled: false
77
+
78
+ Layout/AlignHash:
79
+ Enabled: false
80
+
81
+ Layout/EmptyLineAfterMagicComment:
82
+ Enabled: false
83
+
84
+ Layout/EmptyLinesAroundArguments:
85
+ Enabled: false
86
+
87
+ Lint/InterpolationCheck:
88
+ Enabled: false
89
+
90
+ Layout/SpaceBeforeBlockBraces:
91
+ EnforcedStyleForEmptyBraces: space
92
+
93
+ Layout/SpaceInsideArrayLiteralBrackets:
94
+ Enabled: false
95
+
96
+ Lint/MissingCopEnableDirective:
97
+ Enabled: false
98
+
99
+ Lint/UriEscapeUnescape:
100
+ Enabled: false
101
+
102
+ Lint/Void:
103
+ Enabled: false
104
+
105
+ Metrics/BlockLength:
106
+ Enabled: false
107
+
108
+ Metrics/ModuleLength:
109
+ Exclude:
110
+ - "**/*_spec.rb"
111
+
112
+ Naming/HeredocDelimiterNaming:
113
+ Enabled: false
114
+
115
+ Rails/ApplicationRecord:
116
+ Enabled: true
117
+ Exclude:
118
+ - db/migrate/*.rb
119
+
120
+ Rails/EnvironmentComparison:
121
+ Enabled: false
122
+
123
+ Rails/HasManyOrHasOneDependent:
124
+ Enabled: false
125
+
126
+ Rails/InverseOf:
127
+ Enabled: false
128
+
129
+ Rails/LexicallyScopedActionFilter:
130
+ Enabled: false
131
+
132
+ Rails/Presence:
133
+ Enabled: false
134
+
135
+ Rails/ReadWriteAttribute:
136
+ Enabled: false
137
+
138
+ Rails/RedundantReceiverInWithOptions:
139
+ Enabled: false
140
+
141
+ Rails/SkipsModelValidations:
142
+ Exclude:
143
+ - "**/*_spec.rb"
144
+ - "**/spec/**/*"
145
+ - "features/**/*"
146
+ - "lib/tasks/**/*"
147
+
148
+ Rails/UnknownEnv:
149
+ Environments:
150
+ - development
151
+ - production
152
+ - staging
153
+ - test
154
+
155
+ RSpec/AnyInstance:
156
+ Enabled: false
157
+
158
+ RSpec/BeEql:
159
+ Enabled: false
160
+
161
+ RSpec/ContextWording:
162
+ Enabled: true
163
+ Prefixes:
164
+ - when
165
+ - with
166
+ - without
167
+
168
+ RSpec/DescribeClass:
169
+ Enabled: false
170
+
171
+ RSpec/DescribedClass:
172
+ Enabled: true
173
+ SkipBlocks: true
174
+
175
+ RSpec/DescribeMethod:
176
+ Enabled: false
177
+
178
+ RSpec/EmptyExampleGroup:
179
+ Enabled: true
180
+ CustomIncludeMethods:
181
+ - requires_ability
182
+ - it_counts
183
+ - it_counts_as_read
184
+ - it_count_as_unread
185
+ - it_does_not_count
186
+ - specify_with_schedule
187
+
188
+ RSpec/EmptyLineAfterFinalLet:
189
+ Enabled: false
190
+
191
+ RSpec/EmptyLineAfterSubject:
192
+ Enabled: false
193
+
194
+ RSpec/ExampleLength:
195
+ Enabled: false
196
+
197
+ RSpec/ExampleWording:
198
+ Enabled: true
199
+
200
+ RSpec/ExpectActual:
201
+ Enabled: true
202
+
203
+ RSpec/ExpectOutput:
204
+ Enabled: true
205
+
206
+ RSpec/Focus:
207
+ Enabled: true
208
+
209
+ RSpec/HookArgument:
210
+ Enabled: true
211
+
212
+ RSpec/ImplicitExpect:
213
+ Enabled: true
214
+
215
+ RSpec/InstanceVariable:
216
+ Enabled: true
217
+
218
+ RSpec/LeadingSubject:
219
+ Enabled: true
220
+
221
+ RSpec/LetSetup:
222
+ Enabled: false
223
+
224
+ RSpec/MessageChain:
225
+ Enabled: false
226
+
227
+ RSpec/MessageExpectation:
228
+ Enabled: false
229
+
230
+ RSpec/MessageSpies:
231
+ Enabled: false
232
+
233
+ RSpec/MultipleDescribes:
234
+ Enabled: true
235
+
236
+ RSpec/MultipleExpectations:
237
+ Enabled: false
238
+
239
+ RSpec/NamedSubject:
240
+ Enabled: false
241
+
242
+ RSpec/NestedGroups:
243
+ Enabled: false
244
+
245
+ RSpec/NotToNot:
246
+ Enabled: false
247
+
248
+ RSpec/RepeatedDescription:
249
+ Enabled: true
250
+
251
+ RSpec/RepeatedExample:
252
+ Enabled: true
253
+
254
+ RSpec/ScatteredLet:
255
+ Enabled: false
256
+
257
+ RSpec/SingleArgumentMessageChain:
258
+ Enabled: true
259
+
260
+ RSpec/ScatteredSetup:
261
+ Enabled: true
262
+
263
+ RSpec/SubjectStub:
264
+ Enabled: false
265
+
266
+ RSpec/VerifiedDoubles:
267
+ Enabled: true
268
+
269
+ Style/BracesAroundHashParameters:
270
+ EnforcedStyle: context_dependent
271
+
272
+ Style/CommentedKeyword:
273
+ Enabled: false
274
+
275
+ Style/DateTime:
276
+ Enabled: false
277
+
278
+ Style/EmptyLambdaParameter:
279
+ Enabled: false
280
+
281
+ Style/EmptyMethod:
282
+ EnforcedStyle: expanded
283
+
284
+ Style/Encoding:
285
+ Enabled: true
286
+
287
+ Style/EvalWithLocation:
288
+ Enabled: false
289
+
290
+ Style/FrozenStringLiteralComment:
291
+ Enabled: false
292
+
293
+ Style/Lambda:
294
+ Enabled: false
295
+
296
+ Style/FormatStringToken:
297
+ Enabled: false
298
+
299
+ Style/MethodCallWithArgsParentheses:
300
+ Enabled: false
301
+
302
+ Style/MixinUsage:
303
+ Enabled: true
304
+ Exclude:
305
+ - 'spec/support/**/*'
306
+
307
+ Style/NumericPredicate:
308
+ Enabled: false
309
+
310
+ Style/OptionHash:
311
+ Enabled: true
312
+
313
+ Style/RandomWithOffset:
314
+ Enabled: false
315
+
316
+ Style/RescueStandardError:
317
+ Enabled: false
318
+
319
+ Style/Send:
320
+ Enabled: true
321
+
322
+ Style/UnneededPercentQ:
323
+ Enabled: true