stg 0.1.2 → 0.1.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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/actions.rb +6 -9
  3. data/lib/stg.rb +40 -43
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 230caddab1e3d4399c0b45c216170abce501826f39b0b64e760423c9ac09b0e5
4
- data.tar.gz: 43ab838f4b5de8ab7c68fa51cd6ae895bf13eaf1e1de1d51f0e64cf04af7cd87
3
+ metadata.gz: a24fa114435be573b5b125dc7631052ba02e9b87c071d900aef8be5dd3c771e3
4
+ data.tar.gz: ae2e3189797eb7f737bf2e6f44502458dbf0567d69c8659a1adf18c5a7619a0b
5
5
  SHA512:
6
- metadata.gz: a0f834b3a3de3f1717c4ec41384aa4170323f85a84732f498d788d95bbb70b054c225096961016bc2869b10736278cc1714f8e7d256927c929ba2572da5e0e43
7
- data.tar.gz: 84e35003956f79895a4ac410fb80dd8c40c8fa33b6e724decaf2b56a095c5decac87433dccc363ccf9bf793acfe0509dcd71c10190aab742bd1b4ceb1aad8dea
6
+ metadata.gz: e9b91105669be9f1b50129e3c347af9c7b9dc6adfd1d476d7c015005db0990927848956587961f16f6e3cd8a134edfc4cf4707ea720bd78423110d807e197e7e
7
+ data.tar.gz: c19cea532598c24f46e8743f6f5af524d087780730b19e1081cc0318dea0ec2a68757effdd440429384e17107abf714161f302f4d9daf90f861a7e0206029fd8
data/lib/actions.rb CHANGED
@@ -63,7 +63,7 @@ module Actions
63
63
 
64
64
  index = JSON.parse(File.read('.stolen-git/index.json'))
65
65
 
66
- define_method(:stage_file) do |file_path|
66
+ stage_file = lambda do |file_path|
67
67
  file_hash = get_file_hash(file_path)
68
68
  file_content = File.read(file_path)
69
69
 
@@ -78,16 +78,13 @@ module Actions
78
78
  index[file_path]['hash'] = file_hash
79
79
  end
80
80
 
81
- define_method(:stage_directory) do |dir_path|
81
+ stage_directory = lambda do |dir_path|
82
82
  Dir.children(dir_path).each do |entry|
83
- # puts "entry: #{entry}"
84
83
  path = File.join(dir_path, entry)
85
84
  if File.file?(path)
86
- # puts "entry_file: #{path}"
87
- stage_file(path)
85
+ stage_file.call(path)
88
86
  else
89
- # puts "entry_dir: #{path}"
90
- stage_directory(path)
87
+ stage_directory.call(path)
91
88
  end
92
89
  end
93
90
  end
@@ -99,9 +96,9 @@ module Actions
99
96
  end
100
97
 
101
98
  if File.file?(inp_path)
102
- stage_file(inp_path)
99
+ stage_file.call(inp_path)
103
100
  elsif File.directory? inp_path
104
- stage_directory(inp_path)
101
+ stage_directory.call(inp_path)
105
102
  else
106
103
  puts "Error logging #{inp_path}. It's neither a file or a directory"
107
104
  end
data/lib/stg.rb CHANGED
@@ -1,47 +1,44 @@
1
1
  require_relative 'help'
2
2
  require_relative 'actions'
3
3
 
4
- command = ARGV.shift
5
- NAME = 'stolen-git'
6
- include Actions
7
- include Help
8
- case command
9
- when 'init'
10
- p_initialize
11
-
12
- when 'commit'
13
- commit
14
-
15
- when 'diff'
16
- diff
17
- when 'test'
18
- test
19
-
20
- when 'stage'
21
- stage
22
-
23
- when 'check_router'
24
- check_router
25
- when 'reset'
26
- reset
27
- when 'log'
28
- log
29
-
30
- when 'checkout'
31
- checkout
32
-
33
- when 'branch'
34
- branch
35
-
36
- when 'help'
37
- puts print_usage
38
- exit 1
39
-
40
- when nil
41
- puts print_usage
42
- exit 1
43
-
44
- else
45
- puts "Unknown command: #{command}"
46
- exit 1
4
+ module Stg
5
+ class CLI
6
+ extend Actions
7
+ extend Help
8
+
9
+ def self.start
10
+ command = ARGV.shift
11
+ case command
12
+ when 'init'
13
+ p_initialize
14
+ when 'commit'
15
+ commit
16
+ when 'diff'
17
+ diff
18
+ when 'test'
19
+ test
20
+ when 'stage'
21
+ stage
22
+ when 'check_router'
23
+ check_router
24
+ when 'reset'
25
+ reset
26
+ when 'log'
27
+ log
28
+ when 'checkout'
29
+ checkout
30
+ when 'branch'
31
+ branch
32
+ when 'help'
33
+ puts print_usage
34
+ exit 1
35
+ when nil
36
+ puts print_usage
37
+ exit 1
38
+ else
39
+ puts "Unknown command: #{command}"
40
+ exit 1
41
+ end
42
+ end
43
+ end
47
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Amr ElTaweel