Module: Bitbucket
- Defined in:
- lib/simple_bitbucket.rb
Constant Summary collapse
- VERBOSE =
false
Class Method Summary collapse
Class Method Details
.create_and_sync(path, name = nil) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/simple_bitbucket.rb', line 4 def create_and_sync path, name = nil name = path.split('/')[-1].sub(/\.git$/i, '') if name.nil? curl_command "/repositories", {:method => :post, :params => {:name => name} } FileUtils.chdir path `git remote add origin [email protected]:#{Username}/#{name}.git` `git push origin master` end |
.curl_command(path, opts = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/simple_bitbucket.rb', line 18 def curl_command path, opts = {} method = opts.delete(:method) || :get addition = case method.to_sym when :get when :post d = opts[:params].map {|k, v| "#{k}=#{v}" }.join("&") "-k -X POST -d #{d}" end vebose_str = VERBOSE ? '-v' : '' `curl #{addition} --user #{Email}:#{Password} https://api.bitbucket.org/1.0#{path} #{vebose_str}` end |
.list ⇒ Object
13 14 15 16 |
# File 'lib/simple_bitbucket.rb', line 13 def list str = curl_command("/user/repositories") JSON.parse(str) end |