decko 0.11.7 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/lib/card_controller.rb +4 -0
  3. data/lib/card_controller/errors.rb +11 -13
  4. data/lib/decko.rb +2 -15
  5. data/lib/decko/all.rb +2 -0
  6. data/lib/decko/application.rb +22 -56
  7. data/lib/decko/cli.rb +1 -7
  8. data/lib/decko/commands.rb +17 -110
  9. data/lib/decko/commands/application.rb +2 -2
  10. data/lib/decko/commands/cucumber_command.rb +8 -7
  11. data/lib/decko/commands/cucumber_command/parser.rb +2 -2
  12. data/lib/decko/engine.rb +3 -14
  13. data/lib/decko/generators.rb +17 -0
  14. data/lib/decko/mods_spec_helper.rb +1 -1
  15. data/lib/decko/script_decko_loader.rb +5 -38
  16. data/lib/decko/tasks/cucumber.rake +25 -16
  17. data/lib/decko/tasks/decko.rake +1 -2
  18. data/lib/decko/tasks/decko/seed.rake +5 -3
  19. data/lib/generators/deck/deck_generator.rb +12 -0
  20. metadata +23 -65
  21. data/lib/decko/commands/command.rb +0 -28
  22. data/lib/decko/commands/rake_command.rb +0 -42
  23. data/lib/decko/commands/rake_command/parser.rb +0 -35
  24. data/lib/decko/commands/rspec_command.rb +0 -36
  25. data/lib/decko/commands/rspec_command/parser.rb +0 -97
  26. data/lib/decko/config/environments/cucumber.rb +0 -41
  27. data/lib/decko/config/environments/cypress.rb +0 -100
  28. data/lib/decko/config/environments/development.rb +0 -95
  29. data/lib/decko/config/environments/production.rb +0 -75
  30. data/lib/decko/config/environments/profile.rb +0 -33
  31. data/lib/decko/config/environments/test.rb +0 -69
  32. data/lib/decko/config/initializers/secret_token.rb +0 -15
  33. data/lib/decko/config/initializers/sedate_parser.rb +0 -8
  34. data/lib/decko/config/initializers/session_store.rb +0 -2
  35. data/lib/decko/generators/deck/USAGE +0 -9
  36. data/lib/decko/generators/deck/deck_generator.rb +0 -134
  37. data/lib/decko/generators/deck/deck_generator/deck_helper.rb +0 -110
  38. data/lib/decko/generators/deck/deck_generator/interactive.rb +0 -120
  39. data/lib/decko/generators/deck/deck_generator/rails_overrides.rb +0 -54
  40. data/lib/decko/generators/deck/templates/Gemfile.erb +0 -56
  41. data/lib/decko/generators/deck/templates/Rakefile.erb +0 -6
  42. data/lib/decko/generators/deck/templates/bin/spring.erb +0 -20
  43. data/lib/decko/generators/deck/templates/config.ru.erb +0 -11
  44. data/lib/decko/generators/deck/templates/config/application.rb.erb +0 -107
  45. data/lib/decko/generators/deck/templates/config/boot.rb.erb +0 -11
  46. data/lib/decko/generators/deck/templates/config/cucumber.yml +0 -1
  47. data/lib/decko/generators/deck/templates/config/databases/frontbase.yml +0 -34
  48. data/lib/decko/generators/deck/templates/config/databases/ibm_db.yml +0 -89
  49. data/lib/decko/generators/deck/templates/config/databases/jdbc.yml +0 -65
  50. data/lib/decko/generators/deck/templates/config/databases/jdbcmysql.yml +0 -36
  51. data/lib/decko/generators/deck/templates/config/databases/jdbcpostgresql.yml +0 -46
  52. data/lib/decko/generators/deck/templates/config/databases/jdbcsqlite3.yml +0 -23
  53. data/lib/decko/generators/deck/templates/config/databases/mysql.yml +0 -37
  54. data/lib/decko/generators/deck/templates/config/databases/oracle.yml +0 -42
  55. data/lib/decko/generators/deck/templates/config/databases/postgresql.yml +0 -39
  56. data/lib/decko/generators/deck/templates/config/databases/sqlite3.yml +0 -21
  57. data/lib/decko/generators/deck/templates/config/deck.yml +0 -10
  58. data/lib/decko/generators/deck/templates/config/environment.rb.erb +0 -5
  59. data/lib/decko/generators/deck/templates/config/initializers/cypress.rb +0 -12
  60. data/lib/decko/generators/deck/templates/config/puma.rb +0 -16
  61. data/lib/decko/generators/deck/templates/config/routes.rb.erb +0 -11
  62. data/lib/decko/generators/deck/templates/config/storage.yml +0 -0
  63. data/lib/decko/generators/deck/templates/gitignore +0 -18
  64. data/lib/decko/generators/deck/templates/pryrc +0 -6
  65. data/lib/decko/generators/deck/templates/public/files/htaccess +0 -9
  66. data/lib/decko/generators/deck/templates/public/robots.txt +0 -13
  67. data/lib/decko/generators/deck/templates/rspec.erb +0 -6
  68. data/lib/decko/generators/deck/templates/script/decko +0 -6
  69. data/lib/decko/generators/deck/templates/script/decko_cucumber +0 -8
  70. data/lib/decko/generators/deck/templates/script/decko_rspec +0 -8
  71. data/lib/decko/generators/deck/templates/script/delayed_job +0 -5
  72. data/lib/decko/generators/deck/templates/simplecov.rb.erb +0 -34
  73. data/lib/decko/generators/deck/templates/spec/javascripts/support/deck_jasmine.yml.erb +0 -56
  74. data/lib/decko/generators/deck/templates/spec/javascripts/support/decko_jasmine.yml.erb +0 -74
  75. data/lib/decko/generators/deck/templates/spec/spec_helper.rb +0 -1
  76. data/script/autospec +0 -4
  77. data/script/decko +0 -6
  78. data/script/rails +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a66f5fefa04c2c0cdb0d972fb53a292ffa8db86c0cdaefbce4311df918793b32
4
- data.tar.gz: 6a01a78d7177b1a29917373117db2d09a85c14737eb1c05f66db27b6ca79e4d8
3
+ metadata.gz: 8bb3b3da3fa9c6e8e1fe97ee9ab4fa406b7c3dcb5850db324c1404ac378de442
4
+ data.tar.gz: 4878e14c56ef66cc61cc376aa6c6f0a2cdbc9c0dc7e6b4d4308b140f8b688c91
5
5
  SHA512:
6
- metadata.gz: 497737ef6f1fc5e506fc4c2e399134dbe2528d24a4cc688a9c140ad5d883822ae9d04340f10108f7f978b227f2daed69d819844208aa2d07536e6fdaa78e057f
7
- data.tar.gz: 4d32fc214d767aaf52d34c6bff39d7595cf029daf6dad37febf95c4ed64e923d3ea51afed006d26152d8a5f8863484a7c31820e02f175b0110ac979d80498e71
6
+ metadata.gz: afbfc8a1b33c3e00f4734fb89c25c02abdadb6fb50e9b31b1056409123ccd9237a23069332ef1aea8f0c8f1372a6e47408e9deef742b123c817bffb08c48d736
7
+ data.tar.gz: a8a564f378ecbbb8ac75f0087f2f5e9daa93fd000962ded9e90779caf09fe9c6dcd543c150ea3a35dfcd03b05050c9a0b58782070c0a49d2016033bf14e8a60a
@@ -6,6 +6,7 @@ class CardController < ActionController::Base
6
6
  include Rest
7
7
  include Response
8
8
  include Errors
9
+ extend Errors::Rescue
9
10
 
10
11
  # NOTE: including Card::Env::Location triggers card loading, which triggers mod loading,
11
12
  # which can include initializers that add to the CardController class.
@@ -22,4 +23,7 @@ class CardController < ActionController::Base
22
23
  before_action :load_card, except: [:asset]
23
24
  before_action :load_action, only: [:read]
24
25
  before_action :refresh_card, only: %i[create update delete]
26
+
27
+ rescue_from_class(*Card::Error::UserError.user_error_classes)
28
+ rescue_from_class StandardError if rescue_all?
25
29
  end
@@ -1,19 +1,20 @@
1
1
  # Decko's only controller.
2
2
  class CardController
3
- class << self
4
- def rescue_from_class *klasses
5
- klasses.each do |klass|
6
- rescue_from(klass) { |exception| handle_exception exception }
3
+ # controller error handling
4
+ module Errors
5
+ # controller class method to handle top-level error rescuing
6
+ module Rescue
7
+ def rescue_from_class *klasses
8
+ klasses.each do |klass|
9
+ rescue_from(klass) { |exception| handle_exception exception }
10
+ end
7
11
  end
8
- end
9
12
 
10
- def rescue_all?
11
- Cardio.config.rescue_all_in_controller
13
+ def rescue_all?
14
+ Cardio.config.rescue_all_in_controller
15
+ end
12
16
  end
13
- end
14
17
 
15
- # controller error handling
16
- module Errors
17
18
  def handle_exception exception
18
19
  raise exception if debug_exception?(exception)
19
20
 
@@ -30,7 +31,4 @@ class CardController
30
31
  Card[:debugger]&.content =~ /on/ # && !Card::Env.ajax?
31
32
  end
32
33
  end
33
-
34
- rescue_from_class(*Card::Error::UserError.user_error_classes)
35
- rescue_from_class StandardError if rescue_all?
36
34
  end
data/lib/decko.rb CHANGED
@@ -2,21 +2,8 @@ module Decko
2
2
  DECKO_GEM_ROOT = File.expand_path("..", __dir__)
3
3
 
4
4
  class << self
5
- def root
6
- Rails.root
7
- end
8
-
9
- def application
10
- Rails.application
11
- end
12
-
13
- def config
14
- application.config
15
- end
16
-
17
- def paths
18
- application.paths
19
- end
5
+ delegate :application, :root, to: :Rails
6
+ delegate :config, :paths, to: :application
20
7
 
21
8
  def gem_root
22
9
  DECKO_GEM_ROOT
data/lib/decko/all.rb CHANGED
@@ -1 +1,3 @@
1
+ # backwards compatibility for old decks that require decko/all
2
+
1
3
  require "decko/application"
@@ -1,16 +1,20 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- require "decko/engine"
4
- require_relative "config/initializers/sedate_parser"
3
+ require "action_controller/railtie"
4
+ require "cardio/application"
5
5
 
6
- Bundler.require :default, *Rails.groups
6
+ # require_relative "config/initializers/sedate_parser"
7
7
 
8
8
  module Decko
9
- class Application < Rails::Application
10
- initializer :load_decko_environment_config,
9
+ # The application class from which all decko applications inherit
10
+ class Application < Cardio::Application
11
+ require "decko/engine"
12
+
13
+ card_environment_initializer
14
+
15
+ initializer "decko.load_environment_config",
11
16
  before: :load_environment_config, group: :all do
12
- add_path paths, "lib/decko/config/environments", glob: "#{Rails.env}.rb"
13
- paths["lib/decko/config/environments"].existent.each do |environment|
17
+ paths["decko/config/environments"].existent.each do |environment|
14
18
  require environment
15
19
  end
16
20
  end
@@ -24,36 +28,9 @@ module Decko
24
28
  end
25
29
  end
26
30
 
27
- def add_path paths, path, options={}
28
- root = options.delete(:root) || Decko.gem_root
29
- options[:with] = File.join(root, (options[:with] || path))
30
- paths.add path, options
31
- end
32
-
33
31
  def config
34
- @config ||= begin
35
- config = super
36
-
37
- Cardio.set_config config
38
-
39
- # any config settings below:
40
- # (a) do not apply to Card used outside of a Decko context
41
- # (b) cannot be overridden in a deck's application.rb, but
42
- # (c) CAN be overridden in an environment file
43
-
44
- # therefore, in general, they should be restricted to settings that
45
- # (1) are specific to the web environment, and
46
- # (2) should not be overridden
47
- # ..and we should address (c) above!
48
-
49
- # general card settings (overridable and not) should be in cardio.rb
50
- # overridable decko-specific settings don't have a place yet
51
- # but should probably follow the cardio pattern.
52
-
32
+ @config ||= super.tap do |config|
53
33
  # config.load_defaults "6.0"
54
- config.autoloader = :zeitwerk
55
- config.load_default = "6.0"
56
- config.i18n.enforce_available_locales = true
57
34
  # config.active_record.raise_in_transactional_callbacks = true
58
35
 
59
36
  config.allow_concurrency = false
@@ -61,33 +38,22 @@ module Decko
61
38
  config.assets.version = "1.0"
62
39
 
63
40
  config.filter_parameters += [:password]
64
-
65
- # Rails.autoloaders.log!
66
- Rails.autoloaders.main.ignore(
67
- File.join(Cardio.gem_root, "lib/card/seed_consts.rb")
68
- )
69
- config
41
+ config.autoload_paths += Dir["#{Decko.gem_root}/lib"]
42
+ decko_path_defaults config.paths
70
43
  end
71
44
  end
72
45
 
73
- def paths
74
- @paths ||= begin
75
- paths = super
76
- Cardio.set_paths paths
77
-
78
- paths.add "files"
46
+ private
79
47
 
80
- paths["app/models"] = []
81
- paths["app/mailers"] = []
82
- paths["app/controllers"] = []
48
+ def decko_path_defaults paths
49
+ paths.add "decko/config/environments",
50
+ with: File.join(Decko.gem_root, "config/environments"),
51
+ glob: "#{Rails.env}.rb"
83
52
 
84
- unless paths["config/routes.rb"].existent.present?
85
- add_path paths, "config/routes.rb",
86
- with: "rails/application-routes.rb"
87
- end
53
+ return if paths["config/routes.rb"].existent.present?
88
54
 
89
- paths
90
- end
55
+ paths.add "config/routes.rb",
56
+ with: File.join(Decko.gem_root, "rails/application-routes.rb")
91
57
  end
92
58
  end
93
59
  end
data/lib/decko/cli.rb CHANGED
@@ -6,12 +6,6 @@ require "decko/script_decko_loader"
6
6
  Decko::ScriptDeckoLoader.exec!
7
7
 
8
8
  require "rails/ruby_version_check"
9
- Signal.trap("INT") { puts; exit(1) }
10
-
11
- # if ARGV.first == 'plugin'
12
- # ARGV.shift
13
- # require 'decko/commands/plugin_new'
14
- # else
9
+ Signal.trap("INT") { exit(1) }
15
10
 
16
11
  require "decko/commands/application"
17
- # end
@@ -1,121 +1,28 @@
1
- # add method in? to Object class
2
- require "active_support/core_ext/object/inclusion"
1
+ ENV["CARDIO_COMMANDS"] = "NO_RUN"
3
2
 
4
- def load_rake_tasks
5
- require "./config/environment"
6
- require "rake"
7
- Decko::Application.load_tasks
8
- end
9
-
10
- RAILS_COMMANDS = %w[ generate destroy plugin benchmarker profiler console
11
- server dbconsole application runner ].freeze
12
- DECKO_COMMANDS = %w[new cucumber rspec jasmine].freeze
13
- DECKO_DB_COMMANDS = %w[seed reseed load update].freeze
14
-
15
- ALIAS = {
16
- "rs" => "rspec",
17
- "cc" => "cucumber",
18
- "jm" => "jasmine",
19
- "g" => "generate",
20
- "d" => "destroy",
21
- "c" => "console",
22
- "s" => "server",
23
- "db" => "dbconsole",
24
- "r" => "runner"
25
- }.freeze
26
-
27
- def supported_rails_command? arg
28
- arg.in?(RAILS_COMMANDS) || ALIAS[arg].in?(RAILS_COMMANDS)
29
- end
30
-
31
- ARGV << "--help" if ARGV.empty?
3
+ require "cardio/commands"
32
4
 
33
5
  module Decko
34
- module Commands
35
- class << self
36
- def run_new
37
- if ARGV.first.in?(["-h", "--help"])
38
- require "decko/commands/application"
39
- else
40
- puts "Can't initialize a new deck within the directory of another, " \
41
- "please change to a non-deck directory first.\n"
42
- puts "Type 'decko' for help."
43
- exit(1)
44
- end
45
- end
46
-
47
- def run_rspec
48
- require "decko/commands/rspec_command"
49
- RspecCommand.new(ARGV).run
50
- end
51
-
52
- def run_cucumber
53
- require "decko/commands/cucumber_command"
54
- CucumberCommand.new(ARGV).run
55
- end
6
+ class Commands < Cardio::Commands
7
+ extend Cardio::Commands::Accessors
56
8
 
57
- def run_db_task command
58
- require "decko/commands/rake_command"
59
- RakeCommand.new("decko:#{command}", ARGV).run
60
- end
9
+ commands[:rails] << (aliases["s"] = "server")
10
+ commands[:custom] << (aliases["cc"] = "cucumber")
61
11
 
62
- def run_jasmine
63
- require "decko/commands/rake_command"
64
- RakeCommand.new("spec:javascript", envs: "test").run
65
- end
12
+ def run_cucumber
13
+ require "decko/commands/cucumber_command"
14
+ CucumberCommand.new(args).run
66
15
  end
67
- end
68
- end
69
-
70
- command = ARGV.first
71
- command = ALIAS[command] || command
72
- if supported_rails_command? command
73
- ENV["PRY_RESCUE_RAILS"] = "1" if ARGV.delete("--rescue")
74
-
75
- # without this, the card generators don't list with: decko g --help
76
- require "generators/card" if command == "generate"
77
- require "rails/commands"
78
- else
79
- ARGV.shift
80
- case command
81
- when "--version", "-v"
82
- puts "Decko #{Card::Version.release}"
83
- when *DECKO_COMMANDS
84
- Decko::Commands.send("run_#{command}")
85
- when *DECKO_DB_COMMANDS
86
- Decko::Commands.run_db_task command
87
- else
88
- puts "Error: Command not recognized" unless command.in?(["-h", "--help"])
89
- puts <<-EOT
90
- Usage: decko COMMAND [ARGS]
91
16
 
92
- The most common decko commands are:
93
- new Create a new Decko deck. "decko new my_deck" creates a
94
- new deck called MyDeck in "./my_deck"
95
- seed Create and seed the database specified in config/database.yml
96
-
97
- server Start the Rails server (short-cut alias: "s")
98
- console Start the Rails console (short-cut alias: "c")
99
- dbconsole Start a console for the database specified in config/database.yml
100
- (short-cut alias: "db")
101
-
102
- For core developers
103
- cucumber Run cucumber features (short-cut alias: "cc")
104
- rspec Run rspec tests (short-cut alias: "rs")
105
- update Run card migrations
106
- load Load bootstrap data into database
17
+ def rake_prefix
18
+ "decko"
19
+ end
107
20
 
108
- In addition to those, there are the standard rails commands:
109
- generate Generate new code (short-cut alias: "g")
110
- application Generate the Rails application code
111
- destroy Undo code generated with "generate" (short-cut alias: "d")
112
- benchmarker See how fast a piece of code runs
113
- profiler Get profile information from a piece of code
114
- plugin Install a plugin
115
- runner Run a piece of code in the application environment (short-cut alias: "r")
21
+ def run_rails
22
+ require "decko/generators" if command == "generate"
23
+ super
24
+ end
116
25
 
117
- All commands can be run with -h (or --help) for more information.
118
- EOT
119
- exit(1)
26
+ new(ARGV).run
120
27
  end
121
28
  end
@@ -1,5 +1,5 @@
1
1
  require "rails/generators"
2
- require File.expand_path("../generators/deck/deck_generator", __dir__)
2
+ require File.expand_path("../../../generators/deck/deck_generator", __FILE__)
3
3
 
4
4
  if ARGV.first != "new"
5
5
  ARGV[0] = "--help"
@@ -7,4 +7,4 @@ else
7
7
  ARGV.shift
8
8
  end
9
9
 
10
- Decko::Generators::Deck::DeckGenerator.start
10
+ Cardio::Generators::Deck::DeckGenerator.start
@@ -1,11 +1,14 @@
1
- require File.expand_path("command", __dir__)
1
+ # load the application so we can look in mods
2
+ require APP_PATH
3
+ require "cardio/commands/command"
4
+ require "cardio/mod/dirs"
2
5
 
3
6
  module Decko
4
- module Commands
5
- class CucumberCommand < Command
7
+ class Commands
8
+ class CucumberCommand < Cardio::Commands::Command
9
+ require "decko/commands/cucumber_command/parser"
10
+
6
11
  def initialize args
7
- require "decko"
8
- require "./config/environment"
9
12
  @decko_args, @cucumber_args = split_args args
10
13
  @opts = {}
11
14
  Parser.new(@opts).parse!(@decko_args)
@@ -44,5 +47,3 @@ module Decko
44
47
  end
45
48
  end
46
49
  end
47
-
48
- require File.expand_path("cucumber_command/parser", __dir__)
@@ -3,7 +3,7 @@
3
3
  require "optparse"
4
4
 
5
5
  module Decko
6
- module Commands
6
+ class Commands
7
7
  class CucumberCommand
8
8
  class Parser < OptionParser
9
9
  class Flagger
@@ -34,7 +34,7 @@ module Decko
34
34
  super() do |parser|
35
35
  parser.banner = "Usage: decko cucumber [DECKO ARGS] -- [CUCUMBER ARGS]\n\n"
36
36
  parser.separator "\nDECKO ARGS"
37
- opts[:env] = ["RAILS_ROOT=."]
37
+ opts[:env] = ["RAILS_ROOT=. RAILS_ENV=cucumber"]
38
38
  Flagger.new(parser, opts).add_flags
39
39
  parse_spring parser, opts
40
40
  end
data/lib/decko/engine.rb CHANGED
@@ -1,15 +1,4 @@
1
- require "rails/all"
2
1
  require "cardio"
3
-
4
- # TODO: Move these to modules that use them
5
- require "htmlentities"
6
- require "coderay"
7
- require "haml"
8
- require "kaminari"
9
- require "bootstrap4-kaminari-views"
10
- require "diff/lcs"
11
- require "builder"
12
-
13
2
  require "decko"
14
3
 
15
4
  module Decko
@@ -19,13 +8,13 @@ module Decko
19
8
  paths.add "lib/tasks", with: "#{::Decko.gem_root}/lib/decko/tasks",
20
9
  glob: "**/*.rake"
21
10
  paths["lib/tasks"] << "#{::Cardio.gem_root}/lib/card/tasks"
22
- paths.add "lib/decko/config/initializers",
23
- with: File.join(Decko.gem_root, "lib/decko/config/initializers"),
11
+ paths.add "decko/config/initializers",
12
+ with: File.join(Decko.gem_root, "config/initializers"),
24
13
  glob: "**/*.rb"
25
14
 
26
15
  initializer "decko.engine.load_config_initializers",
27
16
  after: :load_config_initializers do
28
- paths["lib/decko/config/initializers"].existent.sort.each do |initializer|
17
+ paths["decko/config/initializers"].existent.sort.each do |initializer|
29
18
  load(initializer)
30
19
  end
31
20
  end