Class: Ibex::Impact::Seeds
- Inherits:
-
Object
- Object
- Ibex::Impact::Seeds
- Defined in:
- lib/ibex/impact/seeds.rb
Overview
Converts command-line symbols and Diff rule ids into analysis seeds.
Instance Attribute Summary collapse
- #ids ⇒ Object readonly
-
#records ⇒ Object
readonly
: Array[Hash[Symbol, Object?]].
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(grammar, names, origin: "symbol") ⇒ Seeds
constructor
A new instance of Seeds.
Constructor Details
#initialize(grammar, names, origin: "symbol") ⇒ Seeds
Returns a new instance of Seeds.
16 17 18 19 20 21 22 23 |
# File 'lib/ibex/impact/seeds.rb', line 16 def initialize(grammar, names, origin: "symbol") @grammar = grammar @sets = Analysis::Sets.new(grammar) @records = names.flat_map { |name| resolve(name, origin) }.sort_by { |record| seed_symbol(record) } @ids = @records.map { |record| seed_id(record) }.uniq.freeze @records = @records.freeze freeze end |
Instance Attribute Details
#ids ⇒ Object (readonly)
12 13 14 |
# File 'lib/ibex/impact/seeds.rb', line 12 def ids @ids end |
#records ⇒ Object (readonly)
: Array[Hash[Symbol, Object?]]
13 14 15 |
# File 'lib/ibex/impact/seeds.rb', line 13 def records @records end |
Class Method Details
.from_diff(grammar, diff, origin: "diff") ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/ibex/impact/seeds.rb', line 26 def self.from_diff(grammar, diff, origin: "diff") rules = diff.fetch(:rules) #: Hash[Symbol, Object?] names = %i[added removed changed].flat_map do |section| records = rules.fetch(section) #: Array[Hash[Symbol, Object?]] records.map { |record| record.fetch(:id).to_s } end.uniq.sort new(grammar, names, origin: origin) end |