bucket-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 40c5f1a4499778d641fb6a1b843721593567ad5a
4
+ data.tar.gz: 42a542e11a64d789a7822870bc56534f6b3ceab0
5
+ SHA512:
6
+ metadata.gz: 4e4205cf5d982a68596797778235cf000bdc7013c197b7eaebbc5255cadcc2dc3c1528e12cd198a484d263468330a27bc95218b0cbb07dcf727c3418fb077eeb
7
+ data.tar.gz: 2fc5dc71f444b063efb848912f3ef2792308ef0ce9fa2f1a76205f9dc73881d48b642d94e41ed7b4f8612cc889aa226453c23aa13cebb802d566c7e7f617a39a
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bucket.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Roberto Poo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Bucket
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bucket'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bucket
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "rake/testtask"
2
+ require "bundler/gem_tasks"
3
+
4
+ task :default => :spec
5
+
6
+ Rake::TestTask.new(:spec) do |t|
7
+ t.test_files = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ desc "Console"
11
+ task :console do
12
+ exec 'pry -r./lib/bucket'
13
+ end
data/bin/bucket ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
3
+
4
+ require "bucket/cli"
5
+
6
+ Bucket::CLI.start
data/bucket.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bucket/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bucket-cli"
8
+ spec.version = Bucket::VERSION
9
+ spec.authors = ["Roberto Poo"]
10
+ spec.email = ["xaro@poo.cl"]
11
+ spec.description = %q{CLI for BitBucket}
12
+ spec.summary = %q{Easily clone and create repositories in BitBucket from the command line.
13
+ Init and link the local repository with a new BitBucket one in one command.}
14
+ spec.homepage = "https://github.com/xaro/bucket"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_dependency "omniauth"
23
+ spec.add_dependency "thor"
24
+ spec.add_dependency "bitbucket_rest_api"
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.3"
27
+ spec.add_development_dependency "rake"
28
+ spec.add_development_dependency "pry"
29
+ end
data/lib/bucket/cli.rb ADDED
@@ -0,0 +1,75 @@
1
+ require "thor"
2
+ require "io/console"
3
+ require "yaml"
4
+ require_relative "../bucket"
5
+
6
+ module Bucket
7
+ class CLI < Thor
8
+ def initialize(*args)
9
+ super
10
+
11
+ @client = Bucket::Client.new load_config
12
+ end
13
+
14
+ desc "setup", "Setup your BitBucket credentials"
15
+ def setup
16
+ generate_config
17
+
18
+ say("Configuration saved to ~/.bucket")
19
+ end
20
+
21
+ desc "repos", "List your own repositories."
22
+ def repos
23
+ @client.repos_list.each do |repo|
24
+ say(@client.repo_full_name(repo))
25
+ end
26
+ end
27
+
28
+ desc "clone [USER] [NAME]", "Clone repository USER/NAME from bitbucket."
29
+ def clone(user, name)
30
+ `git clone #{@client.repo_url(user, name)}`
31
+ end
32
+
33
+ desc "init [directory]", "Create a new repository locally and on BitBucket."
34
+ option :name
35
+ option :description
36
+ option :public, type: :boolean, default: false
37
+ def init(directory)
38
+ expanded_dir = File.expand_path(directory)
39
+ `git init #{expanded_dir}`
40
+
41
+ repo = @client.create_repo(options[:name] || File.basename(expanded_dir), options)
42
+ `git remote add origin #{@client.repo_url(repo[:owner], repo[:slug])}`
43
+
44
+ say("Repository #{@client.repo_full_name(repo)} created.")
45
+ end
46
+
47
+ private
48
+ def load_config
49
+ YAML.load_file("#{Dir.home}/.bucket")
50
+ rescue
51
+ generate_config
52
+ end
53
+
54
+ def generate_config
55
+ save_config ask_credentials
56
+ end
57
+
58
+ def save_config(credentials)
59
+ File.open "#{Dir.home}/.bucket", 'w' do |f|
60
+ YAML.dump(credentials , f)
61
+ end
62
+
63
+ credentials
64
+ end
65
+
66
+ def ask_credentials
67
+ username = @shell.ask("Username:")
68
+ @shell.say("Password: ")
69
+ password = $stdin.noecho(&:gets).strip
70
+ @shell.say("")
71
+
72
+ { "username" => username, "password" => password }
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,29 @@
1
+ module Bucket
2
+ class Client
3
+ GIT_URL = "git@bitbucket.org"
4
+
5
+ def initialize(credentials)
6
+ @connection = BitBucket.new basic_auth: "#{credentials["username"]}:#{credentials["password"]}"
7
+ end
8
+
9
+ def repos_list
10
+ @connection.repos.list
11
+ end
12
+
13
+ def repo_url(user, name)
14
+ "#{GIT_URL}:#{user}/#{name}.git"
15
+ end
16
+
17
+ def repo_full_name(repo)
18
+ "#{repo[:owner]}/#{repo[:slug]}"
19
+ end
20
+
21
+ # Returns the created repository scm url
22
+ def create_repo(name, options={})
23
+ options = options.merge(is_private: !options[:public])
24
+
25
+ @connection.repos.create(options.merge(name: name))
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module Bucket
2
+ VERSION = "0.0.1"
3
+ end
data/lib/bucket.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "bucket/client"
2
+ require "bucket/version"
3
+ require "bitbucket_rest_api"
4
+
5
+ module Bucket
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ describe "Bucket" do
2
+ subject { Bucket }
3
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest/autorun"
2
+ require "minitest/pride"
3
+
4
+ require_relative "../lib/bucket"
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bucket-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Roberto Poo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: omniauth
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bitbucket_rest_api
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: CLI for BitBucket
98
+ email:
99
+ - xaro@poo.cl
100
+ executables:
101
+ - bucket
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - bin/bucket
111
+ - bucket.gemspec
112
+ - lib/bucket.rb
113
+ - lib/bucket/cli.rb
114
+ - lib/bucket/client.rb
115
+ - lib/bucket/version.rb
116
+ - spec/bucket_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/xaro/bucket
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.0.3
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Easily clone and create repositories in BitBucket from the command line.
142
+ Init and link the local repository with a new BitBucket one in one command.
143
+ test_files:
144
+ - spec/bucket_spec.rb
145
+ - spec/spec_helper.rb
146
+ has_rdoc: