module Cardio::Generators::DeckHelper

Protected helper methods for DeckGenerator. Many methods are called from .erb files.

Protected Instance Methods

database_gem_and_version() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 62
def database_gem_and_version
  entry = database_gemfile_entry
  text = %("#{entry.name}")
  text << %(, '#{entry.version}') if entry.version
  # single quotes to prevent, eg: `gem "pg", ">= 0.18', '< 2.0"`
  text
end
determine_repo_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 32
def determine_repo_path
  @repo_path_determined ? (return nil) : (@repo_path_determined = true)
  path = options["repo-path"]
  path = ENV["DECKO_REPO_PATH"] if path.blank?
  path = prompt_for_repo_path if path.blank? && platypus?
  path.to_s
end
erb_template(name) click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 20
def erb_template name
  template "#{name}.erb", name
end
expanded_repo_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 28
def expanded_repo_path
  @expanded_repo_path ||= File.expand_path repo_path
end
features_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 57
def features_path
  @features_path ||=
    platypus? ? File.expand_path("#{repo_path}/decko/features/") : "mod/"
end
jasmine_yml(prefix) click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 70
def jasmine_yml prefix
  inside("javascripts/support") do
    template "#{prefix}_jasmine.yml.erb", "jasmine.yml"
  end
end
monkey?() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 12
def monkey?
  options[:monkey]
end
mysql_socket() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 76
def mysql_socket
  return if RbConfig::CONFIG["host_os"].match?(/mswin|mingw/)

  @mysql_socket ||= [
    "/tmp/mysql.sock",                        # default
    "/var/run/mysqld/mysqld.sock",            # debian/gentoo
    "/var/tmp/mysql.sock",                    # freebsd
    "/var/lib/mysql/mysql.sock",              # fedora
    "/opt/local/lib/mysql/mysql.sock",        # fedora
    "/opt/local/var/run/mysqld/mysqld.sock",  # mac + darwinports + mysql
    "/opt/local/var/run/mysql4/mysqld.sock",  # mac + darwinports + mysql4
    "/opt/local/var/run/mysql5/mysqld.sock",  # mac + darwinports + mysql5
    "/opt/lampp/var/mysql/mysql.sock"         # xampp for linux
  ].find { |f| File.exist?(f) }
end
platypus?() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 16
def platypus?
  options[:platypus]
end
prompt_for_repo_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 44
def prompt_for_repo_path
  @repo_path = ask "Enter the path to your local decko repository: "
end
repo_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 24
def repo_path
  @repo_path ||= determine_repo_path
end
repo_path_constraint(subdir=nil) click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 40
def repo_path_constraint subdir=nil
  repo_path.present? ? %(, path: "#{repo_path}/#{subdir}") : ""
end
shark?() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 8
def shark?
  !(monkey? || platypus?)
end
spec_helper_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 52
def spec_helper_path
  @spec_helper_path ||=
    platypus? ? "#{repo_path}/card/spec/spec_helper" : "./spec/spec_helper"
end
spec_path() click to toggle source
# File lib/cardio/generators/deck_helper.rb, line 48
def spec_path
  @spec_path ||= platypus? ? repo_path : "mod/"
end