Class: Trackler::Implementation

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/trackler/implementation.rb

Overview

Implementation is a language-specific implementation of an exercise.

Constant Summary collapse

IGNORE_PATTERNS =
[
  "\/HINTS\.md$",
  "\/\.$",
  "/\.meta/"
]

Instance Method Summary collapse

Constructor Details

#initialize(track, specification) ⇒ Implementation

Returns a new instance of Implementation.



18
19
20
21
# File 'lib/trackler/implementation.rb', line 18

def initialize(track, specification)
  @track = track
  @specification = specification
end

Instance Method Details

#exists?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/trackler/implementation.rb', line 33

def exists?
  File.exist?(implementation_dir)
end

#filesObject



37
38
39
40
41
# File 'lib/trackler/implementation.rb', line 37

def files
  @files ||= Hash[file_bundle.paths.map {|path|
    [path.relative_path_from(implementation_dir).to_s, File.read(path)]
  }].merge("README.md" => readme)
end

#git_urlObject



54
55
56
# File 'lib/trackler/implementation.rb', line 54

def git_url
  [track.repository, "tree/master", exercise_dir].join("/")
end

#initialize_copy(original) ⇒ Object



23
24
25
26
# File 'lib/trackler/implementation.rb', line 23

def initialize_copy(original)
  super
  @files = original.files.dup
end

#problemObject



28
29
30
31
# File 'lib/trackler/implementation.rb', line 28

def problem
  warn "DEPRECATION WARNING: The `problem` method is deprecated, Implementation can do everything that Problem can, so call the method directly."
  @specification
end

#readmeObject



50
51
52
# File 'lib/trackler/implementation.rb', line 50

def readme
  @readme ||= static_readme || assemble_readme
end

#track_idObject

DEPRECATED: We changed the class to hold on to a track object, however downstream dependencies send the to the track_id message.



61
62
63
# File 'lib/trackler/implementation.rb', line 61

def track_id
  track.id
end

#zipObject



43
44
45
46
47
48
# File 'lib/trackler/implementation.rb', line 43

def zip
  @zip ||= file_bundle.zip do |io|
    io.put_next_entry('README.md')
    io.print readme
  end
end