git_command 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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/git_command.rb +46 -0
  3. metadata +44 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d68037fc43f50fa7df3bb36bcb86c0d2ebaeef29
4
+ data.tar.gz: 50f1caac111487d5f721a28d3dba7b69f9a7fc11
5
+ SHA512:
6
+ metadata.gz: f36a01bfde2b5f6add9b8e221644f121438f14465dc8a4baa4341c1451ec737ae5832c66a22d4f8076171ada5cedb7736869882f85313cfd4073c2ab21590285
7
+ data.tar.gz: 2283972959f407e58598c56ad093a3c63446d7a46b099c01c0fddc1990feea9a1a062c09d316f2af402e3ae107013a43da6ed2639c876c8c6c03981cd1aeb450
@@ -0,0 +1,46 @@
1
+ require 'byebug'
2
+ def command command, &block
3
+ @commands ||= {}
4
+
5
+ @commands[command] = block
6
+
7
+ temp_args = ARGV
8
+ first = temp_args.shift
9
+
10
+ args = []
11
+ options = {}
12
+
13
+ is_option = false
14
+ option = ""
15
+
16
+ param = false
17
+ temp_args.each do |arg|
18
+ if is_option
19
+ options[option.to_sym] = arg
20
+ is_option = false
21
+ elsif option?(arg)
22
+ is_option = true
23
+ option = arg.gsub /--/, ''
24
+ elsif flag?(arg)
25
+ options[arg] = true
26
+ else
27
+ args << arg
28
+ end
29
+ end
30
+
31
+ args = [ nil ] if args = []
32
+
33
+ if first == command.to_s
34
+ byebug
35
+ block.call *args, **options
36
+ end
37
+ end
38
+
39
+ private
40
+ def option?( option )
41
+ option.match /\A--/
42
+ end
43
+
44
+ def flag?( flag )
45
+ flag.match /\A-/
46
+ end
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: git_command
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Cody Poll
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-06-09 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A small framework for creating custom git commands in ruby
14
+ email: CJPoll@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/git_command.rb
20
+ homepage: ''
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.0.14
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: A small framework for creating custom git commands in ruby
44
+ test_files: []