rapid-cli 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/review +8 -0
- data/bin/version +8 -0
- data/lib/review.rb +74 -0
- data/lib/version.rb +52 -0
- metadata +51 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f1ea1b2b7bffbc91c024eecd8d3c73f079c0ad5b
|
4
|
+
data.tar.gz: 8598ba479403d15e1945f27d42e7af41a331872f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed4b13f1ed1b162437dac1b42a5b2f63f023cafbac7949c2e221b232058e492d65b05d60a38d986843e2226ac826ab1f1d3db796ca85d4cf5dca30e2aba94ae6
|
7
|
+
data.tar.gz: e13b94fb81511e6c521725f3ce368ed683ece7e9df455bf26e7c7343888ca35476f09580e5876181f72152c281fbf96ea5845e65653b3f2b6408421b7e61dfeb
|
data/bin/review
ADDED
data/bin/version
ADDED
data/lib/review.rb
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
module Review
|
5
|
+
class << self
|
6
|
+
|
7
|
+
def files
|
8
|
+
output = `git status --porcelain | grep "^\\(.\\)\\+M" | sed s/^...//`
|
9
|
+
output.split("\n")
|
10
|
+
end
|
11
|
+
|
12
|
+
def show_diff_for(filename)
|
13
|
+
cmd = "git diff " + filename
|
14
|
+
system(cmd)
|
15
|
+
ask_to_add filename
|
16
|
+
end
|
17
|
+
|
18
|
+
def ask_to_add(filename)
|
19
|
+
choose do |cmd|
|
20
|
+
cmd.index = :none
|
21
|
+
cmd.prompt = "Add to stage? "
|
22
|
+
cmd.layout = :one_line
|
23
|
+
cmd.choice("yes") { add_to_stage filename }
|
24
|
+
cmd.choice("no")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def add_to_stage(filename)
|
29
|
+
cmd = "git add " + filename
|
30
|
+
system(cmd)
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_menu
|
34
|
+
HighLine.color_scheme = HighLine::ColorScheme.new do |cs|
|
35
|
+
cs[:system_option] = [ :green ]
|
36
|
+
cs[:simple_option] = [ :magenta ]
|
37
|
+
end
|
38
|
+
|
39
|
+
choose do |menu|
|
40
|
+
menu.header = "Select file to see"
|
41
|
+
menu.prompt = "> "
|
42
|
+
|
43
|
+
menu.choice("<%= color('Stop stage review', :system_option) %>") { exit 1 }
|
44
|
+
|
45
|
+
for i in 0...files.size
|
46
|
+
filename = files[i]
|
47
|
+
option_string = "<%= color('#{filename}', :simple_option) %>"
|
48
|
+
|
49
|
+
menu.choice(option_string) do
|
50
|
+
show_diff_for filename
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
show_menu
|
56
|
+
end
|
57
|
+
|
58
|
+
def run
|
59
|
+
if files.size == 0
|
60
|
+
puts "There are no unstaged files"
|
61
|
+
exit 0
|
62
|
+
elsif files.size == 1
|
63
|
+
show_diff_for(files.first)
|
64
|
+
else
|
65
|
+
show_menu
|
66
|
+
end
|
67
|
+
|
68
|
+
system("git status -s")
|
69
|
+
exit 1
|
70
|
+
end
|
71
|
+
|
72
|
+
end # class
|
73
|
+
end # module
|
74
|
+
|
data/lib/version.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'highline/import'
|
3
|
+
|
4
|
+
module Version
|
5
|
+
class << self
|
6
|
+
|
7
|
+
COMMANDS = ['major', 'minor', 'patch']
|
8
|
+
REGEX = /^([0-9]+)\.?([0-9]*)\.?([0-9]*)/
|
9
|
+
|
10
|
+
def run
|
11
|
+
version = ARGV[0]
|
12
|
+
command = ARGV[1]
|
13
|
+
|
14
|
+
unless ARGV.size > 1 or version =~ REGEX
|
15
|
+
puts 'Usage: version <version> <command>'
|
16
|
+
puts
|
17
|
+
puts 'Commands:'
|
18
|
+
puts "\tmajor\tUpgrade major number"
|
19
|
+
puts "\tminor\tUpgrade minor number"
|
20
|
+
puts "\tpatch\tUpgrade patch number"
|
21
|
+
puts
|
22
|
+
puts 'Example:'
|
23
|
+
puts "\tversion 1.3.5 minor"
|
24
|
+
exit 0
|
25
|
+
end
|
26
|
+
|
27
|
+
parts = version.scan(REGEX)
|
28
|
+
parts = parts.first
|
29
|
+
parts.map! { |i| i.to_i }
|
30
|
+
|
31
|
+
major = parts[0]
|
32
|
+
minor = parts[1]
|
33
|
+
patch = parts[2]
|
34
|
+
|
35
|
+
if command == COMMANDS[0]
|
36
|
+
major += 1
|
37
|
+
minor = 0
|
38
|
+
patch = 0
|
39
|
+
elsif command == COMMANDS[1]
|
40
|
+
minor += 1
|
41
|
+
patch = 0
|
42
|
+
else
|
43
|
+
patch += 1
|
44
|
+
end
|
45
|
+
|
46
|
+
puts "#{major}.#{minor}.#{patch}"
|
47
|
+
exit 1
|
48
|
+
end # run
|
49
|
+
|
50
|
+
end # class
|
51
|
+
end # module
|
52
|
+
|
metadata
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rapid-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Madson Cardoso
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |
|
14
|
+
Rapid is a simple command-line toolset to see diff for files in a git
|
15
|
+
repository more useful when it has more than one modified files.
|
16
|
+
email: madsonmac@gmail.com
|
17
|
+
executables:
|
18
|
+
- review
|
19
|
+
- version
|
20
|
+
extensions: []
|
21
|
+
extra_rdoc_files: []
|
22
|
+
files:
|
23
|
+
- bin/review
|
24
|
+
- bin/version
|
25
|
+
- lib/review.rb
|
26
|
+
- lib/version.rb
|
27
|
+
homepage: http://madsonmac.com
|
28
|
+
licenses:
|
29
|
+
- MIT
|
30
|
+
metadata: {}
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
40
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
version: '0'
|
45
|
+
requirements: []
|
46
|
+
rubyforge_project:
|
47
|
+
rubygems_version: 2.2.2
|
48
|
+
signing_key:
|
49
|
+
specification_version: 4
|
50
|
+
summary: Rapid is a command-line toolset.
|
51
|
+
test_files: []
|