jobshop 0.0.157 → 0.0.163
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -1
- data/app/email_handlers/jobshop/rfq_handler.rb +43 -0
- data/app/models/jobshop/collection.rb +6 -11
- data/app/models/jobshop/company.rb +25 -12
- data/app/models/jobshop/company/type.rb +17 -0
- data/app/models/jobshop/company_person.rb +15 -0
- data/app/models/jobshop/inspection.rb +2 -0
- data/app/models/jobshop/inspection/boolean_criterion.rb +13 -10
- data/app/models/jobshop/inspection/criterion.rb +8 -11
- data/app/models/jobshop/inspection/deviation_criterion.rb +13 -10
- data/app/models/jobshop/inspection/limit_criterion.rb +9 -7
- data/app/models/jobshop/inspection/report.rb +11 -15
- data/app/models/jobshop/inspection/result.rb +9 -5
- data/app/models/jobshop/inspection/tuple.rb +7 -3
- data/app/models/jobshop/mailman.rb +11 -0
- data/app/models/jobshop/order.rb +12 -14
- data/app/models/jobshop/order_line.rb +10 -5
- data/app/models/jobshop/organization.rb +35 -8
- data/app/models/jobshop/person.rb +30 -0
- data/app/models/jobshop/place.rb +3 -1
- data/app/models/jobshop/product.rb +10 -12
- data/app/models/jobshop/rfq.rb +22 -0
- data/app/models/jobshop/rfq_line.rb +12 -0
- data/app/models/jobshop/role.rb +6 -13
- data/app/models/jobshop/role_assignment.rb +4 -2
- data/app/models/jobshop/routing_process.rb +8 -11
- data/app/models/jobshop/routing_step.rb +4 -2
- data/app/models/jobshop/thing.rb +6 -11
- data/app/models/jobshop/user.rb +10 -17
- data/db/migrate/20170311194758_initialize_jobshop.rb +3 -1
- data/db/migrate/20171216021339_create_organizations.rb +4 -2
- data/db/migrate/20171216021554_create_people.rb +48 -0
- data/db/migrate/20171216021853_create_companies.rb +47 -8
- data/db/migrate/20171216022020_create_places.rb +3 -3
- data/db/migrate/20171216022135_create_products.rb +5 -3
- data/db/migrate/20171216022605_create_orders.rb +9 -7
- data/db/migrate/20171216023018_create_roles.rb +18 -16
- data/db/migrate/20171216023022_create_sessions.rb +9 -7
- data/db/migrate/20171216035357_create_things.rb +7 -5
- data/db/migrate/20171219022118_create_routing_processes.rb +10 -8
- data/db/migrate/{20180107203241_create_inspection.rb → 20180107203241_create_inspections.rb} +21 -16
- data/db/migrate/20181117023949_create_rfqs.rb +40 -0
- data/db/migrate/20181118014603_create_mailmen.rb +29 -0
- data/exe/jobshop +1 -1
- data/lib/generators/jobshop/app/app_generator.rb +12 -23
- data/lib/generators/jobshop/app/templates/Procfile.tt +1 -0
- data/lib/generators/jobshop/config/templates/config/initializers/jobshop.rb.tt +5 -0
- data/lib/generators/jobshop/dummy/dummy_generator.rb +4 -5
- data/lib/jobshop.rb +8 -4
- data/lib/jobshop/cli.rb +58 -47
- data/lib/jobshop/configuration.rb +17 -5
- data/lib/jobshop/dummy_app.rb +27 -15
- data/lib/jobshop/engine.rb +28 -15
- data/lib/jobshop/helpers/migration.rb +6 -2
- data/lib/jobshop/postmaster.rb +89 -0
- data/lib/jobshop/version.rb +2 -2
- data/lib/tasks/jobshop_tasks.rake +11 -0
- metadata +83 -16
- data/db/migrate/20171216021717_create_users.rb +0 -30
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
1
3
|
module Jobshop
|
2
4
|
module Helpers
|
3
5
|
module Migration
|
@@ -13,8 +15,10 @@ module Jobshop
|
|
13
15
|
end
|
14
16
|
|
15
17
|
def fk_created_by_id(table_name)
|
16
|
-
foreign_key table_name, :
|
17
|
-
|
18
|
+
foreign_key table_name, :jobshop_people, {
|
19
|
+
organization_id: :organization_id,
|
20
|
+
created_by_id: :person_id
|
21
|
+
}
|
18
22
|
end
|
19
23
|
|
20
24
|
def nested_set_attrs(table_name)
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# frozen_string_literals: true
|
2
|
+
|
3
|
+
require "aws-sdk-s3"
|
4
|
+
require "mail"
|
5
|
+
require "shoryuken"
|
6
|
+
|
7
|
+
module Jobshop
|
8
|
+
# Jobshop::Postmaster
|
9
|
+
#
|
10
|
+
# Reponsible for processing incoming email and dispatching it to its handler.
|
11
|
+
class Postmaster
|
12
|
+
include Shoryuken::Worker
|
13
|
+
|
14
|
+
shoryuken_options queue: Jobshop.configuration.aws.incoming_email_queue
|
15
|
+
|
16
|
+
def perform(sqs_msg, *)
|
17
|
+
@event = S3EventMessage.new(sqs_msg.body) || return
|
18
|
+
tempfile = Tempfile.new
|
19
|
+
|
20
|
+
s3.get_object({ bucket: @event.bucket, key: @event.key }, target: tempfile)
|
21
|
+
|
22
|
+
message = Mail.new(File.read(tempfile))
|
23
|
+
recipient = Mail::Address.new(message.to.first)
|
24
|
+
mailbox = recipient.local.split("+").first
|
25
|
+
handler_address = "#{mailbox}@#{recipient.domain}"
|
26
|
+
mailman = Mailman.find_by(address: handler_address)
|
27
|
+
|
28
|
+
# TODO: If no mailman registered, look for domain. If no domain found
|
29
|
+
# TODO: treat as spam.
|
30
|
+
if mailman
|
31
|
+
klass = mailman.handler_type.constantize
|
32
|
+
handler = klass.new(message, organization: mailman.organization)
|
33
|
+
success = handler.process
|
34
|
+
if success
|
35
|
+
copy_to(handler.processed_copy_prefix) if handler.copy_after_processing?
|
36
|
+
delete_incoming if handler.delete_after_processing?
|
37
|
+
sqs_msg.delete
|
38
|
+
end
|
39
|
+
else
|
40
|
+
return
|
41
|
+
end
|
42
|
+
|
43
|
+
ensure
|
44
|
+
@event = nil
|
45
|
+
tempfile.close
|
46
|
+
tempfile.unlink
|
47
|
+
end
|
48
|
+
|
49
|
+
def s3
|
50
|
+
@s3 ||= Aws::S3::Client.new
|
51
|
+
end
|
52
|
+
|
53
|
+
def copy_to(prefix)
|
54
|
+
key = prefix + "/" + @event.key.split("/").last
|
55
|
+
|
56
|
+
s3.copy_object({
|
57
|
+
copy_source: @event.bucket + "/" + @event.key,
|
58
|
+
bucket: Jobshop.configuration.aws.s3_bucket,
|
59
|
+
key: key
|
60
|
+
}) || raise("Could not copy incoming rfq to processed folder")
|
61
|
+
end
|
62
|
+
|
63
|
+
def delete_incoming
|
64
|
+
s3.delete_object({
|
65
|
+
bucket: @event.bucket, key: @event.key
|
66
|
+
}) || raise("Could not delete incoming email")
|
67
|
+
end
|
68
|
+
|
69
|
+
class S3EventMessage
|
70
|
+
def initialize(message)
|
71
|
+
@message = JSON.parse(message)
|
72
|
+
|
73
|
+
return false unless records
|
74
|
+
end
|
75
|
+
|
76
|
+
def records
|
77
|
+
@records ||= @message["Records"] || []
|
78
|
+
end
|
79
|
+
|
80
|
+
def bucket
|
81
|
+
records.first.dig "s3", "bucket", "name"
|
82
|
+
end
|
83
|
+
|
84
|
+
def key
|
85
|
+
records.first.dig "s3", "object", "key"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/lib/jobshop/version.rb
CHANGED
@@ -6,10 +6,10 @@ module Jobshop
|
|
6
6
|
module VERSION
|
7
7
|
MAJOR = 0
|
8
8
|
MINOR = 0
|
9
|
-
TINY =
|
9
|
+
TINY = 163
|
10
10
|
PRE = nil
|
11
11
|
|
12
|
-
CODE_NAME = "
|
12
|
+
CODE_NAME = "prime time to bump the version"
|
13
13
|
STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
|
14
14
|
end
|
15
15
|
end
|
@@ -22,6 +22,17 @@ namespace :jobshop do
|
|
22
22
|
puts "#{organization_name} | #{organization.id}"
|
23
23
|
end
|
24
24
|
end
|
25
|
+
|
26
|
+
desc "Start Incoming Email Worker"
|
27
|
+
task postmaster: :environment do
|
28
|
+
queue_name = Jobshop.configuration.aws.incoming_email_queue
|
29
|
+
postmaster_path = File.join(Jobshop::Engine.root, "lib", "jobshop", "postmaster.rb")
|
30
|
+
|
31
|
+
exec <<~SHELL
|
32
|
+
bundle exec \
|
33
|
+
shoryuken -R -q #{queue_name} -r #{postmaster_path}
|
34
|
+
SHELL
|
35
|
+
end
|
25
36
|
end
|
26
37
|
|
27
38
|
%w( db:migrate db:rollback db:migrate:up db:migrate:down ).each do |t|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jobshop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.163
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank J. Mattia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord_json_validator
|
@@ -24,20 +24,48 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.2.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: aws-sdk-s3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.24.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.24.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-sqs
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.9.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.9.0
|
27
55
|
- !ruby/object:Gem::Dependency
|
28
56
|
name: composite_primary_keys
|
29
57
|
requirement: !ruby/object:Gem::Requirement
|
30
58
|
requirements:
|
31
59
|
- - "~>"
|
32
60
|
- !ruby/object:Gem::Version
|
33
|
-
version: 11.
|
61
|
+
version: 11.1.0
|
34
62
|
type: :runtime
|
35
63
|
prerelease: false
|
36
64
|
version_requirements: !ruby/object:Gem::Requirement
|
37
65
|
requirements:
|
38
66
|
- - "~>"
|
39
67
|
- !ruby/object:Gem::Version
|
40
|
-
version: 11.
|
68
|
+
version: 11.1.0
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: fast_jsonapi
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -72,14 +100,14 @@ dependencies:
|
|
72
100
|
requirements:
|
73
101
|
- - '='
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version: 5.2.
|
103
|
+
version: 5.2.1
|
76
104
|
type: :runtime
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
108
|
- - '='
|
81
109
|
- !ruby/object:Gem::Version
|
82
|
-
version: 5.2.
|
110
|
+
version: 5.2.1
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
112
|
name: rack-cors
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,20 +136,48 @@ dependencies:
|
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
138
|
version: 5.0.2
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: shoryuken
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 4.0.0
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 4.0.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: statesman
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 3.5.0
|
160
|
+
type: :runtime
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 3.5.0
|
111
167
|
- !ruby/object:Gem::Dependency
|
112
168
|
name: unitwise
|
113
169
|
requirement: !ruby/object:Gem::Requirement
|
114
170
|
requirements:
|
115
|
-
- - "
|
171
|
+
- - "~>"
|
116
172
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
173
|
+
version: 2.2.0
|
118
174
|
type: :runtime
|
119
175
|
prerelease: false
|
120
176
|
version_requirements: !ruby/object:Gem::Requirement
|
121
177
|
requirements:
|
122
|
-
- - "
|
178
|
+
- - "~>"
|
123
179
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
180
|
+
version: 2.2.0
|
125
181
|
- !ruby/object:Gem::Dependency
|
126
182
|
name: bootsnap
|
127
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -268,14 +324,14 @@ dependencies:
|
|
268
324
|
requirements:
|
269
325
|
- - "~>"
|
270
326
|
- !ruby/object:Gem::Version
|
271
|
-
version:
|
327
|
+
version: 4.0.0.rc1
|
272
328
|
type: :development
|
273
329
|
prerelease: false
|
274
330
|
version_requirements: !ruby/object:Gem::Requirement
|
275
331
|
requirements:
|
276
332
|
- - "~>"
|
277
333
|
- !ruby/object:Gem::Version
|
278
|
-
version:
|
334
|
+
version: 4.0.0.rc1
|
279
335
|
- !ruby/object:Gem::Dependency
|
280
336
|
name: terminal-table
|
281
337
|
requirement: !ruby/object:Gem::Requirement
|
@@ -304,7 +360,7 @@ dependencies:
|
|
304
360
|
- - "~>"
|
305
361
|
- !ruby/object:Gem::Version
|
306
362
|
version: '0.8'
|
307
|
-
description:
|
363
|
+
description: An open source Manufacturing Execution System
|
308
364
|
email:
|
309
365
|
- frankjmattia@gmail.com
|
310
366
|
executables:
|
@@ -327,12 +383,15 @@ files:
|
|
327
383
|
- app/controllers/jobshop/session_activations_controller.rb
|
328
384
|
- app/controllers/jobshop/sessions_controller.rb
|
329
385
|
- app/controllers/jobshop/users_controller.rb
|
386
|
+
- app/email_handlers/jobshop/rfq_handler.rb
|
330
387
|
- app/jobs/jobshop/application_job.rb
|
331
388
|
- app/mailers/jobshop/application_mailer.rb
|
332
389
|
- app/models/jobshop/ability.rb
|
333
390
|
- app/models/jobshop/application_record.rb
|
334
391
|
- app/models/jobshop/collection.rb
|
335
392
|
- app/models/jobshop/company.rb
|
393
|
+
- app/models/jobshop/company/type.rb
|
394
|
+
- app/models/jobshop/company_person.rb
|
336
395
|
- app/models/jobshop/dashboard.rb
|
337
396
|
- app/models/jobshop/inspection.rb
|
338
397
|
- app/models/jobshop/inspection/boolean_criterion.rb
|
@@ -342,12 +401,16 @@ files:
|
|
342
401
|
- app/models/jobshop/inspection/report.rb
|
343
402
|
- app/models/jobshop/inspection/result.rb
|
344
403
|
- app/models/jobshop/inspection/tuple.rb
|
404
|
+
- app/models/jobshop/mailman.rb
|
345
405
|
- app/models/jobshop/order.rb
|
346
406
|
- app/models/jobshop/order_line.rb
|
347
407
|
- app/models/jobshop/organization.rb
|
408
|
+
- app/models/jobshop/person.rb
|
348
409
|
- app/models/jobshop/place.rb
|
349
410
|
- app/models/jobshop/product.rb
|
350
411
|
- app/models/jobshop/registration.rb
|
412
|
+
- app/models/jobshop/rfq.rb
|
413
|
+
- app/models/jobshop/rfq_line.rb
|
351
414
|
- app/models/jobshop/role.rb
|
352
415
|
- app/models/jobshop/role_ability.rb
|
353
416
|
- app/models/jobshop/role_assignment.rb
|
@@ -365,7 +428,7 @@ files:
|
|
365
428
|
- config/routes.rb
|
366
429
|
- db/migrate/20170311194758_initialize_jobshop.rb
|
367
430
|
- db/migrate/20171216021339_create_organizations.rb
|
368
|
-
- db/migrate/
|
431
|
+
- db/migrate/20171216021554_create_people.rb
|
369
432
|
- db/migrate/20171216021853_create_companies.rb
|
370
433
|
- db/migrate/20171216022020_create_places.rb
|
371
434
|
- db/migrate/20171216022135_create_products.rb
|
@@ -374,11 +437,14 @@ files:
|
|
374
437
|
- db/migrate/20171216023022_create_sessions.rb
|
375
438
|
- db/migrate/20171216035357_create_things.rb
|
376
439
|
- db/migrate/20171219022118_create_routing_processes.rb
|
377
|
-
- db/migrate/
|
440
|
+
- db/migrate/20180107203241_create_inspections.rb
|
441
|
+
- db/migrate/20181117023949_create_rfqs.rb
|
442
|
+
- db/migrate/20181118014603_create_mailmen.rb
|
378
443
|
- db/seeds.rb
|
379
444
|
- exe/jobshop
|
380
445
|
- lib/generators/jobshop/app/USAGE
|
381
446
|
- lib/generators/jobshop/app/app_generator.rb
|
447
|
+
- lib/generators/jobshop/app/templates/Procfile.tt
|
382
448
|
- lib/generators/jobshop/app/templates/README.md.tt
|
383
449
|
- lib/generators/jobshop/app/templates/config/database.yml.tt
|
384
450
|
- lib/generators/jobshop/config/config_generator.rb
|
@@ -393,6 +459,7 @@ files:
|
|
393
459
|
- lib/jobshop/dummy_app.rb
|
394
460
|
- lib/jobshop/engine.rb
|
395
461
|
- lib/jobshop/helpers/migration.rb
|
462
|
+
- lib/jobshop/postmaster.rb
|
396
463
|
- lib/jobshop/support/memo_attr.rb
|
397
464
|
- lib/jobshop/version.rb
|
398
465
|
- lib/tasks/jobshop_tasks.rake
|
@@ -419,5 +486,5 @@ rubyforge_project:
|
|
419
486
|
rubygems_version: 2.6.14
|
420
487
|
signing_key:
|
421
488
|
specification_version: 4
|
422
|
-
summary: An open source Manufacturing Execution System
|
489
|
+
summary: An open source Manufacturing Execution System
|
423
490
|
test_files: []
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require "jobshop/helpers/migration.rb"
|
2
|
-
|
3
|
-
class CreateUsers < ActiveRecord::Migration[5.1]
|
4
|
-
include Jobshop::Helpers::Migration
|
5
|
-
|
6
|
-
def change
|
7
|
-
create_table :jobshop_users, id: false do |t|
|
8
|
-
t.uuid :organization_id, null: false
|
9
|
-
t.uuid :user_id, null: false, default: "gen_random_uuid()"
|
10
|
-
t.index [ :organization_id, :user_id ], unique: true,
|
11
|
-
name: :idx_jobshop_users_pkey
|
12
|
-
|
13
|
-
t.citext :email, null: false
|
14
|
-
t.index [ :organization_id, :email ], unique: true
|
15
|
-
|
16
|
-
t.string :forename
|
17
|
-
t.string :surname
|
18
|
-
t.string :job_title
|
19
|
-
t.string :email_authentication_token, index: { unique: true }
|
20
|
-
t.datetime :email_authentication_token_sent_at, :datetime
|
21
|
-
|
22
|
-
t.string :password_digest, null: false, default: ""
|
23
|
-
|
24
|
-
t.timestamps
|
25
|
-
end
|
26
|
-
|
27
|
-
idx_table_name_pkey "jobshop_users"
|
28
|
-
fk_organization_id "jobshop_users"
|
29
|
-
end
|
30
|
-
end
|