autovrsion 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b64d1d6200144bafcaced4a667d72e9bba769f0
4
- data.tar.gz: bcc353d8cbee22c84e9e7a3147558b42e1435cbc
3
+ metadata.gz: b2ef6bb69903ab109a3fcda0e9dd931b60ce92b7
4
+ data.tar.gz: b8657194ad863df087a13fdac64561bc072fbc63
5
5
  SHA512:
6
- metadata.gz: 4aa7bce7009ce48958c3b0bacf43ac546d8cd37f6d5c059bfa8f3ca0e33ac9da761f8c29329995cfd8671ac1163e6740498ad7fe036abb4a395077d3655e2c47
7
- data.tar.gz: 36592f4a20276751fd63b647280063f7e7d7c90ec16b6e6664bdde49a15e8b241d8b721070a420aefa70b3b6298343c37c8851abb76d80671371fd43ae7ac185
6
+ metadata.gz: 96ac7952027f8fe080f9d429e2dd4a231b648318838696592d10fda6f3937436a8b9f472954efd7224d99f5ec52a646374eff13d479e5f5f2a58b80853347f51
7
+ data.tar.gz: 0d7a12c8059737206bf179721d77471eda234f95c9445e6e7a56cc69dbab2ee376456f6c39a11e13e07b160defc49a4c0df64164336370497666b93392e51090
data/README.md CHANGED
@@ -39,3 +39,28 @@ https://www.ruby-lang.org/en/installation/
39
39
  6.reset - used after the check command,it resets to the latest version in the repository.
40
40
  7.rewind - permanently rewind to a previous version(WARNING! any changes after the rewound version are permanently lost)
41
41
 
42
+ ### Command Usage
43
+
44
+ $ autovrsion create
45
+ $ autovrsion create </path/to/repository>
46
+ initialize your repository at current directory or specified directory
47
+
48
+ $ autovrsion start
49
+ $ autovrsion start </path/to/repository>
50
+ This will start the listener which will auto-commit after every change detected in the directory
51
+
52
+ $ autovrsion display
53
+ $ autovrsion display </path/to/repository>
54
+ Shows a list of all versions in the directory.
55
+
56
+ $ autovrsion check
57
+ $ autovrsion check </path/to/repository>
58
+ Enter the version number to access a particular version(always use reset after this command).
59
+
60
+ $ autovrsion reset
61
+ $ autovrsion reset </path/to/repository>
62
+ Reset to latest version.
63
+
64
+ $ autovrsion rewind
65
+ $ autovrsion rewind </path/to/repository>
66
+ Permanently rewind to a particular version. All versions above the specified versions are removed permanently !
data/autovrsion.gemspec CHANGED
@@ -20,12 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
21
  spec.require_paths = ["lib"]
22
22
 
23
- spec.add_runtime_dependency "ruby-git"
24
- spec.add_runtime_dependency "rugged"
25
- spec.add_runtime_dependency "git"
26
- spec.add_runtime_dependency "listen"
27
- spec.add_runtime_dependency "daemons"
28
- spec.add_runtime_dependency "colored"
23
+ spec.add_runtime_dependency "ruby-git", "~> 0.2.2"
24
+ spec.add_runtime_dependency "rugged" , "~> 0.19.0"
25
+ spec.add_runtime_dependency "git" , "~> 1.2.6"
26
+ spec.add_runtime_dependency "listen" , "~> 2.7.5"
27
+ spec.add_runtime_dependency "colored", "~> 1.2"
29
28
 
30
29
  spec.add_development_dependency "bundler", "~> 1.5"
31
30
  spec.add_development_dependency "rake"
data/bin/autovrsion CHANGED
@@ -4,53 +4,69 @@ require 'listen'
4
4
  require 'rugged'
5
5
  require 'git'
6
6
 
7
+ require 'autovrsion/display_versions.rb'
8
+ require 'autovrsion/filelistener.rb'
9
+ require 'autovrsion/version_checkout.rb'
10
+ require 'autovrsion/create_repository.rb'
11
+ require 'autovrsion/reset.rb'
12
+ require 'autovrsion/rewind.rb'
13
+
7
14
  if ARGV[1] == nil
8
- path = Dir.pwd
15
+ path = Dir.pwd.to_s
9
16
  else
10
- path = ARGV[1]
17
+ path = ARGV[1].to_s
11
18
  end
19
+
12
20
  case ARGV[0]
13
21
  when "options"
14
- puts "\tdisplay - "
15
- puts "\tstart"
16
- puts "\tstop"
17
- puts "\tcheck"
18
- puts "\tcreate"
19
- puts "\treset"
20
- puts "\trewind"
21
- when "help"
22
- f = File.open("README.md")
23
- while line = f.gets do
24
- puts line
25
- end
26
-
27
- f.close
22
+ puts"create:\n$ autovrsion create
23
+ $ autovrsion create </path/to/repository>
24
+ initialize your repository at current directory or specified directory
25
+ start:
26
+ $ autovrsion start
27
+ $ autovrsion start </path/to/repository>
28
+ This will start the listener which will auto-commit after every change detected in the directory
29
+ display:
30
+ $ autovrsion display
31
+ $ autovrsion display </path/to/repository>
32
+ Shows a list of all versions in the directory.
33
+ check:
34
+ $ autovrsion check
35
+ $ autovrsion check </path/to/repository>
36
+ Enter the version number to access a particular version(always use reset after this command).
37
+ reset:
38
+ $ autovrsion reset
39
+ $ autovrsion reset </path/to/repository>
40
+ Reset to latest version.
41
+ rewind:
42
+ $ autovrsion rewind
43
+ $ autovrsion rewind </path/to/repository>
44
+ Permanently rewind to a particular version. All versions above the specified versions are removed permanently !"
45
+
28
46
  when "display"
29
- require 'autovrsion/display_versions.rb'
30
47
  d= DisplayLog.new
31
48
  d.disp(path)
49
+
32
50
  when "start"
33
- require 'autovrsion/filelistener.rb'
34
- puts "Listening to changes.enter "+"stop ".red+"or"+" 1 ".red+"to stop listening to changes"
35
51
  f = FileListen.new
36
- f.lis(path)
37
-
38
- when "check"
39
- require 'autovrsion/version_checkout.rb'
52
+ f.lis(path,"start")
53
+
54
+ when "check"
40
55
  v = Checkout.new
41
56
  v.chk(path)
57
+
42
58
  when "create"
43
- require 'autovrsion/create_repository.rb'
44
59
  c = CreateRepo.new
45
60
  c.create(path)
46
- when "reset"
47
- require 'autovrsion/reset.rb'
61
+
62
+ when "reset"
48
63
  r = Reset.new
49
64
  r.reset(path)
50
- when "rewind"
51
- require 'autovrsion/rewind.rb'
65
+
66
+ when "rewind"
52
67
  rw = Rewind.new
53
68
  rw.rewindto(path)
69
+
54
70
  end
55
71
 
56
72
 
@@ -6,12 +6,14 @@ class DisplayLog
6
6
  begin
7
7
  @repo=Rugged::Repository.new(path)
8
8
  ref=@repo.head
9
+
9
10
  version_count = 0
10
11
  walker = Rugged::Walker.new(@repo)
11
12
  walker.push(ref.target)
12
13
  walker_counter = Rugged::Walker.new(@repo)
13
14
  walker_counter.push(ref.target)
14
15
  walker_counter.each {version_count += 1}
16
+
15
17
  walker_counter.reset
16
18
 
17
19
  walker.each { |c|
@@ -4,67 +4,106 @@ require 'listen'
4
4
  require 'colored'
5
5
 
6
6
  class FileListen
7
- def lis(path)
8
- repo=Rugged::Repository.new(path)
9
- #callback = Proc.new do |modified,added,removed|
10
- listener = Listen.to(path) do |modified,added,removed|
11
- index = repo.index
12
- user = {
13
- name: repo.config['user.name'],
14
- email: repo.config['user.email'],
15
- time: Time.now
16
- }
7
+ def lis(path,option)
8
+ begin
9
+ puts "Listening to changes.enter "+"stop ".red+"or"+" 1 ".red+"to stop listening to changes"
10
+ repo=Rugged::Repository.new(path)
11
+ listener = Listen.to(path,only: [/^^[\/[a-zA-Z]*]*["Untitled Document"]/,/^[\/[a-zA-Z]*]*[".git"]/]) do |modified,added,removed|
12
+
13
+ index = repo.index
14
+ user = {
15
+ name: repo.config['user.name'],
16
+ email: repo.config['user.email'],
17
+ time: Time.now
18
+ }
17
19
 
18
- commit_options = {}
19
- commit_options[:tree] = index.write_tree(repo)
20
- commit_options[:author] = user
21
- commit_options[:committer] = user
22
- commit_options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
23
- commit_options[:update_ref] = 'HEAD'
20
+ commit_options = {}
21
+ commit_options[:author] = user
22
+ commit_options[:committer] = user
23
+ commit_options[:parents] = repo.empty? ? [] : [ repo.head.target ].compact
24
+ commit_options[:update_ref] = 'HEAD'
24
25
 
25
- if modified.empty? == false then
26
+ if modified.empty? == false
27
+ index.reload
28
+ modified.each do |x|
29
+ x.gsub!(/[a-zA-Z]*[\/]/,"")
30
+ puts x
31
+ index.add("#{x}")
32
+ end
26
33
 
34
+ commit_options[:tree] = index.write_tree(repo)
35
+ m = modified
36
+ index.write
37
+ m.each do |x|
38
+ x.gsub!(/(\[)(\/[a-zA-Z]*)*(\/)/,"")
39
+ x.gsub!(/\]/,"")
40
+ puts x.gsub
41
+ end
42
+ commit_options[:message] ||= "#{m} modified at "+"#{Time.now}"
43
+
44
+ Rugged::Commit.create(repo,commit_options)
45
+ puts "File Modified".yellow
46
+ end
27
47
 
28
- m = modified
29
- index.add_all
30
- index.write
31
- commit_options[:message] ||= "#{m} modified at "+"#{Time.now}"
32
- Rugged::Commit.create(repo,commit_options)
33
- puts "File Modified".yellow
34
- end
48
+ if added.empty? == false
49
+ index.reload
50
+ added.each do |x|
51
+ x.gsub!(/[a-zA-Z]*[\/]/,"")
52
+ index.add("#{x}")
53
+ if x == "Untitled Document"
54
+ index.remove("Untitled Document")
55
+ end
56
+ end
35
57
 
36
- if added.empty? == false then
37
- a = added
38
- #a.sub('[',' ')
39
- #a.sub(']',' ')
40
- index.add_all
41
- index.write
42
- commit_options[:message] ||= " #{a} added at "+"#{Time.now}"
43
- Rugged::Commit.create(repo,commit_options)
44
- puts "File Added".green
45
- end
58
+ a = added
59
+ commit_options[:tree] = index.write_tree repo
60
+ a.each do |x|
61
+ x.gsub!(/(\[)(\/[a-zA-Z]*)*(\/)/,"")
62
+ x.gsub!(/\]/,"")
63
+ puts x
64
+ end
65
+
66
+ index.write
67
+ commit_options[:message] ||= " #{a} added at "+"#{Time.now}"
68
+ if a[0] != "Untitled Document"
69
+ Rugged::Commit.create(repo,commit_options)
70
+ puts "File Added".green
71
+ end
72
+ end
46
73
 
47
- if removed.empty? == false then
48
- r = removed
49
- commit_options[:message] ||= "#{r} removed at "+"#{Time.now}"
50
- Rugged::Commit.create(repo, commit_options)
51
- puts "File Removed".red
74
+ if removed.empty? == false
75
+
76
+ index.reload
77
+ r = removed
78
+ index.add_all
79
+ commit_options[:tree] = index.write_tree(repo)
80
+ r.each do |x|
81
+ x.gsub!(/(\[)(\/[a-zA-Z]*)*(\/)/,"")
82
+ x.gsub!(/\]/,"")
83
+ end
84
+ index.write
85
+ commit_options[:message] ||= "#{r} removed at "+"#{Time.now}"
86
+ if r[0] != "Untitled Document"
87
+ Rugged::Commit.create(repo,commit_options)
88
+ puts "File Removed".red
89
+ end
90
+ end
52
91
  end
53
92
 
54
-
55
- end
56
- listener.start
57
-
58
- stop = STDIN.gets
59
- if stop == 'stop'
93
+ listener.start
94
+ stop = STDIN.gets
95
+ if stop == "stop"
60
96
  puts "Listener stopped"
61
- listener.stop
62
-
97
+ listener.stop
63
98
  end
99
+
64
100
  if stop.to_i == 1
65
- abort"Listener stopped"
66
- listener.stop
101
+ listener.stop
102
+ abort"Listener stopped"
67
103
  end
68
- #listener.stop
104
+ rescue Errno::ENOENT
105
+ puts "Error !Path does not exist".red
106
+ end
69
107
  end
108
+
70
109
  end
@@ -1,3 +1,3 @@
1
1
  module Autovrsion
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1 @@
1
+ Testing yet to be done.
metadata CHANGED
@@ -1,99 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: autovrsion
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shaunak Pagnis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2014-05-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-git
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: 0.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rugged
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 0.19.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 0.19.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: git
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ~>
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.2.6
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.2.6
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: listen
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: daemons
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '>='
59
+ - - ~>
74
60
  - !ruby/object:Gem::Version
75
- version: '0'
61
+ version: 2.7.5
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
- - - '>='
66
+ - - ~>
81
67
  - !ruby/object:Gem::Version
82
- version: '0'
68
+ version: 2.7.5
83
69
  - !ruby/object:Gem::Dependency
84
70
  name: colored
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - '>='
73
+ - - ~>
88
74
  - !ruby/object:Gem::Version
89
- version: '0'
75
+ version: '1.2'
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - '>='
80
+ - - ~>
95
81
  - !ruby/object:Gem::Version
96
- version: '0'
82
+ version: '1.2'
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: bundler
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -146,6 +132,7 @@ files:
146
132
  - lib/autovrsion/rewind.rb
147
133
  - lib/autovrsion/version.rb
148
134
  - lib/autovrsion/version_checkout.rb
135
+ - test/autovrsion_test.rb
149
136
  homepage: ''
150
137
  licenses:
151
138
  - MIT
@@ -170,4 +157,5 @@ rubygems_version: 2.0.3
170
157
  signing_key:
171
158
  specification_version: 4
172
159
  summary: Command line tool for automatic versioning of files in a repository
173
- test_files: []
160
+ test_files:
161
+ - test/autovrsion_test.rb