tracks/ruby/lib/tasks/exercise.rb in trackler-2.1.0.11 vs tracks/ruby/lib/tasks/exercise.rb in trackler-2.1.0.12

- old
+ new

@@ -1,50 +1,42 @@ class Exercise class << self def all - exercise_names.map { |e| new(e) } + slugs.map { |e| new(e) } end private - def exercise_names + def slugs FileList['exercises/*'].pathmap('%f').exclude('TRACK_HINTS.md') end end - attr_reader :name - alias :to_s :name + attr_reader :slug + alias :to_s :slug - def initialize(name) - @name = name + def initialize(slug) + @slug = slug end def directory - "exercises/#{name}/." + "exercises/#{slug}/." end def example_file - File.exist?(File.join(directory, example_filename)) ? example_filename : legacy_example_filename + File.join('.meta', 'solutions', "#{exercise_name}.rb") end def testable_example_file - "#{base_file_name}.rb" + "#{exercise_name}.rb" end def test_file - "#{base_file_name}_test.rb" + "#{exercise_name}_test.rb" end private - def example_filename - File.join('.meta', 'solutions', "#{name}.rb") - end - - def legacy_example_filename - 'example.rb' - end - - def base_file_name - @_base_file_name ||= name.tr('-', '_') + def exercise_name + @exercise_name ||= slug.tr('-', '_') end end