Sha256: b02b32e79cf6dfb07919def936450173ad6456eab028a4df1c0b4910f93de687

Contents?: true

Size: 989 Bytes

Versions: 205

Compression:

Stored size: 989 Bytes

Contents

module Generator
  module Files
    module GeneratorCases
      class << self
        def available(track_path)
          cases_filepaths(track_path).map { |filepath| slugify(filepath) }.sort
        end

        def source_filepath(track_path, slug)
          path = meta_generator_path(track_path, slug)
          filename = filename(slug) + '.rb'
          File.join(path, filename)
        end

        private

        def cases_filepaths(track_path)
          generator_glob = File.join(meta_generator_path(track_path, '*'), '*_case.rb')
          Dir.glob(generator_glob, File::FNM_DOTMATCH)
        end

        def slugify(filepath)
          File.basename(filepath, '_case.rb').tr('_', '-')
        end

        def filename(exercise_name_or_slug)
          "#{exercise_name_or_slug.tr('-', '_')}_case"
        end

        def meta_generator_path(track_path, slug)
          File.join(track_path, 'exercises', slug, '.meta', 'generator')
        end
      end
    end
  end
end

Version data entries

205 entries across 205 versions & 1 rubygems

Version Path
trackler-2.2.1.98 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.97 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.96 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.95 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.94 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.93 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.92 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.91 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.90 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.89 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.88 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.87 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.86 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.85 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.84 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.83 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.82 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.81 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.80 tracks/ruby/lib/generator/files/generator_cases.rb
trackler-2.2.1.79 tracks/ruby/lib/generator/files/generator_cases.rb