jobshop 0.0.163 → 0.0.167

Sign up to get free protection for your applications and to get access to all the features.
Files changed (90) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +3 -3
  3. data/Rakefile +8 -17
  4. data/app/controllers/jobshop/application_controller.rb +5 -4
  5. data/app/controllers/jobshop/places_controller.rb +0 -4
  6. data/app/controllers/jobshop/users_controller.rb +0 -3
  7. data/app/mailers/jobshop/application_mailer.rb +0 -2
  8. data/app/mailers/jobshop/rfq_responder_mailer.rb +18 -0
  9. data/app/models/jobshop/ability.rb +1 -1
  10. data/app/models/jobshop/customer.rb +30 -0
  11. data/app/models/jobshop/customer/category.rb +19 -0
  12. data/app/models/jobshop/customer/contact.rb +28 -0
  13. data/app/models/jobshop/employee.rb +46 -0
  14. data/app/models/jobshop/employment.rb +25 -0
  15. data/app/models/jobshop/employment_version.rb +10 -0
  16. data/app/models/jobshop/inspection/boolean_criterion.rb +2 -2
  17. data/app/models/jobshop/inspection/deviation_criterion.rb +4 -4
  18. data/app/models/jobshop/inspection/limit_criterion.rb +6 -4
  19. data/app/models/jobshop/inspection/report.rb +2 -0
  20. data/app/models/jobshop/inspection/result.rb +2 -2
  21. data/app/models/jobshop/mailman.rb +22 -0
  22. data/app/models/jobshop/order.rb +2 -6
  23. data/app/models/jobshop/order_line.rb +2 -3
  24. data/app/models/jobshop/organization.rb +15 -6
  25. data/app/models/jobshop/place.rb +2 -0
  26. data/app/models/jobshop/product.rb +0 -3
  27. data/app/models/jobshop/rfq.rb +12 -6
  28. data/app/models/jobshop/user.rb +2 -17
  29. data/app/views/jobshop/rfq_responder_mailer/verified_contact.html.erb +5 -0
  30. data/app/views/jobshop/rfq_responder_mailer/verified_contact.text.erb +3 -0
  31. data/app/views/layouts/jobshop/application.html.haml +15 -0
  32. data/app/views/layouts/jobshop/mailer.html.erb +13 -0
  33. data/config/initializers/devise.rb +290 -0
  34. data/config/locales/devise.en.yml +64 -0
  35. data/config/routes.rb +1 -2
  36. data/db/migrate/20170311194758_initialize_jobshop.rb +42 -2
  37. data/db/migrate/20171216021339_create_organizations.rb +1 -4
  38. data/db/migrate/20171216021400_create_employees.rb +47 -0
  39. data/db/migrate/20171216021554_create_people.rb +13 -18
  40. data/db/migrate/20171216021853_create_customers.rb +57 -0
  41. data/db/migrate/20171216022020_create_places.rb +8 -9
  42. data/db/migrate/20171216022135_create_products.rb +6 -13
  43. data/db/migrate/20171216022605_create_orders.rb +19 -36
  44. data/db/migrate/20171216023018_create_roles.rb +5 -3
  45. data/db/migrate/20171216035357_create_things.rb +4 -4
  46. data/db/migrate/20171219022118_create_routing_processes.rb +15 -15
  47. data/db/migrate/20180107203241_create_inspections.rb +15 -14
  48. data/db/migrate/20181117023949_create_rfqs.rb +27 -19
  49. data/db/migrate/20181118014603_create_mailmen.rb +6 -4
  50. data/db/seeds.rb +126 -0
  51. data/lib/generators/jobshop/app/app_generator.rb +1 -1
  52. data/lib/generators/jobshop/app/templates/Procfile.tt +1 -0
  53. data/lib/generators/jobshop/app/templates/config/database.yml.tt +5 -5
  54. data/lib/generators/jobshop/{dummy/dummy_generator.rb → canary/canary_generator.rb} +13 -14
  55. data/lib/generators/jobshop/{dummy → canary}/templates/config/boot.rb.tt +0 -0
  56. data/lib/jobshop.rb +41 -12
  57. data/lib/jobshop/cli.rb +16 -82
  58. data/lib/jobshop/cli/app_generator.rb +38 -0
  59. data/lib/jobshop/cli/application.rb +14 -0
  60. data/lib/jobshop/cli/canary.rb +52 -0
  61. data/lib/jobshop/configuration.rb +16 -11
  62. data/lib/jobshop/engine.rb +39 -28
  63. data/lib/jobshop/helpers/migration.rb +78 -2
  64. data/lib/jobshop/mailroom/base_handler.rb +33 -0
  65. data/lib/jobshop/mailroom/null_handler.rb +10 -0
  66. data/lib/jobshop/mailroom/postmaster.rb +77 -0
  67. data/lib/jobshop/mailroom/rfq_handler.rb +39 -0
  68. data/lib/jobshop/version.rb +3 -1
  69. data/lib/tasks/jobshop_tasks.rake +7 -6
  70. metadata +98 -69
  71. data/app/controllers/concerns/email_token_validation.rb +0 -59
  72. data/app/controllers/concerns/jobshop/authentication_handler.rb +0 -15
  73. data/app/controllers/concerns/jobshop/authorization_handler.rb +0 -29
  74. data/app/controllers/jobshop/session_activations_controller.rb +0 -13
  75. data/app/controllers/jobshop/sessions_controller.rb +0 -20
  76. data/app/email_handlers/jobshop/rfq_handler.rb +0 -43
  77. data/app/models/jobshop/company.rb +0 -35
  78. data/app/models/jobshop/company/type.rb +0 -17
  79. data/app/models/jobshop/company_person.rb +0 -15
  80. data/app/models/jobshop/person.rb +0 -30
  81. data/app/models/jobshop/session_activation.rb +0 -30
  82. data/app/serializers/jobshop/test_user_serializer.rb +0 -10
  83. data/app/services/jobshop/authentication_service.rb +0 -20
  84. data/app/services/jobshop/authorization_service.rb +0 -30
  85. data/app/services/jobshop/jwt_service.rb +0 -17
  86. data/db/migrate/20171216021853_create_companies.rb +0 -64
  87. data/db/migrate/20171216023022_create_sessions.rb +0 -23
  88. data/lib/jobshop/cli/spinner.rb +0 -21
  89. data/lib/jobshop/dummy_app.rb +0 -190
  90. data/lib/jobshop/postmaster.rb +0 -89
@@ -1,8 +1,7 @@
1
- require "jobshop/dummy_app"
2
1
  require "generators/jobshop/app/app_generator"
3
2
 
4
3
  module Jobshop
5
- class DummyBuilder < Jobshop::AppBuilder
4
+ class CanaryBuilder < Jobshop::AppBuilder
6
5
  def readme
7
6
  # Do not generate README.md
8
7
  end
@@ -22,11 +21,16 @@ module Jobshop
22
21
  end
23
22
  end
24
23
 
24
+ # Make a phony `bin/jobshop` file
25
+ def bin_jobshop
26
+ FileUtils.touch("bin/jobshop")
27
+ end
28
+
25
29
  def expose_mailer_previews
26
- # Mailer previews don't really play nice with Engines so in the dummy app we
27
- # create an initializer to expose them properly.
30
+ # Mailer previews don't really play nice with Engines so in the canary app
31
+ # we create an initializer to expose them properly.
28
32
  initializer "jobshop_expose_mailer_previews.rb", <<~INITIALIZER
29
- if Rails.env.development? || Rails.env.test?
33
+ if Rails.env.development?
30
34
  Rails.application.configure do
31
35
  config.action_mailer.preview_path = "\#{Jobshop::Engine.root}/spec/mailers"
32
36
  end
@@ -47,25 +51,20 @@ module Jobshop
47
51
  end
48
52
 
49
53
  module Generators
50
- class DummyGenerator < Jobshop::Generators::AppGenerator
54
+ class CanaryGenerator < Jobshop::Generators::AppGenerator
51
55
  def self.source_paths
52
56
  [ Rails::Generators::AppGenerator.source_root,
53
- Jobshop::Generators::DummyGenerator.source_root ]
57
+ Jobshop::Generators::CanaryGenerator.source_root ]
54
58
  end
55
59
 
56
60
  hide!
57
61
 
58
- def initialize(*args)
59
- super
60
- return if options[:pretend]
61
- DummyApp.destroy! if Jobshop::DummyApp.exist?
62
- end
63
-
64
62
  def create_boot_file
65
63
  template "config/boot.rb.tt"
66
64
  end
67
65
 
68
66
  def finish_template
67
+ build :bin_jobshop
69
68
  build :config_database_yml
70
69
  build :db_migrate
71
70
  build :expose_mailer_previews
@@ -83,7 +82,7 @@ module Jobshop
83
82
 
84
83
  protected
85
84
  def get_builder_class
86
- Jobshop::DummyBuilder
85
+ Jobshop::CanaryBuilder
87
86
  end
88
87
  end
89
88
  end
data/lib/jobshop.rb CHANGED
@@ -1,15 +1,44 @@
1
- # Dependencies
2
- require "fast_jsonapi"
3
- require "jwt"
4
- require "rack/cors"
5
- require "redis-rails"
6
- require "unitwise"
7
-
8
- # Jobshop Version
9
- require "jobshop/version"
1
+ # frozen_string_literals: true
10
2
 
11
- # Jobshop Configuration
12
- require "jobshop/configuration"
3
+ #
4
+ # Jobshop - An Open Source Manufacturing Execution System
5
+ # Copyright (C) 2019 Frank J. Mattia
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU Affero General Public License as
9
+ # published by the Free Software Foundation, either version 3 of the
10
+ # License, or (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU Affero General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU Affero General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ #
13
20
 
14
- # Jobshop Engine
21
+ require "active_support"
22
+ require "jobshop/version"
23
+ require "jobshop/configuration"
15
24
  require "jobshop/engine"
25
+
26
+ module Jobshop
27
+ extend ActiveSupport::Autoload
28
+
29
+ module Mailroom
30
+ extend ActiveSupport::Autoload
31
+
32
+ autoload :BaseHandler
33
+
34
+ eager_autoload do
35
+ autoload :RFQHandler
36
+ autoload :NullHandler
37
+ end
38
+ end
39
+
40
+ def self.eager_load!
41
+ super
42
+ Jobshop::Mailroom.eager_load!
43
+ end
44
+ end
data/lib/jobshop/cli.rb CHANGED
@@ -1,24 +1,27 @@
1
- require "thor"
2
- require "active_support/inflector"
1
+ # frozen_string_literals: true
3
2
 
4
- require "jobshop/dummy_app"
5
- require "generators/jobshop/app/app_generator"
6
- require "generators/jobshop/dummy/dummy_generator"
3
+ require "thor"
4
+ require "jobshop/cli/application"
5
+ require "jobshop/cli/canary"
6
+ require "jobshop/cli/app_generator"
7
7
 
8
8
  module Jobshop
9
9
  module CLI
10
10
  class << self
11
- def start(*args)
12
- if [ "-v", "--version" ].include?(args[0])
11
+ def start(argv = ARGV)
12
+ if [ "-v", "--version" ].include?(argv[0])
13
13
  require "jobshop/version"
14
+
14
15
  puts "Jobshop #{Jobshop.gem_version}"
15
16
  exit 0
16
- elsif application?
17
- puts "No tasks available for the application environment yet"
18
- elsif development?
19
- Jobshop::CLI::Development.start
17
+ end
18
+
19
+ if application?
20
+ Jobshop::CLI::Application.start(argv)
21
+ elsif canary?
22
+ Jobshop::CLI::Canary.start(argv)
20
23
  else
21
- Jobshop::CLI::Apps.start
24
+ Jobshop::CLI::AppGenerator.start(argv)
22
25
  end
23
26
  end
24
27
 
@@ -26,7 +29,7 @@ module Jobshop
26
29
  has_executable? && !has_gemspec?
27
30
  end
28
31
 
29
- def development?
32
+ def canary?
30
33
  has_executable? && has_gemspec?
31
34
  end
32
35
 
@@ -38,74 +41,5 @@ module Jobshop
38
41
  @jobshop_development ||= File.file?("jobshop.gemspec")
39
42
  end
40
43
  end
41
-
42
- class Apps < Thor
43
- desc "list", "List known Jobshop applications"
44
- long_desc <<~DESC
45
- TODO: List all known Jobshop instances.
46
- DESC
47
- default_command def list
48
- abort "No apps found"
49
- end
50
-
51
- desc "new [options]", "Create a new Jobshop application"
52
- long_desc <<~DESC
53
- All the the normal options to `rails new` are applicable but the
54
- following will be set regardless of input:
55
-
56
- --database=postgresql
57
- DESC
58
- def new(*args)
59
- Jobshop::Generators::AppGenerator.start(args, jobshop_options: {
60
- database: "postgresql"
61
- })
62
- end
63
- end
64
-
65
- class Dev < Thor
66
- desc "reset [options]", "Create the app used for running tests"
67
- long_desc <<~DESC
68
- All the the normal options to `rails new` are applicable but the
69
- following options may not be changed:
70
-
71
- --database=postgresql
72
- --skip-bundle
73
- --skip-gemfile
74
- --skip-git
75
- --skip-listen
76
- --skip-test
77
- DESC
78
- def reset(*args)
79
- Jobshop::Generators::DummyGenerator.start(
80
- args.unshift(Jobshop::DummyApp.path),
81
- jobshop_options: {
82
- database: "postgresql",
83
- skip_bundle: true,
84
- skip_gemfile: true,
85
- skip_git: true,
86
- skip_listen: true,
87
- skip_test: true
88
- }
89
- )
90
- end
91
-
92
- desc "seed", "Seed the test app"
93
- def seed
94
- Jobshop::DummyApp.seed
95
- end
96
-
97
- desc "routes", "Test app routes"
98
- def routes
99
- Dir.chdir(Jobshop::DummyApp.path)
100
- exec %Q(rails routes)
101
- end
102
- end
103
-
104
- class Development < Thor
105
- register Jobshop::CLI::Apps, "apps", "apps COMMAND [options]", "Manage jobshop applications"
106
- if Jobshop::CLI.development?
107
- register Jobshop::CLI::Dev, "dev", "dev COMMAND [options]", "Manage test app used for tests"
108
- end
109
- end
110
44
  end
111
45
  end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literals: true
2
+
3
+ require "generators/jobshop/app/app_generator"
4
+
5
+ module Jobshop
6
+ module CLI
7
+ class AppGenerator < Thor
8
+ default_task :help
9
+
10
+ desc "help", "Display long help"
11
+ def help
12
+ self.class.command_help(Thor::Base.shell.new, "new")
13
+ end
14
+
15
+ desc "new APP_PATH [options]", "Create Jobshop Application Host"
16
+ long_desc <<~DESC
17
+ Options:
18
+
19
+ All the the normal options to `rails new` are applicable but the
20
+ following options may not be changed:
21
+
22
+ --database=postgresql
23
+ DESC
24
+ def new(*args)
25
+ Jobshop::Generators::AppGenerator.start(
26
+ args, jobshop_options: { database: "postgresql" }
27
+ )
28
+ end
29
+
30
+
31
+ no_commands do
32
+ def require_environment!
33
+ require File.expand_path("spec/canary/config/environment")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literals: true
2
+
3
+ module Jobshop
4
+ module CLI
5
+ class Application < Thor
6
+
7
+ no_commands do
8
+ def require_environment!
9
+ require File.expand_path("config/environment")
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literals: true
2
+
3
+ require "generators/jobshop/canary/canary_generator"
4
+
5
+ module Jobshop
6
+ module CLI
7
+ class Canary < Thor
8
+ desc "reset [options]", "Recreate the app used for running tests"
9
+ long_desc <<~DESC
10
+ All the the normal options to `rails new` are applicable but the
11
+ following options may not be changed:
12
+
13
+ --database=postgresql
14
+ --skip-bundle
15
+ --skip-gemfile
16
+ --skip-git
17
+ --skip-listen
18
+ --skip-test
19
+ DESC
20
+ def reset(*args)
21
+ FileUtils.rmtree(File.expand_path("spec/canary"))
22
+ Jobshop::Generators::CanaryGenerator.start(
23
+ args.unshift(File.expand_path("spec/canary")),
24
+ jobshop_options: {
25
+ database: "postgresql",
26
+ skip_bundle: true,
27
+ skip_gemfile: true,
28
+ skip_git: true,
29
+ skip_listen: true,
30
+ skip_test: true
31
+ }
32
+ )
33
+ end
34
+
35
+ desc "seed", "Seed the test app"
36
+ def seed
37
+ require_environment!
38
+ Jobshop::Engine.load_seed
39
+ end
40
+
41
+ no_commands do
42
+ def require_environment!
43
+ begin
44
+ require File.expand_path("spec/canary/config/environment")
45
+ rescue LoadError
46
+ abort "Canary app does not exist. Run `jobshop reset` to create it."
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -2,23 +2,28 @@ module Jobshop
2
2
  class Configuration
3
3
  extend Forwardable
4
4
 
5
- attr_accessor :mailer_host, :session_store_url
6
- def_delegators :aws, :access_key_id, :secret_access_key, :region,
7
- :s3_bucket, :incoming_email_queue
5
+ attr_accessor :aws, :smtp, :mailer_host, :session_store_url
8
6
 
9
7
  def initialize
10
8
  self.mailer_host = ENV.fetch("JOBSHOP_MAILER_HOST", "localhost:3000")
11
9
  self.session_store_url = ENV.fetch("JOBSHOP_SESSION_STORE_URL", "")
12
10
 
13
- aws.access_key_id = ENV.fetch("JOBSHOP_AWS_ACCESS_KEY_ID", "")
14
- aws.secret_access_key = ENV.fetch("JOBSHOP_AWS_SECRET_ACCESS_KEY", "")
15
- aws.region = ENV.fetch("JOBSHOP_AWS_REGION", "")
16
- aws.s3_bucket = ENV.fetch("JOBSHOP_S3_BUCKET", "")
17
- aws.incoming_email_queue = ENV.fetch("JOBSHOP_INCOMING_EMAIL_QUEUE", "")
18
- end
11
+ self.aws = ActiveSupport::OrderedOptions.new
12
+ self.aws.access_key_id = ENV.fetch("JOBSHOP_AWS_ACCESS_KEY_ID", "")
13
+ self.aws.secret_access_key =
14
+ ENV.fetch("JOBSHOP_AWS_SECRET_ACCESS_KEY", "")
15
+ self.aws.region = ENV.fetch("JOBSHOP_AWS_REGION", "")
16
+ self.aws.s3_bucket = ENV.fetch("JOBSHOP_S3_BUCKET", "")
17
+ self.aws.incoming_email_queue =
18
+ ENV.fetch("JOBSHOP_INCOMING_EMAIL_QUEUE", "")
19
19
 
20
- def aws
21
- @aws ||= ActiveSupport::OrderedOptions.new
20
+ self.smtp = ActiveSupport::OrderedOptions.new
21
+ self.smtp.address = ENV.fetch("JOBSHOP_SES_SMTP_ADDRESS", "")
22
+ self.smtp.port = ENV.fetch("JOBSHOP_SES_SMTP_PORT", 587)
23
+ self.smtp.user_name = ENV.fetch("JOBSHOP_SES_SMTP_USERNAME", "")
24
+ self.smtp.password = ENV.fetch("JOBSHOP_SES_SMTP_PASSWORD", "")
25
+ self.smtp.default_from =
26
+ ENV.fetch("JOBSHOP_SES_SMTP_DEFAULT_FROM", "noreply@jobshop.test")
22
27
  end
23
28
  end
24
29
 
@@ -1,11 +1,15 @@
1
+ # frozen_string_literals: true
2
+
3
+ require "devise"
4
+ require "haml-rails"
5
+ require "unitwise"
6
+
1
7
  module Jobshop
2
8
  class Engine < ::Rails::Engine
3
9
  isolate_namespace Jobshop
4
10
 
5
11
  config.eager_load_namespaces << Jobshop
6
12
 
7
- config.generators.api_only = true
8
-
9
13
  config.generators do |g|
10
14
  g.orm :active_record, primary_key_type: :uuid
11
15
  g.test_framework :rspec, view_specs: false
@@ -15,48 +19,55 @@ module Jobshop
15
19
 
16
20
  ActiveSupport::Inflector.inflections do |inflect|
17
21
  inflect.irregular "criterion", "criteria"
18
- inflect.acronym "JWT"
19
- inflect.acronym "RFQ"
20
22
  inflect.acronym "RFQs"
23
+ inflect.acronym "RFQ"
24
+ end
25
+
26
+ initializer "jobshop.append_paths", before: :load_config_initializers do
27
+ config.paths["db/migrate"].expanded.each do |expanded_path|
28
+ Rails.application.config.paths["db/migrate"] << expanded_path
29
+ end
21
30
  end
22
31
 
23
- initializer "jobshop.active_record_enhancements" do
32
+ initializer "jobshop.active_record_on_load" do
24
33
  ActiveSupport.on_load(:active_record) do
25
34
  require "activerecord_json_validator"
26
35
  require "composite_primary_keys"
36
+ require "fast_jsonapi"
27
37
  end
28
38
  end
29
39
 
30
- initializer "jobshop.middleware" do
31
- config.middleware.use Rack::Cors do
32
- allow do
33
- origins "localhost:4200"
34
- resource "*",
35
- headers: :any,
36
- expose: %w(access-token expiry token-type uid client),
37
- methods: %i(get post options delete put)
38
- end
39
- end
40
- end
40
+ initializer "jobshop.action_mailer_on_load" do
41
+ ActiveSupport.on_load(:action_mailer) do
42
+ ActionMailer::Base.smtp_settings = {
43
+ address: Jobshop.configuration.smtp.address,
44
+ port: Jobshop.configuration.smtp.port,
45
+ user_name: Jobshop.configuration.smtp.user_name,
46
+ password: Jobshop.configuration.smtp.password,
47
+ authentication: :login,
48
+ enable_starttls_auto: true
49
+ }
41
50
 
42
- initializer "jobshop.append_paths", before: :load_config_initializers do |app|
43
- config.paths["db/migrate"].expanded.each do |expanded_path|
44
- app.config.paths["db/migrate"] << expanded_path
51
+ ActionMailer::Base.default_options = {
52
+ from: Jobshop.configuration.smtp.default_from
53
+ }
54
+
55
+ ActionMailer::Base.default_url_options = {
56
+ host: Jobshop.configuration.mailer_host
57
+ }
45
58
  end
46
59
  end
47
60
 
48
- initializer "jobshop.redis_session_store" do
49
- Rails.application.config.session_store(:redis_store, {
50
- servers: Jobshop.configuration.session_store_url
51
- })
52
- end
61
+ initializer "jobshop.redis" do
62
+ #require "redis-rails"
53
63
 
54
- initializer "jobshop.action_mailer.default_url_options" do
55
- config.action_mailer.default_url_options = {
56
- host: Jobshop.configuration.mailer_host
57
- }
64
+ Rails.application.config.session_store :cookie_store, key: '_your_app_session'
65
+ #(:redis_store, {
66
+ # servers: Jobshop.configuration.session_store_url
67
+ #})
58
68
  end
59
69
 
70
+
60
71
  initializer "jobshop.aws.config" do
61
72
  require "aws-sdk-core"
62
73