Class: Rdm::Handlers::DiffPackageHandler
- Inherits:
-
Object
- Object
- Rdm::Handlers::DiffPackageHandler
- Defined in:
- lib/rdm/handlers/diff_package_handler.rb
Instance Attribute Summary collapse
-
#all_packages ⇒ Object
readonly
Returns the value of attribute all_packages.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
Class Method Summary collapse
Instance Method Summary collapse
- #handle ⇒ Object
-
#initialize(path:, revision:) ⇒ DiffPackageHandler
constructor
A new instance of DiffPackageHandler.
Constructor Details
#initialize(path:, revision:) ⇒ DiffPackageHandler
Returns a new instance of DiffPackageHandler.
11 12 13 14 15 16 17 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 11 def initialize(path:, revision:) @path = path @revision = revision source_path = Rdm::SourceLocator.locate(path) @all_packages = Rdm::SourceParser.read_and_init_source(source_path).packages.values end |
Instance Attribute Details
#all_packages ⇒ Object (readonly)
Returns the value of attribute all_packages.
10 11 12 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 10 def all_packages @all_packages end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
10 11 12 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 10 def path @path end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
10 11 12 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 10 def revision @revision end |
Class Method Details
.handle(path:, revision: 'HEAD') ⇒ Object
5 6 7 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 5 def handle(path:, revision: 'HEAD') return Rdm::Handlers::DiffPackageHandler.new(path: path, revision: revision).handle end |
Instance Method Details
#handle ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rdm/handlers/diff_package_handler.rb', line 19 def handle @revision = 'HEAD' if @revision.nil? || @revision.empty? modified_packages = Rdm::Git::DiffManager .run(path: path, revision: revision) .reject { |file| file.include?(Rdm::Gen::Init::LOCAL_TEMPLATES_PATH) } .map { |file| Rdm::Packages::Locator.locate(file) rescue nil } .map { |path_to_package| Rdm::PackageParser.parse_file(path_to_package).name rescue nil } .reject(&:blank?) .uniq return get_dependencies(modified_packages) || [] end |