backenup 0.0.5
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 +7 -0
- data/lib/backenup.rb +75 -0
- metadata +57 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 456279ce8e8e92a237d85173c53d440949777a8a
|
4
|
+
data.tar.gz: 578f5f87e338a46bebc71bde687cc88b51de2a25
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 844e36e3ca2e9b2b1618475c2003b70dd572403c3718126d9bbe0d926660030a202c20b34bf5ffcd173f2e048440e3bc6cfeecac3c2edded69bedfaf00a8d5f7
|
7
|
+
data.tar.gz: b9c8d38398169c65ef6464e5cabb828d53a39cf5e6cae2d84510030b4f7a2bd61bb02791e30703a3d9356603cdbb1e159155fb3937d6a1c4cb6ac1ac486efdcb
|
data/lib/backenup.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
|
2
|
+
require 'set'
|
3
|
+
require 'grit'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Backenup
|
7
|
+
|
8
|
+
class Storage
|
9
|
+
attr_reader :base_path
|
10
|
+
|
11
|
+
def initialize(base_path)
|
12
|
+
@base_path = File.absolute_path(base_path)
|
13
|
+
|
14
|
+
@repo = File.exists?(base_path) ? Grit::Repo.new(base_path) : Grit::Repo.init(base_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def storage_path
|
18
|
+
File.join(self.base_path, "storage")
|
19
|
+
end
|
20
|
+
|
21
|
+
# Convenient way to see the contents of the storage
|
22
|
+
def ls(path = ".")
|
23
|
+
make_storage_path_exist
|
24
|
+
Dir.entries(File.join(self.storage_path, path)).reject{|f| [".", ".."].include? f}
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
def cp(src, dest = nil)
|
29
|
+
if dest.nil?
|
30
|
+
dest = File.basename(src)
|
31
|
+
end
|
32
|
+
|
33
|
+
dest = File.join(self.storage_path, dest)
|
34
|
+
|
35
|
+
make_storage_path_exist
|
36
|
+
FileUtils.cp_r src, dest
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
# Clears the current contents of the storage.
|
41
|
+
def clear
|
42
|
+
self.ls.each do |f|
|
43
|
+
FileUtils.rm_rf File.join(self.storage_path, f)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
def commit(message = nil)
|
49
|
+
if message.nil?
|
50
|
+
files = self.ls
|
51
|
+
if files.any?
|
52
|
+
message = "Storage:\n#{files.map{|f| ' ' + f}.join("\n") }"
|
53
|
+
else
|
54
|
+
message = "[No files in storage]"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
message = self.ls.join("\n") if message.nil?
|
58
|
+
|
59
|
+
Dir.chdir self.base_path do
|
60
|
+
@repo.add "." # Add all new / modified files
|
61
|
+
@repo.commit_all message # This handles any file that was deleted
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
def make_storage_path_exist
|
69
|
+
Dir.mkdir self.storage_path unless File.exists?(self.storage_path)
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
metadata
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: backenup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brian Lauber
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-04-11 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: grit
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.5.0
|
27
|
+
description: File backups via Git
|
28
|
+
email: constructible.truth@gmail.com
|
29
|
+
executables: []
|
30
|
+
extensions: []
|
31
|
+
extra_rdoc_files: []
|
32
|
+
files:
|
33
|
+
- lib/backenup.rb
|
34
|
+
homepage: https://briandamaged.org/
|
35
|
+
licenses: []
|
36
|
+
metadata: {}
|
37
|
+
post_install_message:
|
38
|
+
rdoc_options: []
|
39
|
+
require_paths:
|
40
|
+
- lib
|
41
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
requirements: []
|
52
|
+
rubyforge_project:
|
53
|
+
rubygems_version: 2.0.3
|
54
|
+
signing_key:
|
55
|
+
specification_version: 4
|
56
|
+
summary: File backups via Git
|
57
|
+
test_files: []
|