Class: Bosh::Gen::Generators::ExtractPackageGenerator
- Includes:
- Thor::Actions
- Defined in:
- lib/bosh/gen/generators/extract_package_generator.rb
Instance Method Summary collapse
- #check_package_path_is_a_package ⇒ Object
- #check_package_path_within_release ⇒ Object
- #check_root_is_release ⇒ Object
- #copy_dependent_packages ⇒ Object
- #copy_package_spec_files ⇒ Object
-
#detect_dependent_packages ⇒ Object
Extract target package and all its dependencies.
- #readme ⇒ Object
- #using_source_release_for_templates ⇒ Object
Instance Method Details
#check_package_path_is_a_package ⇒ Object
25 26 27 28 29 30 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 25 def check_package_path_is_a_package parent_dir = File.basename(File.dirname(source_package_path)) unless parent_dir == "packages" raise Thor::Error.new("source package path is not a BOSH package") end end |
#check_package_path_within_release ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 17 def check_package_path_within_release FileUtils.chdir(source_release_path) do unless File.exist?("jobs") && File.exist?("packages") raise Thor::Error.new("source package path is not within a BOSH release project") end end end |
#check_root_is_release ⇒ Object
11 12 13 14 15 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 11 def check_root_is_release unless File.exist?("jobs") && File.exist?("packages") raise Thor::Error.new("run inside a BOSH release project") end end |
#copy_dependent_packages ⇒ Object
43 44 45 46 47 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 43 def copy_dependent_packages @packages.each do |package| directory "packages/#{package}", mode: :preserve end end |
#copy_package_spec_files ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 49 def copy_package_spec_files @blobs = false @packages.each do |package| spec = source_file("packages", package, "spec") file_globs = YAML.load_file(spec)["files"] file_globs.each do |file_glob| source_files = Dir.glob(File.join(source_release_path, "src", file_glob)) source_files.each do |source_path| target_path = source_path.scan(%r{/src/(.*)}).flatten.first copy_file(File.join("src", target_path)) end end file_globs.each do |file_glob| source_files = Dir.glob(File.join(source_release_path, "blobs", file_glob)) source_files.each do |source_path| target_path = source_path.scan(%r{/blobs/(.*)}).flatten.first BoshCli.run "add-blob #{source_path} #{target_path}" say_status "add-blob", target_path @blobs = true end end end end |
#detect_dependent_packages ⇒ Object
Extract target package and all its dependencies
37 38 39 40 41 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 37 def detect_dependent_packages spec = YAML.load_file(source_package_dir("spec")) @packages = [source_package_name] @packages << spec["packages"] if spec["packages"] end |
#readme ⇒ Object
75 76 77 78 79 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 75 def readme if @blobs say_status "readme", "Upload blobs with 'bosh upload-blobs'" end end |
#using_source_release_for_templates ⇒ Object
32 33 34 |
# File 'lib/bosh/gen/generators/extract_package_generator.rb', line 32 def using_source_release_for_templates source_paths << File.join(source_release_path) end |