Class: Curldown::BitBucket
Constant Summary collapse
- CORE_URL =
"https://api.bitbucket.org/2.0"
Instance Attribute Summary collapse
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#readme_file ⇒ Object
Returns the value of attribute readme_file.
-
#readme_md ⇒ Object
Returns the value of attribute readme_md.
-
#repo_name ⇒ Object
Returns the value of attribute repo_name.
-
#repo_object ⇒ Object
Returns the value of attribute repo_object.
-
#tree ⇒ Object
Returns the value of attribute tree.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
- #get_last_commit ⇒ Object
- #get_readme_file ⇒ Object
- #get_readme_md ⇒ Object
- #get_repo ⇒ Object
- #get_tree_object ⇒ Object
-
#initialize(u, r) ⇒ BitBucket
constructor
A new instance of BitBucket.
- #perform ⇒ Object
Methods included from Curldown
Constructor Details
#initialize(u, r) ⇒ BitBucket
Returns a new instance of BitBucket.
103 104 105 106 |
# File 'lib/curldown.rb', line 103 def initialize(u, r) @user= u @repo_name= r end |
Instance Attribute Details
#commit ⇒ Object
Returns the value of attribute commit.
102 103 104 |
# File 'lib/curldown.rb', line 102 def commit @commit end |
#readme_file ⇒ Object
Returns the value of attribute readme_file.
102 103 104 |
# File 'lib/curldown.rb', line 102 def readme_file @readme_file end |
#readme_md ⇒ Object
Returns the value of attribute readme_md.
102 103 104 |
# File 'lib/curldown.rb', line 102 def readme_md @readme_md end |
#repo_name ⇒ Object
Returns the value of attribute repo_name.
102 103 104 |
# File 'lib/curldown.rb', line 102 def repo_name @repo_name end |
#repo_object ⇒ Object
Returns the value of attribute repo_object.
102 103 104 |
# File 'lib/curldown.rb', line 102 def repo_object @repo_object end |
#tree ⇒ Object
Returns the value of attribute tree.
102 103 104 |
# File 'lib/curldown.rb', line 102 def tree @tree end |
#user ⇒ Object
Returns the value of attribute user.
102 103 104 |
# File 'lib/curldown.rb', line 102 def user @user end |
Instance Method Details
#get_last_commit ⇒ Object
119 120 121 122 123 |
# 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 ⇒ Object
127 128 129 130 131 132 133 134 135 136 |
# 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 ⇒ Object
137 138 139 |
# 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 ⇒ Object
114 115 116 117 118 |
# 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 ⇒ Object
124 125 126 |
# File 'lib/curldown.rb', line 124 def get_tree_object @tree= get("#{CORE_URL}/repositories/#{@user}/#{@repo_slug}/src/#{@commit}/") end |
#perform ⇒ Object
107 108 109 110 111 112 113 |
# File 'lib/curldown.rb', line 107 def perform get_repo get_last_commit get_tree_object get_readme_file get_readme_md end |