autovrsion 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b40c0ec2b2bac0695b23eea86ffbc7c39da9d8ad
4
+ data.tar.gz: 1ce65c4ee600723d9f9f1848455a28cd11bc6c61
5
+ SHA512:
6
+ metadata.gz: 453ca454d533c125a427fb60df8d5564dd89796ac5ca998fdb60f7a26e991e88c0c994cf1f5904804fccdb40747feeb65764e7246df92ed3d2a2fb8d98d734e2
7
+ data.tar.gz: bbe8ca96f5e8977a922a0e7673f6bcd0ae864a17f7af8cfe1c472de404bff155ece99be101b650780fb02e634f038d587d955c1dc4016ce1fe57e1991d2dd675
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in autovrsion.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Shaunak Pagnis
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # Autovrsion
2
+
3
+ A command line tool for simple auto versioning of files using Rugged and Listen.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'autovrsion'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install autovrsion
18
+
19
+ ## Pre-requisities
20
+ install Git:
21
+ command: $ sudo apt-get install git
22
+ install Ruby:
23
+ links for downloading and installing ruby
24
+ https://www.ruby-lang.org/en/downloads/
25
+ https://www.ruby-lang.org/en/installation/
26
+
27
+ ## Usage
28
+ $ autovrsion <option>
29
+ for working on current directory
30
+
31
+ $ autovrsion <option> </path/to/your/directory>
32
+ for working on a specific directory
33
+
34
+ options:-
35
+ 1.create - used to create a new git repository or re-initialize an existing one.
36
+ 2.start - start listening to file system changes and auto commit any change.commits would be created after every file addition,modification and/or deletion.
37
+ 4.display - display the versions in the repository.
38
+ 5.check - access a particular version.
39
+ 6.reset - used after the check command,it resets to the latest version in the repository.
40
+ 7.rewind - permanently rewind to a previous version(WARNING! any changes after the rewound version are permanently lost)
41
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,32 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'autovrsion/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "autovrsion"
8
+ spec.version = Autovrsion::VERSION
9
+ spec.authors = ["Shaunak Pagnis"]
10
+ spec.email = ["shaunak.pagnis@gmail.com"]
11
+ spec.summary = %q{Command line tool for automatic versioning of files in a repository}
12
+ spec.description = %q{A command line that uses Rugged and Listen for automatic versioning of files.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.bindir = 'bin'
18
+ spec.executables = 'autovrsion'
19
+ #spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
21
+ spec.require_paths = ["lib"]
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"
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.5"
31
+ spec.add_development_dependency "rake"
32
+ end
data/bin/autovrsion ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'listen'
4
+ require 'rugged'
5
+ require 'git'
6
+
7
+ if ARGV[1] == nil
8
+ path = Dir.pwd
9
+ else
10
+ path = ARGV[1]
11
+ end
12
+ case ARGV[0]
13
+ 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 "display"
22
+ require 'autovrsion/display_versions.rb'
23
+ d= DisplayLog.new
24
+ d.disp(path)
25
+ when "start"
26
+ require 'autovrsion/filelistener.rb'
27
+ puts "Listening to changes.enter "+"stop ".red+"or"+" 1 ".red+"to stop listening to changes"
28
+ f = FileListen.new
29
+ f.lis(path)
30
+
31
+ when "check"
32
+ require 'autovrsion/version_checkout.rb'
33
+ v = Checkout.new
34
+ v.chk(path)
35
+ when "create"
36
+ require 'autovrsion/create_repository.rb'
37
+ c = CreateRepo.new
38
+ c.create(path)
39
+ when "reset"
40
+ require 'autovrsion/reset.rb'
41
+ r = Reset.new
42
+ r.reset(path)
43
+ when "rewind"
44
+ require 'autovrsion/rewind.rb'
45
+ rw = Rewind.new
46
+ rw.rewindto(path)
47
+ end
48
+
data/lib/autovrsion.rb ADDED
@@ -0,0 +1,14 @@
1
+ begin
2
+ RUBY_VERSION =~ /(\d+.\d+)/
3
+ require "autovrsion/#{$1}/autovrsion"
4
+ rescue LoadError
5
+ require "autovrsion/autovrsion"
6
+ end
7
+ require 'autovrsion/create_repository'
8
+ require 'autovrsion/display_versions'
9
+ require 'autovrsion/version_checkout'
10
+ require 'autovrsion/version'
11
+ require 'autovrsion/rewind'
12
+ require 'autovrsion/reset'
13
+ require 'autovrsion/file_listener'
14
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rugged'
3
+ require 'colored'
4
+ class CreateRepo
5
+ def create(path)
6
+ repository = Rugged::Repository.init_at(path)
7
+ puts "Repository created at directory #{path}".cyan
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rugged'
3
+ require 'colored'
4
+ class DisplayLog
5
+ def disp(path)
6
+ begin
7
+ @repo=Rugged::Repository.new(path)
8
+ ref=@repo.head
9
+ version_count = 0
10
+ walker = Rugged::Walker.new(@repo)
11
+ walker.push(ref.target)
12
+ walker_counter = Rugged::Walker.new(@repo)
13
+ walker_counter.push(ref.target)
14
+ walker_counter.each {version_count += 1}
15
+ walker_counter.reset
16
+
17
+ walker.each { |c|
18
+ puts "-----------------------------"+"version number".yellow + " #{version_count}".cyan + "---------------------------"
19
+ file_count = 1
20
+ puts c.message
21
+ tree1 = c.tree
22
+ tree1.each_blob { |x| puts "(#{file_count}) #{x[:name]}"
23
+ file_count+=1
24
+ }
25
+ version_count-=1 }
26
+ walker.reset
27
+
28
+ rescue Rugged::OSError
29
+ puts "Path does not exist".red
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rugged'
3
+ require 'listen'
4
+ require 'colored'
5
+
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
+ }
17
+
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'
24
+
25
+ if modified.empty? == false then
26
+
27
+
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
35
+
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
46
+
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
52
+ end
53
+
54
+
55
+ end
56
+ listener.start
57
+
58
+ stop = STDIN.gets
59
+ if stop == 'stop'
60
+ puts "Listener stopped"
61
+ listener.stop
62
+
63
+ end
64
+ if stop.to_i == 1
65
+ abort"Listener stopped"
66
+ listener.stop
67
+ end
68
+ #listener.stop
69
+ end
70
+ end
@@ -0,0 +1,12 @@
1
+ require 'git'
2
+ require 'colored'
3
+
4
+ class Reset
5
+ def reset(path)
6
+
7
+ g = Git.open(path)
8
+ g.reset
9
+ g.checkout('master')
10
+ puts "Repository reset to latest version".green
11
+ end
12
+ end
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rugged'
4
+ require 'colored'
5
+
6
+ class Rewind
7
+ def rewindto path
8
+ @repo = Rugged::Repository.new(path)
9
+ ref = @repo.head
10
+ version_count = 0
11
+ walker_counter = Rugged::Walker.new(@repo)
12
+ walker_counter.push(ref.target)
13
+ walker_counter.each {version_count += 1}
14
+ puts "Warning ! You will lose current data if u rewind to previous version".red
15
+ puts "Do you wish to continue ?(1/0)"
16
+ ch = STDIN.gets
17
+ ch.chomp
18
+ puts ch
19
+ if ch.to_i == 1
20
+ puts "Enter Version number"
21
+ version_no = STDIN.gets.to_i
22
+
23
+ #begin
24
+ @repo.index.add_all
25
+ @repo.index.write
26
+ v = version_count - version_no
27
+ @repo.reset("HEAD~#{v}", :hard)
28
+ puts "Rewind Successful to version number".green + " #{version_no}".yellow
29
+ #rescue Rugged::InvalidError
30
+ # puts "Enter Valid Version no"
31
+ # end
32
+ else
33
+ puts "exiting..."
34
+ abort
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,3 @@
1
+ module Autovrsion
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/env ruby
2
+ require 'git'
3
+ require 'rugged'
4
+ require 'colored'
5
+
6
+ class Checkout
7
+ def chk(path)
8
+ @repo = Rugged::Repository.new(path)
9
+ begin
10
+ puts "Enter Version number"
11
+ g = Git.open(path)
12
+ ver = STDIN.gets.to_i
13
+ versh = Array.new()
14
+ version_count = 0
15
+ ref=@repo.head
16
+ walker = Rugged::Walker.new(@repo)
17
+
18
+ walker.push(ref.target)
19
+ walker.each{ |x| version_count +=1}
20
+ walker.reset
21
+
22
+ walker.push(ref.target)
23
+ walker.each { |w|
24
+ #puts w.oid
25
+ versh[version_count] = w.oid
26
+ version_count-=1
27
+ }
28
+ walker.reset
29
+ #g.commit
30
+ #g.branch('update').checkout
31
+ g.checkout(versh[ver])
32
+
33
+
34
+ c = @repo.lookup(versh[ver])
35
+ rescue Rugged::OSError
36
+ puts "Path does not exist".red
37
+ rescue TypeError
38
+ puts "Enter Valid Version number".red
39
+ else
40
+ puts "Directory now at version no." + " #{ver}".yellow
41
+ puts ""
42
+ puts c.message
43
+ puts c.type
44
+ tree1 = c.tree
45
+ tree1.each_blob { |x| puts "#{x[:name]}".cyan }
46
+ end
47
+
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,173 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: autovrsion
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shaunak Pagnis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ruby-git
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: git
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: listen
57
+ requirement: !ruby/object:Gem::Requirement
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
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: colored
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bundler
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '1.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '1.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rake
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A command line that uses Rugged and Listen for automatic versioning of
126
+ files.
127
+ email:
128
+ - shaunak.pagnis@gmail.com
129
+ executables:
130
+ - autovrsion
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - .gitignore
135
+ - Gemfile
136
+ - LICENSE.txt
137
+ - README.md
138
+ - Rakefile
139
+ - autovrsion.gemspec
140
+ - bin/autovrsion
141
+ - lib/autovrsion.rb
142
+ - lib/autovrsion/create_repository.rb
143
+ - lib/autovrsion/display_versions.rb
144
+ - lib/autovrsion/filelistener.rb
145
+ - lib/autovrsion/reset.rb
146
+ - lib/autovrsion/rewind.rb
147
+ - lib/autovrsion/version.rb
148
+ - lib/autovrsion/version_checkout.rb
149
+ homepage: ''
150
+ licenses:
151
+ - MIT
152
+ metadata: {}
153
+ post_install_message:
154
+ rdoc_options: []
155
+ require_paths:
156
+ - lib
157
+ required_ruby_version: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - '>='
160
+ - !ruby/object:Gem::Version
161
+ version: '0'
162
+ required_rubygems_version: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '>='
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ requirements: []
168
+ rubyforge_project:
169
+ rubygems_version: 2.0.3
170
+ signing_key:
171
+ specification_version: 4
172
+ summary: Command line tool for automatic versioning of files in a repository
173
+ test_files: []