pori 0.0.2 → 0.0.3

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.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Pori
2
2
 
3
- A command line toos for Bitbucket to create repository.(only git)
3
+ A command line toos for Bitbucket to create private repository.(only git)
4
4
 
5
5
  ## Installation
6
6
 
@@ -23,6 +23,7 @@ Or install it yourself as:
23
23
 
24
24
  ## Requirements
25
25
 
26
+ * [Git](http://git-scm.com/)
26
27
  * [cURL](http://curl.haxx.se/)
27
28
 
28
29
  ## Contributing
data/bin/pori CHANGED
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'pori'
4
+ Pori::Runner.execute(*ARGV)
data/lib/pori/commands.rb CHANGED
@@ -2,17 +2,45 @@
2
2
 
3
3
  require 'pit'
4
4
 
5
- config = Pit.get("bitbucket", :require => {
6
- "username" => "your account in bitbucket",
7
- "password" => "your password in bitbucket"
8
- })
5
+ module Pori
6
+ class Commands
7
+ def initialize(args)
8
+ @args = args
9
9
 
10
- username = config['username']
11
- password = config['password']
10
+ config = Pit.get("bitbucket", :require => {
11
+ "username" => "your account in bitbucket",
12
+ "password" => "your password in bitbucket"
13
+ })
14
+ @username = config['username']
15
+ @password = config['password']
16
+ end
12
17
 
13
- repo = new_repo_name
18
+ def self.run(args)
19
+ self.new(args).run
20
+ end
14
21
 
15
- puts "curl --request POST --user #{username}:#{password} https://api.bitbucket.org/1.0/repositories/ --data name=#{repo} --data scm=git --data is_private=true"
16
- system "curl --request POST --user #{username}:#{password} https://api.bitbucket.org/1.0/repositories/ --data name=#{repo} --data scm=git --data is_private=true"
17
- puts "git remote add origin ssh://git@bitbucket.org/#{username}/#{repo}.git"
18
- system "git remote add origin ssh://git@bitbucket.org/#{username}/#{repo}.git"
22
+ def run
23
+ # 今は決め打ち、動的に変更する
24
+ self.send('create')
25
+ end
26
+
27
+ def create
28
+ repo = new_repo_name
29
+
30
+ puts "curl --request POST --user #{@username}:#{@password.chars.map{|c| '*'}.join} https://api.bitbucket.org/1.0/repositories/ --data name=#{repo} --data scm=git --data is_private=true"
31
+ system "curl --request POST --user #{@username}:#{@password} https://api.bitbucket.org/1.0/repositories/ --data name=#{repo} --data scm=git --data is_private=true"
32
+ puts "git remote add origin ssh://git@bitbucket.org/#{@username}/#{repo}.git"
33
+ system "git remote add origin ssh://git@bitbucket.org/#{@username}/#{repo}.git"
34
+ end
35
+
36
+ private
37
+ def new_repo_name
38
+ raise Exception, "Not a git repository" unless is_git_repo?
39
+ Dir.pwd.split('/')[-1]
40
+ end
41
+
42
+ def is_git_repo?
43
+ system('git rev-parse --git-dir >/dev/null 2>&1;')
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,18 @@
1
+ module Pori
2
+ class Runner
3
+ attr_reader :args
4
+
5
+ def initialize(*args)
6
+ @args = args
7
+ end
8
+
9
+ # Shortcut
10
+ def self.execute(*args)
11
+ new(*args).execute
12
+ end
13
+
14
+ def execute
15
+ Commands.run(@args)
16
+ end
17
+ end
18
+ end
data/lib/pori/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pori
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/pori.rb CHANGED
@@ -1,4 +1,5 @@
1
+ # -*- coding: utf-8 -*-
2
+
1
3
  require "pori/version"
2
- require "pori/context"
3
4
  require "pori/commands"
4
-
5
+ require "pori/runner"
data/pori.gemspec CHANGED
@@ -4,7 +4,7 @@ require File.expand_path('../lib/pori/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Akira Maeda"]
6
6
  gem.email = ["glidenote@gmail.com"]
7
- gem.summary = %q{A command line tool for Bitbucket to create repositories.}
7
+ gem.summary = %q{A command line tool for Bitbucket to create private repositories.(only git)}
8
8
  gem.homepage = "http://github.com/glidenote/pori/"
9
9
 
10
10
  gem.files = `git ls-files`.split($\)
@@ -15,4 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.version = Pori::VERSION
16
16
 
17
17
  gem.add_dependency 'pit'
18
+ gem.add_dependency 'rake'
19
+ gem.add_development_dependency 'rspec'
18
20
  end
File without changes
data/spec/spec.opts ADDED
@@ -0,0 +1,5 @@
1
+ --colour
2
+ --format document
3
+ --loadby mtime
4
+ --backtrace
5
+ --reverse
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+
4
+ require 'pori'
5
+ require 'rspec'
6
+
7
+ RSpec.configure do |config|
8
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-04 00:00:00.000000000 Z
12
+ date: 2012-06-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: pit
16
- requirement: &70147834541300 !ruby/object:Gem::Requirement
16
+ requirement: &70344883657960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,29 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70147834541300
24
+ version_requirements: *70344883657960
25
+ - !ruby/object:Gem::Dependency
26
+ name: rake
27
+ requirement: &70344883657300 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70344883657300
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70344883656660 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :development
45
+ prerelease: false
46
+ version_requirements: *70344883656660
25
47
  description:
26
48
  email:
27
49
  - glidenote@gmail.com
@@ -38,9 +60,12 @@ files:
38
60
  - bin/pori
39
61
  - lib/pori.rb
40
62
  - lib/pori/commands.rb
41
- - lib/pori/context.rb
63
+ - lib/pori/runner.rb
42
64
  - lib/pori/version.rb
43
65
  - pori.gemspec
66
+ - spec/pori/.gitkeep
67
+ - spec/spec.opts
68
+ - spec/spec_helper.rb
44
69
  homepage: http://github.com/glidenote/pori/
45
70
  licenses: []
46
71
  post_install_message:
@@ -53,16 +78,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
53
78
  - - ! '>='
54
79
  - !ruby/object:Gem::Version
55
80
  version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 2418092421942208002
56
84
  required_rubygems_version: !ruby/object:Gem::Requirement
57
85
  none: false
58
86
  requirements:
59
87
  - - ! '>='
60
88
  - !ruby/object:Gem::Version
61
89
  version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 2418092421942208002
62
93
  requirements: []
63
94
  rubyforge_project:
64
95
  rubygems_version: 1.8.11
65
96
  signing_key:
66
97
  specification_version: 3
67
- summary: A command line tool for Bitbucket to create repositories.
68
- test_files: []
98
+ summary: A command line tool for Bitbucket to create private repositories.(only git)
99
+ test_files:
100
+ - spec/pori/.gitkeep
101
+ - spec/spec.opts
102
+ - spec/spec_helper.rb
data/lib/pori/context.rb DELETED
@@ -1,24 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- PWD = Dir.pwd
4
-
5
- def current_dir
6
- PWD
7
- end
8
-
9
- def new_repo_name
10
- is_git_repo=system("git rev-parse -q --git-dir")
11
-
12
- if is_git_repo
13
- tmp_dir = `git rev-parse -q --git-dir`.chomp
14
- if tmp_dir == ".git"
15
- repo_name = File.basename(Dir.pwd)
16
- else
17
- repo_dir_name = File.dirname("#{tmp_dir}") # => /Users/akira/repos/pori/.git
18
- repo_name = File.basename("#{repo_dir_name}")
19
- end
20
- else
21
- raise FatalError, "Not a git repository"
22
- end
23
- repo_name
24
- end