Class: Curldown::GitHub

Inherits:
Object
  • Object
show all
Includes:
Curldown
Defined in:
lib/curldown.rb

Constant Summary collapse

CORE_URL =
"https://raw.githubusercontent.com"

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Curldown

#get, render

Constructor Details

#initialize(u, r) ⇒ GitHub

Returns a new instance of GitHub.



76
77
78
79
# File 'lib/curldown.rb', line 76

def initialize(u, r)
  @user= u
  @repo_name= r
end

Instance Attribute Details

#readme_mdObject

Returns the value of attribute readme_md.



75
76
77
# File 'lib/curldown.rb', line 75

def readme_md
  @readme_md
end

#repo_nameObject

Returns the value of attribute repo_name.



75
76
77
# File 'lib/curldown.rb', line 75

def repo_name
  @repo_name
end

#userObject

Returns the value of attribute user.



75
76
77
# File 'lib/curldown.rb', line 75

def user
  @user
end

Instance Method Details

#get_readmeObject



83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/curldown.rb', line 83

def get_readme
  ["readme.md", "README.md", "README.MD", "Readme.md"].each{|file|
    begin
      @readme_md= get("#{CORE_URL}/#{@user}/#{@repo_name}/master/#{file}", json: false)
    rescue
      false
    end
  }
  if !@readme_md
    raise StandardError.new("No readme file found.")
  else
    @readme_md
  end
end

#performObject



80
81
82
# File 'lib/curldown.rb', line 80

def perform
  get_readme
end