Sha256: 74112c38dcaecd841447693183b9439d081c81a245b586113c80b72c6399958f
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 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.open tests_path, 'w' do |f| f.write tests end 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
exercism-0.0.9 | lib/exercism/assignment.rb |
exercism-0.0.8 | lib/exercism/assignment.rb |
exercism-0.0.7 | lib/exercism/assignment.rb |