class FeduxOrgStdlib::FixturesManagement::FixturesManager

Fixture manager

Attributes

creator[R]
fixtures[R]
null_klass[R]

Public Class Methods

new(creator: Fixture, null_klass: NoFixture) click to toggle source
# File lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb, line 12
def initialize(creator: Fixture, null_klass: NoFixture)
  @fixtures   = Set.new
  @creator    = creator
  @null_klass = null_klass
end

Public Instance Methods

add(path) click to toggle source

Add fixture

# File lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb, line 30
def add(path)
  fixtures << creator.new(path)
end
find(name) click to toggle source

Find fixture

# File lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb, line 35
def find(name)
  name = name.to_sym

  fixtures.find(null_klass.new(name)) { |f| f.name == name }
end
load_fixtures(path) click to toggle source

Load fixtures found at path

# File lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb, line 19
def load_fixtures(path)
  path = Pathname.new(path)

  path.entries.each do |f|
    next if f.to_s[/^\.\.?/]

    add f.expand_path(path)
  end
end
to_s() click to toggle source

String representation

# File lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb, line 42
def to_s
  data = frontend_components.sort.reduce([]) { |a, e| a << { name: e.name, path: e.path } }
  List.new(data).to_s
end