Sha256: 7bc535d596f99cf5f574c08b4867d6c5d8dbad5114516a58d341a814e54f65b8
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
class Exercism class Assignment def self.save(data, path) assignments = [] data['assignments'].each do |attributes| assignments << Assignment.new(attributes.merge('project_dir' => path)).save end assignments end attr_reader :track, :slug, :readme, :test_file, :tests, :project_dir def initialize(attributes) @track = attributes['track'] @slug = attributes['slug'] @readme = attributes['readme'] @test_file = attributes['test_file'] @tests = attributes['tests'] @project_dir = attributes['project_dir'] end def save FileUtils.mkdir_p assignment_dir File.open readme_path, 'w' do |f| f.write readme end File.write tests_path, tests self end def assignment_dir @assignment_dir ||= File.join(project_dir, track, slug) end private def readme_path File.join(assignment_dir, 'README.md') end def tests_path File.join(assignment_dir, test_file) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
exercism-0.0.6 | lib/exercism/assignment.rb |
exercism-0.0.5 | lib/exercism/assignment.rb |