Sha256: 993b0763bf497a96d1b1439d73f8ab1d8d697f6329b84a88adad811de08e80a3

Contents?: true

Size: 1.42 KB

Versions: 6

Compression:

Stored size: 1.42 KB

Contents

module LearnWeb
  class Client
    module ValidateRepo
      class Slug
        attr_accessor :data, :repo_slug, :lab, :lesson_id, :later_lesson,
                      :repo_name, :dot_learn
        attr_reader   :response

        include AttributePopulatable

        def initialize(response)
          @response = response

          parse!
        end

        private

        def parse!
          case response.status
          when 200
            self.data = Oj.load(response.body, symbol_keys: true)
            populate_attributes!
          when 401
            puts "It seems your OAuth token is incorrect. Please re-run config with: learn reset"
            exit
          when 422
            begin
              self.data = Oj.load(response.body, symbol_keys: true)
              if data[:message].match(/Cannot find lesson/)
                puts "Hmm...#{data[:message]}. Please check your input and try again."
                exit
              else
                puts "Sorry, something went wrong. Please try again."
                exit
              end
            rescue
              puts "Sorry, something went wrong. Please try again."
              exit
            end
          when 500
            puts "Sorry, something went wrong. Please try again."
            exit
          else
            puts "Sorry, something went wrong. Please try again."
            exit
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
learn-web-1.5.5 lib/learn_web/client/validate_repo/slug.rb
learn-web-1.5.4 lib/learn_web/client/validate_repo/slug.rb
learn-web-1.5.3 lib/learn_web/client/validate_repo/slug.rb
learn-web-1.5.2 lib/learn_web/client/validate_repo/slug.rb
learn-web-1.5.1 lib/learn_web/client/validate_repo/slug.rb
learn-web-1.5.0 lib/learn_web/client/validate_repo/slug.rb