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
@@ -1,33 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- Decko.application.class.configure do
4
- # Settings specified here will take precedence over those in config/environment.rb
5
- # The profile environment should match the same settings
6
- # as the production environment to give a reasonalbe
7
- # approximation of performance. However, it should
8
- # definitely not use the production databse!
9
-
10
- config.eager_load = true
11
-
12
- # Cache classes - otherwise your code
13
- # will run approximately 5 times slower and the
14
- # profiling results will be overwhelmed by Rails
15
- # dependency loading mechanism
16
- config.cache_classes = true
17
-
18
- # Don't check template timestamps - once again this
19
- # is to avoid IO times overwhelming profile results
20
- config.action_view.cache_template_loading = true
21
-
22
- # This is debatable, but turn off action controller
23
- # caching to see how long it really takes to run
24
- # queries and render templates
25
- config.action_controller.perform_caching = true
26
-
27
- # Turn off most logging
28
- config.log_level = :info
29
-
30
- config.active_support.deprecation = :log
31
-
32
- config.action_mailer.perform_deliveries = false
33
- end
@@ -1,69 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- Decko.application.class.configure do
4
- # Settings specified here will take precedence over those in config/application.rb
5
-
6
- config.eager_load = false
7
-
8
- config.machine_refresh = :never
9
-
10
- # The test environment is used exclusively to run your application's
11
- # test suite. You never need to work with it otherwise. Remember that
12
- # your test database is "scratch space" for the test suite and is wiped
13
- # and recreated between test runs. Don't rely on the data there!
14
- config.cache_classes = false
15
-
16
- config.assets.enabled = true if Object.const_defined?(:JasmineRails)
17
-
18
- config.persistent_cache = false
19
- config.prepopulate_cache = true
20
-
21
- # Configure static asset server for tests with Cache-Control for performance
22
- config.serve_static_files = true
23
- config.static_cache_control = "public, max-age=3600"
24
-
25
- # Log error messages when you accidentally call methods on nil
26
- config.whiny_nils = true
27
-
28
- # Show full error reports and disable caching
29
- config.consider_all_requests_local = true
30
- config.action_controller.perform_caching = false
31
-
32
- # Raise exceptions instead of rendering exception templates
33
- config.action_dispatch.show_exceptions = false
34
-
35
- # Disable request forgery protection in test environment
36
- config.action_controller.allow_forgery_protection = false
37
-
38
- # Tell Action Mailer not to deliver emails to the real world.
39
- # The :test delivery method accumulates sent emails in the
40
- # ActionMailer::Base.deliveries array.
41
- config.action_mailer.delivery_method = :test
42
- config.action_mailer.perform_deliveries = true
43
- config.action_mailer.default charset: "utf-8"
44
-
45
- # config.action_mailer.delivery_method = :smtp
46
- # config.action_mailer.smtp_settings = { address: "localhost", port: 1025 }
47
-
48
- # Use SQL instead of Active Record's schema dumper when creating the test database.
49
- # This is necessary if your schema can't be completely dumped by the schema dumper,
50
- # like if you have constraints or database-specific column types
51
- # config.active_record.schema_format = :sql
52
-
53
- # FIXME: - add back the next one when we go back to 3.2
54
- # Raise exception on mass assignment protection for Active Record models
55
- # config.active_record.mass_assignment_sanitizer = :strict
56
-
57
- # Print deprecation notices to the stderr
58
- config.active_support.deprecation = :stderr
59
-
60
- config.raise_all_rendering_errors = true
61
-
62
- config.rescue_all_in_controller = false
63
- # Use Pry instead of IRB
64
- silence_warnings do
65
- require "pry"
66
- config.console = Pry
67
- rescue LoadError
68
- end
69
- end
@@ -1,15 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- # Be sure to restart your server when you modify this file.
4
-
5
- # Your secret key for verifying the integrity of signed cookies.
6
- # If you change this key, all old signed cookies will become invalid!
7
- # Make sure the secret is at least 30 characters and all random,
8
- # no regular words or you'll be exposed to dictionary attacks.
9
-
10
- Decko.config.secret_token = "65632e048d6c80d1e63c911e1a40a51072413543f3182e0261"\
11
- "b52e3812b2c9f0ee81828fa5688a34c13a78e438a4b56f4971"\
12
- "35dc079a4e4460733d555968a2f8"
13
- Decko.config.secret_key_base = "65632e048d6c80d1e63c911e1a40a51072413543f3182e0"\
14
- "261b52e3812b2c9f0ee81828fa5688a34c13a78e438a4b5"\
15
- "6f497135dc079a4e4460733d555968a2f8"
@@ -1,8 +0,0 @@
1
- # Hack to get rid of annoying parser warnings
2
- module Parser
3
- def self.warn msg
4
- super unless msg.match?(
5
- %r{^warning: (?:parser/current|[\d.]+-compliant syntax|please see)}
6
- )
7
- end
8
- end
@@ -1,2 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- # Be sure to restart your server when you modify this file.
@@ -1,9 +0,0 @@
1
- Description:
2
- The 'decko new' command creates a new Decko deck with a default
3
- directory structure and configuration at the path you specify.
4
-
5
- Example:
6
- decko new ~/Poker/FullHouse
7
-
8
- This generates a new deck in ~/Poker/FullHouse.
9
-
@@ -1,134 +0,0 @@
1
- require "rails/generators/app_base"
2
-
3
- module Decko
4
- module Generators
5
- module Deck
6
- # Create new Decks (Decko Applications)
7
- class DeckGenerator < Rails::Generators::AppBase
8
- require "decko/generators/deck/deck_generator/rails_overrides"
9
- require "decko/generators/deck/deck_generator/deck_helper"
10
-
11
- include RailsOverrides
12
- include DeckHelper
13
-
14
- source_root File.expand_path("templates", __dir__)
15
-
16
- # All but the first aliases should be considered deprecated
17
- class_option "monkey",
18
- type: :boolean, aliases: %w[-M --mod-dev],
19
- default: false, group: :runtime,
20
- desc: "Prepare deck for monkey (mod developer)"
21
-
22
- class_option "platypus",
23
- type: :boolean, aliases: %w[-P --core-dev -c],
24
- default: false, group: :runtime,
25
- desc: "Prepare deck for platypus (core development)"
26
-
27
- class_option "repo-path",
28
- type: :string, aliases: %w[-R -g --gem-path],
29
- default: "", group: :runtime,
30
- desc: "Path to local decko repository " \
31
- "(Default, use env DECKO_REPO_PATH)"
32
-
33
- class_option :database,
34
- type: :string, aliases: %w[-D -d], default: "mysql",
35
- desc: "Preconfigure for selected database " \
36
- "(options: #{DATABASES.join('/')})"
37
-
38
- class_option "interactive",
39
- type: :boolean, aliases: %w[-I -i], default: false, group: :runtime,
40
- desc: "Prompt with dynamic installation options"
41
-
42
- public_task :set_default_accessors!
43
- public_task :create_root
44
-
45
- def self.banner
46
- "decko new #{arguments.map(&:usage).join(' ')} [options]"
47
- end
48
-
49
- # Generator works its way through each public method below
50
-
51
- def core_files
52
- erb_template "config.ru"
53
- erb_template "Gemfile"
54
- erb_template "Rakefile"
55
- end
56
-
57
- def empty_dirs
58
- %w[mod log files tmp].each { |dirname| empty_directory_with_keep_file dirname }
59
- end
60
-
61
- def dotfiles
62
- copy_file "pryrc", ".pryrc"
63
- copy_file "gitignore", ".gitignore"
64
- template "rspec.erb", ".rspec"
65
- template "simplecov.rb.erb", ".simplecov"
66
- end
67
-
68
- def config
69
- inside "config" do
70
- erb_template "application.rb"
71
- erb_template "routes.rb"
72
- erb_template "environment.rb"
73
- erb_template "boot.rb"
74
- template "databases/#{options[:database]}.yml", "database.yml"
75
- template "cucumber.yml"
76
- template "storage.yml"
77
- template "initializers/cypress.rb" if platypus?
78
- template "puma.rb"
79
- end
80
- end
81
-
82
- def public
83
- inside "public" do
84
- template "robots.txt"
85
- inside("files") { template "htaccess", ".htaccess" }
86
- end
87
- end
88
-
89
- def spring
90
- inside("bin") { erb_template "spring" }
91
- end
92
-
93
- def script
94
- directory("script") { |content| "#{shebang}\n" + content }
95
- chmod "script", 0o755 & ~File.umask, verbose: false
96
- end
97
-
98
- def spec
99
- inside "spec" do
100
- if platypus?
101
- jasmine_yml :decko
102
- else
103
- jasmine_yml :deck
104
- template "spec_helper.rb"
105
- end
106
- end
107
- end
108
-
109
- public_task :run_bundle
110
-
111
- def seed_data
112
- if options["interactive"]
113
- Interactive.new(destination_root, (monkey? || platypus?)).run
114
- else
115
- puts "Now:
116
- 1. Run `cd #{File.basename(destination_root)}` to enter your new deck directory
117
- 2. Run `decko seed` to seed your database (see config/database.yml).
118
- 3. Run `decko server` to start your server"
119
- end
120
- end
121
-
122
- protected
123
-
124
- def database_gemfile_entry
125
- return [] if options[:skip_active_record]
126
-
127
- gem_name, gem_version = gem_for_database
128
- msg = "Use #{options[:database]} as the database for Active Record"
129
- GemfileEntry.version gem_name, gem_version, msg
130
- end
131
- end
132
- end
133
- end
134
- end
@@ -1,110 +0,0 @@
1
- module Decko
2
- module Generators
3
- module Deck
4
- class DeckGenerator
5
- # Protected helper methods for DeckGenerator.
6
- # Many methods are called from .erb files.
7
- module DeckHelper
8
- protected
9
-
10
- def shark?
11
- !(monkey? || platypus?)
12
- end
13
-
14
- def monkey?
15
- options[:monkey]
16
- end
17
-
18
- def platypus?
19
- options[:platypus]
20
- end
21
-
22
- def erb_template name
23
- template "#{name}.erb", name
24
- end
25
-
26
- def repo_path
27
- @repo_path ||= determine_repo_path
28
- end
29
-
30
- def expanded_repo_path
31
- @expanded_repo_path ||= File.expand_path repo_path
32
- end
33
-
34
- def determine_repo_path
35
- @repo_path_determined ? (return nil) : (@repo_path_determined = true)
36
- path = options["repo-path"]
37
- path = ENV["DECKO_REPO_PATH"] if path.blank?
38
- path = prompt_for_repo_path if path.blank? && platypus?
39
- path.to_s
40
- end
41
-
42
- def repo_path_constraint
43
- repo_path.present? ? %(, path: "#{repo_path}") : ""
44
- end
45
-
46
- def prompt_for_repo_path
47
- @repo_path = ask "Enter the path to your local decko repository: "
48
- end
49
-
50
- def spec_path
51
- @spec_path ||= platypus? ? repo_path : "mod/"
52
- end
53
-
54
- def spec_helper_path
55
- @spec_helper_path ||=
56
- platypus? ? "#{repo_path}/card/spec/spec_helper" : "./spec/spec_helper"
57
- end
58
-
59
- def features_path
60
- @features_path ||=
61
- platypus? ? File.expand_path("#{repo_path}/decko/features/") : "mod/"
62
- end
63
-
64
- # FIXME: these gem roots are not correct unless repo_path is specified
65
- def cardio_gem_root
66
- @cardio_gem_root ||= File.join repo_path, "card"
67
- end
68
-
69
- def decko_gem_root
70
- @decko_gem_root ||= File.join repo_path, "decko"
71
- end
72
-
73
- def database_gem_and_version
74
- entry = database_gemfile_entry
75
- text = %("#{entry.name}")
76
- text << %(, '#{entry.version}') if entry.version
77
- # single quotes to prevent, eg: `gem "pg", ">= 0.18', '< 2.0"`
78
- text
79
- end
80
-
81
- def simplecov_config
82
- "" # TODO: add simplecov configs here
83
- end
84
-
85
- def jasmine_yml prefix
86
- inside("javascripts/support") do
87
- template "#{prefix}_jasmine.yml.erb", "jasmine.yml"
88
- end
89
- end
90
-
91
- def mysql_socket
92
- return if RbConfig::CONFIG["host_os"].match?(/mswin|mingw/)
93
-
94
- @mysql_socket ||= [
95
- "/tmp/mysql.sock", # default
96
- "/var/run/mysqld/mysqld.sock", # debian/gentoo
97
- "/var/tmp/mysql.sock", # freebsd
98
- "/var/lib/mysql/mysql.sock", # fedora
99
- "/opt/local/lib/mysql/mysql.sock", # fedora
100
- "/opt/local/var/run/mysqld/mysqld.sock", # mac + darwinports + mysql
101
- "/opt/local/var/run/mysql4/mysqld.sock", # mac + darwinports + mysql4
102
- "/opt/local/var/run/mysql5/mysqld.sock", # mac + darwinports + mysql5
103
- "/opt/lampp/var/mysql/mysql.sock" # xampp for linux
104
- ].find { |f| File.exist?(f) }
105
- end
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,120 +0,0 @@
1
- module Decko
2
- module Generators
3
- module Deck
4
- class DeckGenerator
5
- # Guides through the decko deck installation with an interactive menu
6
- # Offers the possibilitiy to
7
- # - edit database config
8
- # - edit application.rb
9
- # - seed database
10
- # - run server
11
- class Interactive
12
- def initialize destination_root, dev=false
13
- @dev = dev
14
- @destination_root = destination_root
15
- end
16
-
17
- def run
18
- require config_path("application") # need this for Rails.env
19
- @menu = ActiveSupport::OrderedHash.new
20
- add_config_options
21
- add_seed_options
22
- add_exit_option
23
- while (answer = ask(build_menu)) != "x"
24
- if @menu.key? answer
25
- @menu[answer][:code].call
26
- else
27
- puts "invalid choice"
28
- end
29
- end
30
- end
31
-
32
- private
33
-
34
- def dev_options?
35
- @dev
36
- end
37
-
38
- def config_path file
39
- File.join destination_root, "config", file
40
- end
41
-
42
- def bundle_exec command, opts={}
43
- rails_env = "RAILS_ENV=#{opts[:rails_env]}" if opts[:rails_env]
44
- system "cd #{destination_root} && #{rails_env} bundle exec #{command}"
45
- end
46
-
47
- def build_menu
48
- lines = ["What would you like to do next?"]
49
- lines += @menu.map { |key, v| build_option key, v[:desc], v[:command] }
50
- lines << "[#{@menu.keys.join}]"
51
- "\n#{lines.join("\n")}\n"
52
- end
53
-
54
- def build_option key, desc, command
55
- command &&= "#{' ' * (65 - desc.size)}[#{command}]"
56
- " #{key} - #{desc}#{command}"
57
- end
58
-
59
- def add_config_options
60
- @menu["d"] = {
61
- desc: "edit database configuration file",
62
- command: "nano config/database.yml",
63
- code: proc { system "nano #{config_path 'database.yml'}" }
64
- }
65
- @menu["c"] = {
66
- desc: "configure Decko (e.g. email settings)",
67
- command: "nano config/application.rb",
68
- code: proc { system "nano #{config_path 'application.rb'}" }
69
- }
70
- end
71
-
72
- def add_seed_options
73
- add_common_seed_option
74
- add_seed_all_option
75
- end
76
-
77
- def add_common_seed_option
78
- @menu["s"] = {
79
- desc: "seed #{Rails.env}#{' and test' if dev_options?} database",
80
- command: "decko seed",
81
- code: proc do
82
- bundle_exec "rake decko:seed"
83
- bundle_exec "rake decko:seed", rails_env: "test" if dev_options?
84
- add_after_seed_options
85
- end
86
- }
87
- end
88
-
89
- def add_seed_all_option
90
- @menu["a"] = {
91
- desc: "seed all databases (production, development, and test)",
92
- command: "decko seed --all",
93
- code: proc do
94
- %w[production development test].each do |env|
95
- bundle_exec "rake decko:seed", rails_env: env
96
- end
97
- add_after_seed_options
98
- end
99
- }
100
- end
101
-
102
- def add_exit_option
103
- @menu["x"] = {
104
- desc: "exit (run 'decko seed' to complete the installation later)"
105
- }
106
- end
107
-
108
- def add_after_seed_options
109
- @menu["x"][:desc] = "exit"
110
- @menu["r"] = {
111
- desc: "run decko server",
112
- command: "decko server",
113
- code: proc { bundle_exec "decko server" }
114
- }
115
- end
116
- end
117
- end
118
- end
119
- end
120
- end