Module: Cardio::Modfiles
- Included in:
- Cardio
- Defined in:
- lib/cardio/modfiles.rb
Overview
methods for handling simple and gem mod paths/files
Instance Method Summary collapse
- #each_gem_mod_path ⇒ Object
- #each_mod_path(&block) ⇒ Object
- #each_simple_mod_path ⇒ Object
- #gem_mod_spec?(spec) ⇒ True/False
-
#gem_mod_specs ⇒ Hash
In the form{ modname(String) => Gem::Specification }.
- #mod_migration_paths(dir) ⇒ Object
Instance Method Details
#each_gem_mod_path ⇒ Object
31 32 33 34 35 |
# File 'lib/cardio/modfiles.rb', line 31 def each_gem_mod_path gem_mod_specs.each_value do |spec| yield spec.full_gem_path end end |
#each_mod_path(&block) ⇒ Object
18 19 20 21 |
# File 'lib/cardio/modfiles.rb', line 18 def each_mod_path &block each_simple_mod_path(&block) each_gem_mod_path(&block) end |
#each_simple_mod_path ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/cardio/modfiles.rb', line 23 def each_simple_mod_path paths["mod"].each do |mods_path| Dir.glob("#{mods_path}/*").each do |single_mod_path| yield single_mod_path end end end |
#gem_mod_spec?(spec) ⇒ True/False
12 13 14 15 16 |
# File 'lib/cardio/modfiles.rb', line 12 def gem_mod_spec? spec return unless spec spec.name.match?(/^card-mod-/) || spec.["card-mod"].present? end |
#gem_mod_specs ⇒ Hash
Returns in the form{ modname(String) => Gem::Specification }.
5 6 7 8 9 |
# File 'lib/cardio/modfiles.rb', line 5 def gem_mod_specs Bundler.definition.specs.each_with_object({}) do |gem_spec, h| h[gem_spec.name] = gem_spec if gem_mod_spec? gem_spec end end |