jobshop 0.0.131 → 0.0.157

Sign up to get free protection for your applications and to get access to all the features.
Files changed (122) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +16 -9
  4. data/app/controllers/concerns/jobshop/authentication_handler.rb +15 -0
  5. data/app/controllers/concerns/jobshop/authorization_handler.rb +29 -0
  6. data/app/controllers/jobshop/application_controller.rb +5 -32
  7. data/app/controllers/jobshop/organizations/lookups_controller.rb +18 -0
  8. data/app/controllers/jobshop/places_controller.rb +1 -1
  9. data/app/controllers/jobshop/{welcome/registrations_controller.rb → registrations_controller.rb} +2 -7
  10. data/app/controllers/jobshop/session_activations_controller.rb +1 -1
  11. data/app/controllers/jobshop/sessions_controller.rb +15 -1
  12. data/app/controllers/jobshop/users_controller.rb +9 -0
  13. data/app/mailers/jobshop/application_mailer.rb +2 -2
  14. data/app/models/jobshop/ability.rb +7 -0
  15. data/app/models/jobshop/collection.rb +22 -0
  16. data/app/models/jobshop/company.rb +22 -0
  17. data/app/models/jobshop/dashboard.rb +1 -1
  18. data/app/models/jobshop/inspection/boolean_criterion.rb +44 -0
  19. data/app/models/jobshop/inspection/criterion.rb +22 -0
  20. data/app/models/jobshop/inspection/deviation_criterion.rb +112 -0
  21. data/app/models/jobshop/inspection/limit_criterion.rb +114 -0
  22. data/app/models/jobshop/inspection/report.rb +41 -0
  23. data/app/models/jobshop/inspection/result.rb +42 -0
  24. data/app/models/jobshop/inspection/tuple.rb +13 -0
  25. data/app/models/jobshop/inspection.rb +13 -0
  26. data/app/models/jobshop/order.rb +41 -0
  27. data/app/models/jobshop/order_line.rb +13 -0
  28. data/app/models/jobshop/organization.rb +34 -0
  29. data/app/models/jobshop/place.rb +6 -4
  30. data/app/models/jobshop/product.rb +23 -0
  31. data/app/models/jobshop/registration.rb +14 -10
  32. data/app/models/jobshop/role.rb +24 -0
  33. data/app/models/jobshop/role_ability.rb +7 -0
  34. data/app/models/jobshop/role_assignment.rb +7 -0
  35. data/app/models/jobshop/routing_process.rb +20 -0
  36. data/app/models/jobshop/routing_step.rb +11 -0
  37. data/app/models/jobshop/thing.rb +30 -4
  38. data/app/models/jobshop/user.rb +23 -25
  39. data/app/serializers/jobshop/test_user_serializer.rb +10 -0
  40. data/app/services/jobshop/authentication_service.rb +20 -0
  41. data/app/services/jobshop/authorization_service.rb +30 -0
  42. data/app/services/jobshop/jwt_service.rb +17 -0
  43. data/config/routes.rb +2 -43
  44. data/db/migrate/20170311194758_initialize_jobshop.rb +1 -106
  45. data/db/migrate/20171216021339_create_organizations.rb +20 -0
  46. data/db/migrate/20171216021717_create_users.rb +30 -0
  47. data/db/migrate/20171216021853_create_companies.rb +25 -0
  48. data/db/migrate/20171216022020_create_places.rb +22 -0
  49. data/db/migrate/20171216022135_create_products.rb +27 -0
  50. data/db/migrate/20171216022605_create_orders.rb +53 -0
  51. data/db/migrate/20171216023018_create_roles.rb +52 -0
  52. data/db/migrate/20171216023022_create_sessions.rb +21 -0
  53. data/db/migrate/20171216035357_create_things.rb +44 -0
  54. data/db/migrate/20171219022118_create_routing_processes.rb +57 -0
  55. data/db/migrate/20180107203241_create_inspection.rb +159 -0
  56. data/{app/assets/stylesheets/jobshop/welcome.scss → db/seeds.rb} +0 -0
  57. data/lib/generators/jobshop/app/app_generator.rb +36 -3
  58. data/lib/generators/jobshop/app/templates/config/database.yml.tt +19 -0
  59. data/lib/generators/jobshop/config/templates/config/initializers/jobshop.rb.tt +0 -2
  60. data/lib/generators/jobshop/dummy/dummy_generator.rb +3 -14
  61. data/lib/jobshop/cli/spinner.rb +21 -0
  62. data/lib/jobshop/cli.rb +44 -24
  63. data/lib/jobshop/configuration.rb +24 -0
  64. data/lib/jobshop/dummy_app.rb +155 -0
  65. data/lib/jobshop/engine.rb +30 -31
  66. data/lib/jobshop/helpers/migration.rb +55 -0
  67. data/lib/jobshop/version.rb +2 -2
  68. data/lib/jobshop.rb +7 -21
  69. data/lib/tasks/jobshop_tasks.rake +7 -24
  70. metadata +113 -150
  71. data/app/assets/config/jobshop_manifest.js +0 -2
  72. data/app/assets/images/jobshop/logo.svg +0 -50
  73. data/app/assets/javascripts/jobshop/application.js +0 -34
  74. data/app/assets/stylesheets/jobshop/application.scss +0 -57
  75. data/app/assets/stylesheets/jobshop/breakpoints.scss +0 -47
  76. data/app/assets/stylesheets/jobshop/dialog.scss +0 -43
  77. data/app/controllers/concerns/registration_token_validation.rb +0 -41
  78. data/app/controllers/jobshop/teams/lookups_controller.rb +0 -20
  79. data/app/controllers/jobshop/teams_controller.rb +0 -6
  80. data/app/controllers/jobshop/welcome/places_controller.rb +0 -42
  81. data/app/controllers/jobshop/welcome/things_controller.rb +0 -42
  82. data/app/controllers/jobshop/welcome_controller.rb +0 -11
  83. data/app/helpers/jobshop/application_helper.rb +0 -14
  84. data/app/mailers/jobshop/teams_mailer.rb +0 -10
  85. data/app/models/jobshop/team.rb +0 -36
  86. data/app/policies/jobshop/application_policy.rb +0 -55
  87. data/app/views/devise/confirmations/new.html.haml +0 -10
  88. data/app/views/devise/mailer/confirmation_instructions.html.haml +0 -4
  89. data/app/views/devise/mailer/password_change.html.haml +0 -3
  90. data/app/views/devise/mailer/reset_password_instructions.html.haml +0 -6
  91. data/app/views/devise/mailer/unlock_instructions.html.haml +0 -5
  92. data/app/views/devise/passwords/edit.html.haml +0 -19
  93. data/app/views/devise/passwords/new.html.haml +0 -10
  94. data/app/views/devise/registrations/edit.html.haml +0 -31
  95. data/app/views/devise/registrations/new.html.haml +0 -21
  96. data/app/views/devise/sessions/new.html.haml +0 -15
  97. data/app/views/devise/shared/_links.html.haml +0 -19
  98. data/app/views/devise/unlocks/new.html.haml +0 -10
  99. data/app/views/jobshop/dashboards/show.html.haml +0 -140
  100. data/app/views/jobshop/places/show.html.haml +0 -12
  101. data/app/views/jobshop/session_activations/destroy.js.erb +0 -1
  102. data/app/views/jobshop/shared/_authenticated_header.html.haml +0 -8
  103. data/app/views/jobshop/shared/_unauthenticated_header.html.haml +0 -10
  104. data/app/views/jobshop/teams/lookups/show.html.haml +0 -14
  105. data/app/views/jobshop/teams_mailer/found_teams.html.haml +0 -11
  106. data/app/views/jobshop/teams_mailer/found_teams.text.erb +0 -8
  107. data/app/views/jobshop/welcome/index.html.haml +0 -21
  108. data/app/views/jobshop/welcome/places/new.html.haml +0 -22
  109. data/app/views/jobshop/welcome/registrations/new.html.haml +0 -32
  110. data/app/views/jobshop/welcome/things/new.html.haml +0 -24
  111. data/app/views/layouts/jobshop/application.html.haml +0 -15
  112. data/app/views/layouts/jobshop/unauthenticated.html.haml +0 -6
  113. data/config/initializers/assets.rb +0 -11
  114. data/config/initializers/devise.rb +0 -282
  115. data/config/initializers/field_with_errors.rb +0 -3
  116. data/config/initializers/simple_form.rb +0 -157
  117. data/config/locales/devise.en.yml +0 -62
  118. data/config/locales/simple_form.en.yml +0 -31
  119. data/db/migrate/keep +0 -0
  120. data/lib/generators/jobshop/team/USAGE +0 -7
  121. data/lib/generators/jobshop/team/team_generator.rb +0 -60
  122. data/lib/jobshop/failure_app.rb +0 -11
data/lib/jobshop/cli.rb CHANGED
@@ -1,16 +1,24 @@
1
1
  require "thor"
2
+ require "active_support/inflector"
2
3
 
3
4
  require "jobshop/dummy_app"
4
5
  require "generators/jobshop/app/app_generator"
5
6
  require "generators/jobshop/dummy/dummy_generator"
6
7
 
7
8
  module Jobshop
8
- class CLI
9
- class Unbound < Thor
10
- desc "new", "Create a new Jobshop application"
9
+ module CLI
10
+ class App < Thor
11
+ desc "new [options]", "Create a new Jobshop application"
12
+ long_desc <<~DESC
13
+ All the the normal options to `rails new` are applicable but the
14
+ following will be set regardless of input:
15
+
16
+ --database=postgresql
17
+ DESC
11
18
  default_command def new(*)
12
- Jobshop::Generators::AppGenerator.start \
13
- Rails::Generators::ARGVScrubber.new(ARGV).prepare!
19
+ Jobshop::Generators::AppGenerator.start(args, jobshop_options: {
20
+ database: "postgresql"
21
+ })
14
22
  end
15
23
 
16
24
  def help
@@ -19,30 +27,42 @@ module Jobshop
19
27
  end
20
28
 
21
29
  class Dummy < Thor
22
- desc "server", "Start the dummy app"
23
- default_command def server(*args)
24
- if Jobshop::DummyApp.exist?
25
- Dir.chdir(Jobshop::DummyApp.path)
26
- exec %Q(rails s #{args.join(" ")})
27
- else
28
- abort <<~MESSAGE
29
- Dummy app does not exist at #{Jobshop::DummyApp.path}
30
- Please run `jobshop dummy create` first to initialize it.
31
- MESSAGE
32
- end
30
+ desc "create [options]", "Create the dummy app used for running tests"
31
+ long_desc <<~DESC
32
+ All the the normal options to `rails new` are applicable but the
33
+ following will be set regardless of input:
34
+
35
+ --database=postgresql
36
+ DESC
37
+ def create(*args)
38
+ Jobshop::Generators::DummyGenerator.start(
39
+ args.unshift(Jobshop::DummyApp.path),
40
+ jobshop_options: {
41
+ database: "postgresql",
42
+ skip_gemfile: true,
43
+ skip_bundle: true,
44
+ skip_git: true,
45
+ skip_listen: true,
46
+ skip_test: true
47
+ }
48
+ )
49
+ end
50
+
51
+ desc "seed", "Seed the dummy app"
52
+ def seed
53
+ Jobshop::DummyApp.seed
33
54
  end
34
55
 
35
- desc "create", "Create the dummy app"
36
- def create
37
- Jobshop::DummyApp.destroy! if Jobshop::DummyApp.exist?
38
- ARGV.shift; ARGV.unshift("new", Jobshop::DummyApp.path)
39
- Jobshop::Generators::DummyGenerator.start \
40
- Rails::Generators::ARGVScrubber.new(ARGV).prepare!
56
+ desc "routes", "Dummy app routes"
57
+ def routes
58
+ Dir.chdir(Jobshop::DummyApp.path)
59
+ exec %Q(rails routes)
41
60
  end
42
61
  end
43
62
 
44
63
  class Development < Thor
45
- register Jobshop::CLI::Dummy, "dummy", "dummy [options]", "Manage dummy app used for tests"
64
+ register Jobshop::CLI::App, "app", "app COMMAND [options]", "Create test apps in development"
65
+ register Jobshop::CLI::Dummy, "dummy", "dummy COMMAND [options]", "Manage dummy app used for tests"
46
66
  end
47
67
 
48
68
  class << self
@@ -56,7 +76,7 @@ module Jobshop
56
76
  elsif jobshop_development?
57
77
  Jobshop::CLI::Development.start
58
78
  else
59
- Jobshop::CLI::Unbound.start
79
+ Jobshop::CLI::App.start
60
80
  end
61
81
  end
62
82
 
@@ -0,0 +1,24 @@
1
+ module Jobshop
2
+ class Configuration
3
+ attr_accessor :mailer_host
4
+ attr_accessor :session_store_url
5
+
6
+ def initialize
7
+ @mailer_host = begin
8
+ ENV.fetch("JOBSHOP_MAILER_HOST", "localhost:3000")
9
+ end
10
+ end
11
+ end
12
+
13
+ class << self
14
+ attr_writer :configuration
15
+
16
+ def configuration
17
+ @configuration ||= Configuration.new
18
+ end
19
+
20
+ def configure
21
+ yield configuration
22
+ end
23
+ end
24
+ end
@@ -1,8 +1,49 @@
1
1
  require "rails/version"
2
2
 
3
+ require "jobshop/cli"
4
+ require "jobshop/cli/spinner"
5
+
3
6
  module Jobshop
4
7
  class DummyApp
8
+ WIDGET_TYPES = [ "A", "B", "C" ]
9
+ WIDGET_SHAPES = [ "triangle", "square", "pentagon", "hexagon", "heptagon" ]
10
+ WIDGET_COLLECTION_SCHEMA = {
11
+ "properties": {
12
+ "shape": {
13
+ "title": "Widget Shape",
14
+ "description": "The shape of the widget",
15
+ "enum": WIDGET_SHAPES
16
+ },
17
+ "size": {
18
+ "title": "Nominal Size",
19
+ "description": "Nominal size of new widget",
20
+ "type": "number"
21
+ }
22
+ },
23
+ "required": [ "shape", "size" ],
24
+ "additionalProperties": false
25
+ }
26
+
27
+ WIDGET_PACK_POSITIONS = [ "A", "B", "C", "D" ]
28
+ WIDGET_PACK_COLLECTION_SCHEMA = {
29
+ "properties": {
30
+ "widgets": {
31
+ "type": "object",
32
+ "patternProperties": {
33
+ "^[A-Z]$": {
34
+ "type": "string",
35
+ "format": "uri"
36
+ }
37
+ },
38
+ "additionalProperties": false
39
+ }
40
+ },
41
+ "additionalProperties": false
42
+ }
43
+
5
44
  class << self
45
+ include CLI::UI
46
+
6
47
  def destroy!
7
48
  FileUtils.rmtree(path)
8
49
  end
@@ -18,6 +59,120 @@ module Jobshop
18
59
  def path
19
60
  @path ||= File.expand_path("spec/dummy")
20
61
  end
62
+
63
+ def factory_paths
64
+ [ Jobshop::Engine.root.join("spec", "factories") ]
65
+ end
66
+
67
+ def seed
68
+ with_dummy_app do
69
+ do_with_spinner("Loading factories") do
70
+ require "factory_bot_rails"
71
+ FactoryBot.definition_file_paths = factory_paths
72
+ FactoryBot.find_definitions if Rails.env.development?
73
+ end
74
+
75
+ do_with_spinner("Cleaning database") do
76
+ clean_database
77
+ end
78
+
79
+ @org = do_with_spinner("Creating sample Organization") do
80
+ FactoryBot.create(:organization)
81
+ end
82
+
83
+ @ceo = do_with_spinner("Creating first User") do
84
+ FactoryBot.create(:user, :ceo, organization: @org)
85
+ end
86
+
87
+ @places = do_with_spinner("Creating sample Places") do
88
+ FactoryBot.create_list(:place, 10, organization: @org)
89
+ end
90
+
91
+ @companies = do_with_spinner("Creating sample companies") do
92
+ FactoryBot.create_list(:company, 100, organization: @org,
93
+ created_by: @ceo)
94
+ end
95
+
96
+ @products = do_with_spinner("Creating sample Products") do
97
+ FactoryBot.create_list(:product, 50,
98
+ organization: @org,
99
+ created_by: @ceo)
100
+ end
101
+
102
+ do_with_spinner("Creating Routers for Products") do
103
+ @products.each do |product|
104
+ rp = FactoryBot.create(:routing_process, organization: @org,
105
+ product: product)
106
+ FactoryBot.create_list(:routing_step, rand(1..4),organization: @org,
107
+ routing_process: rp)
108
+ end
109
+ end
110
+
111
+ do_with_spinner("Creating sample Orders") do
112
+ 50.times do
113
+ ord = FactoryBot.create(:order, organization: @org,
114
+ company: @companies.sample,
115
+ created_by: @ceo)
116
+ FactoryBot.create_list(:order_line, rand(1..4), organization: @org,
117
+ order: ord,
118
+ product: @products.sample,
119
+ created_by: @ceo)
120
+ end
121
+ end
122
+
123
+ @widgets = do_with_spinner("Creating Collection of widgets") do
124
+ wc = FactoryBot.create(:widget_collection,
125
+ organization: @org)
126
+ FactoryBot.create_list(:widget_thing, 50, organization: @org,
127
+ collection: wc)
128
+ end
129
+
130
+ @widget_packs = do_with_spinner("Creating Collection of widget packs") do
131
+ wpc = FactoryBot.create(:widget_pack_collection,
132
+ organization: @org)
133
+ FactoryBot.create_list(:widget_pack_thing, 50, organization: @org,
134
+ collection: wpc,
135
+ widgets: @widgets)
136
+ end
137
+
138
+ do_with_spinner("Creating Inspection Reports") do
139
+ 10.times do
140
+ report = FactoryBot.create(:inspection_report, organization: @org)
141
+ 8.times do |index|
142
+ FactoryBot.create(Jobshop::Inspection::CRITERION_TYPES.sample,
143
+ organization: @org, report: report,
144
+ position: (index + 1))
145
+ end
146
+ 10.times do |index|
147
+ tuple = FactoryBot.create(:inspection_tuple, organization: @org,
148
+ report: report, position: (index + 1))
149
+ report.criteria.each do |criterion|
150
+ FactoryBot.create(:inspection_result, organization: @org,
151
+ report: report, criterion: criterion,
152
+ tuple: tuple)
153
+ end
154
+ end
155
+ end
156
+ end
157
+ #binding.pry
158
+ end
159
+ end
160
+
161
+ private def with_dummy_app(&block)
162
+ begin
163
+ require "#{Jobshop::DummyApp.path}/config/environment"
164
+ rescue LoadError
165
+ abort "Dummy app does not exist. Run `jobshop dummy` to create it."
166
+ end
167
+
168
+ yield
169
+ end
170
+
171
+ private def clean_database
172
+ require "database_cleaner"
173
+ DatabaseCleaner.strategy = :truncation
174
+ DatabaseCleaner.clean
175
+ end
21
176
  end
22
177
  end
23
178
  end
@@ -1,29 +1,46 @@
1
- require "action_view"
2
- require "postgresql/check"
3
- require "devise"
4
- require "haml-rails"
5
- require "jquery-rails"
6
- require "material_design_lite-sass"
7
- require "pundit"
1
+ require "active_support/lazy_load_hooks"
2
+ require "activerecord_json_validator"
3
+ require "composite_primary_keys"
4
+ require "fast_jsonapi"
5
+ require "jwt"
6
+ require "rack/cors"
7
+ require "rails/all"
8
8
  require "redis-rails"
9
- require "rolify"
10
- require "sass-rails"
11
- require "simple_form"
12
- require "turbolinks"
9
+ require "unitwise"
13
10
 
14
11
  module Jobshop
15
12
  class Engine < ::Rails::Engine
16
13
  isolate_namespace Jobshop
17
14
 
15
+ config.generators.api_only = true
16
+
18
17
  config.generators do |g|
18
+ g.orm :active_record, primary_key_type: :uuid
19
19
  g.test_framework :rspec, view_specs: false
20
20
  g.helper false
21
21
  g.javascripts false
22
22
  end
23
23
 
24
- initializer "jobshop.append_migrations_paths", before: :load_config_initializers do
24
+ initializer "jobshop.middleware" do
25
+ config.middleware.use Rack::Cors do
26
+ allow do
27
+ origins "localhost:4200"
28
+ resource "*",
29
+ headers: :any,
30
+ expose: %w(access-token expiry token-type uid client),
31
+ methods: %i(get post options delete put)
32
+ end
33
+ end
34
+ end
35
+
36
+ ActiveSupport::Inflector.inflections do |inflect|
37
+ inflect.irregular "criterion", "criteria"
38
+ inflect.acronym "jwt"
39
+ end
40
+
41
+ initializer "jobshop.append_paths", before: :load_config_initializers do |app|
25
42
  config.paths["db/migrate"].expanded.each do |expanded_path|
26
- Rails.application.config.paths["db/migrate"] << expanded_path
43
+ app.config.paths["db/migrate"] << expanded_path
27
44
  end
28
45
  end
29
46
 
@@ -38,23 +55,5 @@ module Jobshop
38
55
  host: Jobshop.configuration.mailer_host
39
56
  }
40
57
  end
41
-
42
- initializer "jobshop.active_sessions", after: :load_config_initializers do
43
- Warden::Manager.after_set_user except: :fetch do |user, warden, opts|
44
- SessionActivation.deactivate(warden.raw_session["activation_token"])
45
- warden.raw_session["activation_token"] = user.activate_session
46
- end
47
-
48
- Warden::Manager.after_fetch do |user, warden, opts|
49
- unless user.session_active?(warden.raw_session["activation_token"])
50
- warden.logout
51
- throw :warden, message: :unauthenticated
52
- end
53
- end
54
-
55
- Warden::Manager.before_logout do |user, warden, opts|
56
- SessionActivation.deactivate warden.raw_session["activation_token"]
57
- end
58
- end
59
58
  end
60
59
  end
@@ -0,0 +1,55 @@
1
+ module Jobshop
2
+ module Helpers
3
+ module Migration
4
+ def idx_table_name_pkey(table_name)
5
+ execute <<~SQL
6
+ ALTER TABLE #{table_name}
7
+ ADD PRIMARY KEY USING INDEX idx_#{table_name}_pkey;
8
+ SQL
9
+ end
10
+
11
+ def fk_organization_id(table_name)
12
+ foreign_key table_name, :jobshop_organizations, :organization_id
13
+ end
14
+
15
+ def fk_created_by_id(table_name)
16
+ foreign_key table_name, :jobshop_users,
17
+ { organization_id: :organization_id, created_by_id: :user_id }
18
+ end
19
+
20
+ def nested_set_attrs(table_name)
21
+ reference_column = table_name.sub(/jobshop_/, "").singularize + "_id"
22
+ add_column table_name, :parent_id, :uuid
23
+ add_column table_name, :lft, :uuid
24
+ add_column table_name, :rgt, :uuid
25
+
26
+ foreign_key table_name, table_name, { organization_id: :organization_id,
27
+ parent_id: reference_column }
28
+ end
29
+
30
+ def foreign_key(table_name, reference_table, columns, options = "")
31
+ if columns.is_a?(Hash)
32
+ keys = []
33
+ references = []
34
+
35
+ columns.each do |k, v|
36
+ keys.push(k)
37
+ references.push(v)
38
+ end
39
+ else
40
+ keys = references = Array(columns)
41
+ end
42
+
43
+ constraint_name = "fk_#{table_name}_#{keys.join('_')}"
44
+
45
+ execute <<~SQL
46
+ ALTER TABLE #{table_name}
47
+ ADD CONSTRAINT #{constraint_name}
48
+ FOREIGN KEY (#{keys.join(", ")})
49
+ REFERENCES #{reference_table} (#{references.join(", ")})
50
+ #{options};
51
+ SQL
52
+ end
53
+ end
54
+ end
55
+ end
@@ -6,10 +6,10 @@ module Jobshop
6
6
  module VERSION
7
7
  MAJOR = 0
8
8
  MINOR = 0
9
- TINY = 131
9
+ TINY = 157
10
10
  PRE = nil
11
11
 
12
- CODE_NAME = "bump it up prime".freeze
12
+ CODE_NAME = "the floor is making progress".freeze
13
13
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".").freeze
14
14
  end
15
15
  end
data/lib/jobshop.rb CHANGED
@@ -1,25 +1,11 @@
1
- module Jobshop
2
- class << self
3
- attr_writer :configuration
4
-
5
- def configuration
6
- @configuration ||= Configuration.new
7
- end
1
+ require "jobshop/version"
8
2
 
9
- def configure
10
- yield(configuration)
11
- end
12
- end
3
+ # Jobshop Configuration
4
+ require "jobshop/configuration"
13
5
 
14
- class Configuration
15
- attr_accessor :mailer_host,
16
- :session_store_url
6
+ # Jobshop Engine
7
+ require "jobshop/engine"
17
8
 
18
- def initialize
19
- @mailer_host = ENV.fetch("JOBSHOP_MAILER_HOST", "localhost:3000")
20
- @session_store_url ||= ENV.fetch("SESSION_STORE_URL", "redis://localhost:6379/0")
21
- end
22
- end
9
+ module Jobshop
10
+ # Your code goes here...
23
11
  end
24
-
25
- require "jobshop/engine"
@@ -1,4 +1,4 @@
1
- # This effectively hides the rake task from `$ rake -T`.
1
+ # This effectively hides `rake jobshop:install:migrations` from `$ rake -T`.
2
2
  Rake::Task["jobshop:install:migrations"].instance_variable_set(:@comments, [])
3
3
 
4
4
  namespace :jobshop do
@@ -14,29 +14,12 @@ namespace :jobshop do
14
14
  end
15
15
  end
16
16
 
17
- desc "Outputs team[:name] and team[:id] for all sites within Jobshop."
18
- task teams: :environment do
19
- Jobshop::Team.joins(:owner)
20
- .select([ "jobshop_teams.id", "name", "jobshop_users.email AS owner_email" ]).each do |team|
21
- team_name = team.name.ljust(32)
22
- puts "#{team_name} | #{team.id} | #{team.owner_email} "
23
- end
24
- end
25
-
26
- namespace :teams do
27
- desc "Clear out teams that haven't been registered after 24 hours"
28
- task purge: :environment do
29
- deleted_teams = Jobshop::Team
30
- .where(Jobshop::Team.arel_table[:registration_token_sent_at]
31
- .lt(24.hours.ago))
32
- .where(owner_id: nil)
33
- .destroy_all
34
-
35
- count = deleted_teams.count
36
- inflection = "team".pluralize(count)
37
- list = deleted_teams.map(&:id).join("\n")
38
-
39
- puts "Purged #{count} #{inflection}\n#{list}"
17
+ desc "Outputs organization[:name] and organization[:id] for all sites within Jobshop."
18
+ task organizations: :environment do
19
+ Jobshop::Organization
20
+ .select([ "jobshop_organizations.id", "name" ]).each do |organization|
21
+ organization_name = organization.name.ljust(32)
22
+ puts "#{organization_name} | #{organization.id}"
40
23
  end
41
24
  end
42
25
  end