Sha256: 0930825fda1d07313b8d3096b3503017a7d1a4f8ea8eea35e3854bf4949bd672

Contents?: true

Size: 1 KB

Versions: 58

Compression:

Stored size: 1 KB

Contents

# encoding: utf-8
module FeduxOrgStdlib
  module FixturesManagement
    # Fixture manager
    class FixturesManager
      private

      attr_reader :fixtures, :creator, :null_klass

      public

      def initialize(creator: Fixture, null_klass: NoFixture)
        @fixtures   = Set.new
        @creator    = creator
        @null_klass = null_klass
      end

      # Load fixtures found at path
      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

      # Add fixture
      def add(path)
        fixtures << creator.new(path)
      end

      # Find fixture
      def find(name)
        name = name.to_sym

        fixtures.find(null_klass.new(name)) { |f| f.name == name }
      end

      # String representation
      def to_s
        data = frontend_components.sort.reduce([]) { |a, e| a << { name: e.name, path: e.path } }
        List.new(data).to_s
      end
    end
  end
end

Version data entries

58 entries across 58 versions & 1 rubygems

Version Path
fedux_org-stdlib-0.11.18 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.17 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.16 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.15 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.14 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.12 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.11 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.9 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.8 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.7 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.6 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.5 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.4 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.3 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.2 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.1 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.11.0 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.10.9 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.10.8 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb
fedux_org-stdlib-0.10.7 lib/fedux_org_stdlib/fixtures_management/fixtures_manager.rb