Class: Cardio::Application::Paths
- Inherits:
-
Object
- Object
- Cardio::Application::Paths
- Defined in:
- lib/cardio/application.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#paths ⇒ Object
readonly
Returns the value of attribute paths.
Instance Method Summary collapse
- #add_db_paths ⇒ Object
- #add_gem_environment_path ⇒ Object
- #add_initializer_paths ⇒ Object
- #add_initializers(base_dir, mod = false, init_dir = "initializers") ⇒ Object
- #add_mod_initializer_paths ⇒ Object
- #add_path(path, options = {}) ⇒ Object
- #add_tmppaths ⇒ Object
- #assign ⇒ Object
-
#initialize(config) ⇒ Paths
constructor
A new instance of Paths.
- #tmppath_opts(dir) ⇒ Object
Constructor Details
#initialize(config) ⇒ Paths
Returns a new instance of Paths.
61 62 63 64 |
# File 'lib/cardio/application.rb', line 61 def initialize config @config = config @paths = config.paths end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
59 60 61 |
# File 'lib/cardio/application.rb', line 59 def config @config end |
#paths ⇒ Object (readonly)
Returns the value of attribute paths.
59 60 61 |
# File 'lib/cardio/application.rb', line 59 def paths @paths end |
Instance Method Details
#add_db_paths ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/cardio/application.rb', line 97 def add_db_paths add_path "db" add_path "db/migrate" add_path "db/migrate_core_cards" add_path "db/migrate_deck", root: config.root, with: "db/migrate" add_path "db/migrate_deck_cards", root: config.root, with: "db/migrate_cards" add_path "db/seeds.rb", with: "db/seeds.rb" end |
#add_gem_environment_path ⇒ Object
128 129 130 131 132 |
# File 'lib/cardio/application.rb', line 128 def add_gem_environment_path add_path "card/config/environments", glob: "#{Rails.env}.rb", with: "config/environments" end |
#add_initializer_paths ⇒ Object
106 107 108 109 110 111 112 |
# File 'lib/cardio/application.rb', line 106 def add_initializer_paths add_path "config/initializers", glob: "**/*.rb" add_initializers config.root Cardio::Mod.each_path do |mod_path| add_initializers mod_path, false, "core_initializers" end end |
#add_initializers(base_dir, mod = false, init_dir = "initializers") ⇒ Object
121 122 123 124 125 126 |
# File 'lib/cardio/application.rb', line 121 def add_initializers base_dir, mod=false, init_dir="initializers" Dir.glob("#{base_dir}/config/#{init_dir}").each do |initializers_dir| path_mark = mod ? "mod/config/initializers" : "config/initializers" paths[path_mark] << initializers_dir end end |
#add_mod_initializer_paths ⇒ Object
114 115 116 117 118 119 |
# File 'lib/cardio/application.rb', line 114 def add_mod_initializer_paths add_path "mod/config/initializers", glob: "**/*.rb" Cardio::Mod.each_path do |mod_path| add_initializers mod_path, true end end |
#add_path(path, options = {}) ⇒ Object
134 135 136 137 138 |
# File 'lib/cardio/application.rb', line 134 def add_path path, ={} root = .delete(:root) || Cardio.gem_root [:with] = File.join(root, ([:with] || path)) paths.add path, end |
#add_tmppaths ⇒ Object
82 83 84 85 86 87 |
# File 'lib/cardio/application.rb', line 82 def add_tmppaths %w[set set_pattern].each do |dir| opts = tmppath_opts dir add_path "tmp/#{dir}", opts if opts end end |
#assign ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/cardio/application.rb', line 66 def assign add_tmppaths add_path "mod" # add card gem's mod path paths["mod"] << "mod" # add deck's mod path paths.add "files" add_db_paths add_initializer_paths add_mod_initializer_paths add_gem_environment_path paths["app/models"] = [] paths["app/mailers"] = [] paths["app/controllers"] = [] end |
#tmppath_opts(dir) ⇒ Object
89 90 91 92 93 94 95 |
# File 'lib/cardio/application.rb', line 89 def tmppath_opts dir if ENV["REPO_TMPSETS"] { with: "tmpsets/#{dir}" } elsif ENV["TMPSETS"] { root: config.root } end end |