Sha256: cf34f1ad307bd860a11e49d2a7ad1cb979cdd833cc0929df55d83ba90178d348

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

module LearnOpen
  module Lessons
    class BaseLesson
      attr_reader :repo_path,
                  :organization,
                  :name,
                  :id,
                  :dot_learn,
                  :git_server,
                  :later_lesson,
                  :use_student_fork,
                  :options,
                  :io,
                  :system_adapter,
                  :platform,
                  :environment_vars,
                  :logger,
                  :location

      def initialize(lesson_data, options = {})
        lesson = lesson_data[:lesson]

        @repo_path = lesson.clone_repo
        @organization, @name = repo_path.split('/')

        @git_server = lesson.git_server
        @dot_learn = lesson.dot_learn
        @is_lab = lesson.lab
        @use_student_fork = lesson.use_student_fork
        @later_lesson = lesson_data[:later_lesson]
        @id = lesson_data[:id]

        @logger = options.fetch(:logger, LearnOpen.logger)
        @io = options.fetch(:io, LearnOpen.default_io)
        @system_adapter = options.fetch(:system_adapter, LearnOpen.system_adapter)
        @platform = options.fetch(:platform, LearnOpen.platform)
        @environment_vars = options.fetch(:environment_vars, LearnOpen.environment_vars)
        @location = options.fetch(:lessons_directory) {LearnOpen.lessons_directory}
        @options = options
      end

      def lab?
        @is_lab
      end

      def readme?
        !lab?
      end

      def to_path
        "#{location}/#{name}"
      end

      def to_url
        "https://learn.co/lessons/#{id}"
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
learn-open-1.2.28 lib/learn_open/lessons/base_lesson.rb
learn-open-1.2.27 lib/learn_open/lessons/base_lesson.rb
learn-open-1.2.26 lib/learn_open/lessons/base_lesson.rb
learn-open-1.2.24 lib/learn_open/lessons/base_lesson.rb
learn-open-1.2.23 lib/learn_open/lessons/base_lesson.rb