Class: Lono::Blueprint::Find
- Inherits:
-
Object
- Object
- Lono::Blueprint::Find
- Extended by:
- Memoist
- Defined in:
- lib/lono/blueprint/find.rb
Class Method Summary collapse
-
.all_blueprints ⇒ Object
Returns both project and gem blueprints.
-
.all_project_blueprint_infos ⇒ Object
Returns: Array of Blueprint::Info.
- .bundler_version_check! ⇒ Object
- .dot_meta_path(source) ⇒ Object
-
.find(blueprint) ⇒ Object
Returns blueprint root full path.
- .one_or_all(blueprint) ⇒ Object
-
.specs ⇒ Object
Only the blueprint specs.
Class Method Details
.all_blueprints ⇒ Object
Returns both project and gem blueprints
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/lono/blueprint/find.rb', line 13 def all_blueprints project_blueprints = all_project_blueprint_infos.map { |info| info.name } gem_blueprints = specs.map do |spec| dot_lono = (spec) config = YAML.load_file(dot_lono) config["blueprint_name"] end all = project_blueprints + gem_blueprints all.uniq end |
.all_project_blueprint_infos ⇒ Object
Returns: Array of Blueprint::Info. Example:
[#<Lono::Blueprint::Info:0x0000561e620e0548
@name="ecs-spot-fleet",
@path="/full/path/to/blueprint/ecs-spot-demo">,
#<Lono::Blueprint::Info:0x0000561e61e132c0
@name="ec2",
@path="/full/path/to/blueprint/ec2">]
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/lono/blueprint/find.rb', line 53 def all_project_blueprint_infos infos = [] Dir.glob("#{Lono.root}/blueprints/*").select do |p| dot_lono = (p) next unless File.exist?(dot_lono) config = YAML.load_file(dot_lono) infos << Info.new(config["blueprint_name"], p) end infos end |
.bundler_version_check! ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/lono/blueprint/find.rb', line 81 def bundler_version_check! return unless Bundler.bundler_major_version >= 1 # LockfileParser only works for Bundler version 2+ puts "ERROR: The bundler version detected is too old. Please use bundler 2+".color(:red) puts "Current detected bundler version is #{Bundler.bundler_major_version}" exit 1 end |
.dot_meta_path(source) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/lono/blueprint/find.rb', line 73 def (source) if source.is_a?(String) # path to folder "#{source}/.meta/config.yml" else # spec "#{source.full_gem_path}/.meta/config.yml" end end |
.find(blueprint) ⇒ Object
Returns blueprint root full path. Can be:
1. projects blueprints/BLUEPRINT - higher precedence
2. full gem path
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/lono/blueprint/find.rb', line 31 def find(blueprint) # Check projects blueprints info = all_project_blueprint_infos.find { |info| info.name == blueprint} return info.path if info # Check gem specs result = specs.find do |spec| dot_lono = (spec) config = YAML.load_file(dot_lono) config["blueprint_name"] == blueprint end result.full_gem_path if result end |
.one_or_all(blueprint) ⇒ Object
8 9 10 |
# File 'lib/lono/blueprint/find.rb', line 8 def one_or_all(blueprint) blueprint ? [blueprint] : all_blueprints end |
.specs ⇒ Object
Only the blueprint specs
65 66 67 68 69 70 |
# File 'lib/lono/blueprint/find.rb', line 65 def specs specs = Bundler.load.specs specs.select do |spec| File.exist?((spec)) end end |