class Curldown::BitBucket
Constants
- CORE_URL
Attributes
commit[RW]
readme_file[RW]
readme_md[RW]
repo_name[RW]
repo_object[RW]
tree[RW]
user[RW]
Public Class Methods
new(u, r)
click to toggle source
# File lib/curldown.rb, line 103 def initialize(u, r) @user= u @repo_name= r end
Public Instance Methods
get_last_commit()
click to toggle source
# File lib/curldown.rb, line 119 def get_last_commit commits_url = repo_object['links']['commits']['href'] commits = get(commits_url) @commit= commits['values'][0]['hash'] end
get_readme_file()
click to toggle source
# File lib/curldown.rb, line 127 def get_readme_file tree['values'].each{|v| if v['path'].match?(/readme.md/i) @readme_file= v['path'] end } if !readme_file raise RuntimeError.new("No readme file in repository") end end
get_readme_md()
click to toggle source
# File lib/curldown.rb, line 137 def get_readme_md @readme_md= get("https://bitbucket.org/#{@user}/#{@repo_name}/raw/#{@commit}/#{@readme_file}", json: false) end
get_repo()
click to toggle source
# File lib/curldown.rb, line 114 def get_repo @repo_object= get("#{CORE_URL}/repositories/#{@user}/#{@repo_name}") @repo_name= repo_object['name'] @repo_slug= repo_object['slug'] end
get_tree_object()
click to toggle source
# File lib/curldown.rb, line 124 def get_tree_object @tree= get("#{CORE_URL}/repositories/#{@user}/#{@repo_slug}/src/#{@commit}/") end
perform()
click to toggle source
# File lib/curldown.rb, line 107 def perform get_repo get_last_commit get_tree_object get_readme_file get_readme_md end