gpr 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 80d2d92c3f8db42725dddeb4d0b9b260afe8a8ba
4
- data.tar.gz: b0b7c3932b6a09afea0b4225aa69d377f2871c2b
3
+ metadata.gz: db4e04d3bc996e20786e660233433065632ae416
4
+ data.tar.gz: 3236bfb901ec284240a172a2b9d981fe5fc66fa3
5
5
  SHA512:
6
- metadata.gz: d0717eec796c4a585f41c2f43c1dd9b248763a63e79657343582a7e4da00bcdb784de28b9aef82e6dfc03eb900f3e7b355e302a7d030684e7b8a69351e0345e4
7
- data.tar.gz: 105a7e363d6ef9c09fe5a1d30e1790e3dd7274fa0d7302730d30618446c950692551f478e5d17a32f7645e48323fdca090368878a16518739713edce5e7c70c3
6
+ metadata.gz: d062b5bc775e280220b747d8bf0f993535b8b7b46a45e8f5440294a31203a184a9417755280fe7cc7a9f648bde4d78b61e2f2ce9410b3c7072f90ac5c3ae5fbd
7
+ data.tar.gz: b40cffe88efad45628284744a73e6a4a571fa889b18f0ce87ffc4e0418e465a19e690b9b470e14334316d3ceee066e463dfbe68734b9ec42dad0692c49f5c97b
data/README.md CHANGED
@@ -18,6 +18,10 @@ It is possible to centrally manage of the all repositories.
18
18
  $ gem install gpr
19
19
  ```
20
20
 
21
+ ## Requirements
22
+
23
+ * Ruby 2.1.0 or higher
24
+
21
25
  ## Usage
22
26
 
23
27
  ```sh
@@ -29,31 +33,38 @@ $ gpr help
29
33
  Just clone a git repository into `$HOME/.gpr/<host>/<user>/<repository>`.
30
34
 
31
35
  ```sh
36
+ # e.g. gpr get git@github.com:kaihar4/gpr.git
32
37
  $ gpr get <repository url>
33
38
  ```
34
39
 
40
+ This is alias of GitHub.
41
+
42
+ ```sh
43
+ # e.g. gpr get kaihar4/gpr
44
+ $ gpr get <user>/<repository>
45
+ ```
46
+
35
47
  ### Register all public repositories of the specified user
36
48
 
37
49
  You can specify host only `github.com` or `bitbucket.org`.
38
50
 
39
51
  ```sh
52
+ # e.g. gpr get github.com/kaihar4
40
53
  $ gpr get <host>/<user>
41
54
  ```
42
55
 
43
56
  ### Show all registered repositories
44
57
 
45
58
  ```sh
46
- $ gpr list
47
- ```
59
+ Usage:
60
+ gpr list
48
61
 
49
- ![list](https://raw.github.com/wiki/kaihar4/gpr/images/list.png)
62
+ Options:
63
+ [--paths], [--no-paths] # Show the paths of all registered repositories
50
64
 
51
- ```sh
52
- $ gpr list --paths
65
+ Show all registered repositories
53
66
  ```
54
67
 
55
- ![list\_paths](https://raw.github.com/wiki/kaihar4/gpr/images/list_paths.png)
56
-
57
68
  ### Select a repository using the interactive interface
58
69
 
59
70
  ```sh
@@ -113,9 +124,17 @@ $ gpr update
113
124
  ### Fetch all registered repositories
114
125
 
115
126
  ```sh
127
+ # e.g. gpr fetch origin
116
128
  $ gpr fetch <remote repository>
117
129
  ```
118
130
 
131
+ Also possible to specify the branch.
132
+
133
+ ```sh
134
+ # e.g. gpr fetch origin master
135
+ $ gpr fetch <remote repository> <branch>
136
+ ```
137
+
119
138
  If you run for short, it means `gpr fetch origin`.
120
139
 
121
140
  ```sh
@@ -146,8 +165,8 @@ $ source ~/.zshrc
146
165
  alias gcd='cd $(gpr select)'
147
166
  # Remove a directory that you specify
148
167
  alias grm='rm -rf $(gpr select)'
149
- # Show your contributions of a directory that you specify
168
+
169
+ # And more...
150
170
  alias gcontrib='gpr contrib $(gpr select)'
151
- # Fetch a repository of a directory that you specify
152
171
  alias gfetch='gpr fetch $(gpr select)'
153
172
  ```
data/lib/gpr/cli.rb CHANGED
@@ -17,19 +17,27 @@ module Gpr
17
17
  return
18
18
  end
19
19
 
20
- puts "#{user}/#{repository} is registering..."
21
- unless GitHelper.clone(param, path)
22
- puts "Failed to clone #{user}/#{repository}."
23
- return
24
- end
20
+ GitHelper.clone(param, path)
25
21
  add_file(path)
26
22
 
27
23
  when /^([^\/]+)\/([^\/]+)$/
28
24
  parsed_param = param.match(/^([^\/]+)\/([^\/]+)$/)
29
- host = parsed_param[1]
30
- user = parsed_param[2]
31
25
 
32
- APIHelper.get_repository_urls(host, user).each do |clone_url|
26
+ # <host>/<user>
27
+ if parsed_param[1].include?('.')
28
+ host = parsed_param[1]
29
+ user = parsed_param[2]
30
+
31
+ APIHelper.get_repository_urls(host, user).each do |clone_url|
32
+ get(clone_url)
33
+ end
34
+
35
+ # <user>/<repository>
36
+ else
37
+ user = parsed_param[1]
38
+ repository = parsed_param[2]
39
+
40
+ clone_url = "https://github.com/#{user}/#{repository}.git"
33
41
  get(clone_url)
34
42
  end
35
43
  end
@@ -2,7 +2,7 @@ module Gpr
2
2
  module GitHelper
3
3
  class << self
4
4
  def clone(url, path)
5
- system("git clone #{url} #{path} >/dev/null 2>&1")
5
+ `git clone #{url} #{path}`
6
6
  end
7
7
 
8
8
  def ls_files(path)
data/lib/gpr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Gpr
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -26,7 +26,7 @@ module GraphDrawer
26
26
  if @value.zero?
27
27
  draw_str = "#{@item}|"
28
28
  else
29
- bar = ' ' * (@value - 1)
29
+ bar = ' ' * (@value - @value.to_s.size)
30
30
  data_label = @value.to_s.color(:black)
31
31
  draw_str = "#{@item}|#{(bar + data_label).bg_color(color)}"
32
32
  end
@@ -5,6 +5,7 @@ module InteractiveFilter
5
5
  @targets = array
6
6
 
7
7
  @input = Input.new
8
+ @outputs = []
8
9
  @cursor_position = 1
9
10
 
10
11
  Curses.init_screen
@@ -12,18 +13,13 @@ module InteractiveFilter
12
13
  Curses.noecho
13
14
  @window = Curses::Window.new(Curses.lines, Curses.cols, 0, 0)
14
15
  @window.keypad(true)
16
+ end
15
17
 
16
- # Initialize a window
17
- @outputs = []
18
- @window.clear
19
- reset_cursor_position
20
-
18
+ def grep
21
19
  output_line(@prompt)
22
20
  output_choises
23
21
  reset_cursor_position
24
- end
25
22
 
26
- def grep
27
23
  loop do
28
24
  key = @window.getch
29
25
  keycode = get_keycode(key)
@@ -44,11 +40,11 @@ module InteractiveFilter
44
40
  end
45
41
 
46
42
  elsif keycode == :KEY_DOWN
47
- down_cursor_position if @outputs.size > @cursor_position
43
+ down_cursor_position
48
44
  next
49
45
 
50
46
  elsif keycode == :KEY_UP
51
- up_cursor_position if @cursor_position > 1
47
+ up_cursor_position
52
48
  next
53
49
 
54
50
  # Ignore other keys
@@ -103,13 +99,23 @@ module InteractiveFilter
103
99
  end
104
100
 
105
101
  def up_cursor_position
106
- @window.setpos(@cursor_position - 1, 0)
107
- @cursor_position -= 1
102
+ if @cursor_position == 1
103
+ @window.setpos(@outputs.size, 0)
104
+ @cursor_position = @outputs.size
105
+ else
106
+ @window.setpos(@cursor_position - 1, 0)
107
+ @cursor_position -= 1
108
+ end
108
109
  end
109
110
 
110
111
  def down_cursor_position
111
- @window.setpos(@cursor_position + 1, 0)
112
- @cursor_position += 1
112
+ if @cursor_position == @outputs.size
113
+ @window.setpos(1, 0)
114
+ @cursor_position = 1
115
+ else
116
+ @window.setpos(@cursor_position + 1, 0)
117
+ @cursor_position += 1
118
+ end
113
119
  end
114
120
 
115
121
  def reset_cursor_position
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - kaihar4
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-10 00:00:00.000000000 Z
11
+ date: 2014-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor