fos 1.0.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +10 -0
- data/README.md +49 -5
- data/Rakefile +6 -0
- data/bin/fos +1 -1
- data/fos.gemspec +5 -3
- data/lib/fos/version.rb +1 -1
- data/lib/fos.rb +125 -33
- metadata +29 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 1bad468a812602dce0121eda26a1dcf3ce5080d0
|
4
|
+
data.tar.gz: ebc6523c478fb9cb951fff9f966d1eb338da5418
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ecadbddef56a2527dedcd9b3364a44bd5132276bee84c630c6863fa1171ed3f0dc9b95ca82557dff295c6d1c49104603f347d141dfc86edd25ebb36cf9a61680
|
7
|
+
data.tar.gz: b155237029ae2f54a2395ecd6460beb695d139eea9ceb135da4f019d4464bfbe3e6894df1d33c3827806b35af571b26f69e4121ebd2796d1186afca4f49929d0
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,19 +1,63 @@
|
|
1
1
|
# fos
|
2
2
|
|
3
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/fos.svg)](http://badge.fury.io/rb/fos) [![Build Status](https://travis-ci.org/scottyg/fos.svg?branch=master)](https://travis-ci.org/scottyg/fos)
|
4
|
+
|
5
|
+
Fos is a folder archive tool for Linux or Mac. By default Fos archives ~/Desktop and ~/Downloads, but can easily archive any folder.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
|
9
|
+
Fos is a Ruby Gem and can be easily installed with the command `gem install fos`.
|
10
|
+
|
11
|
+
If you do not yet have [ruby installed](https://www.ruby-lang.org/en/installation/) you will need to do that first.
|
8
12
|
|
9
13
|
## Usage
|
10
14
|
|
11
|
-
|
15
|
+
Basic usage is `fos` and archives ~/Desktop and ~/Downloads.
|
16
|
+
|
17
|
+
`fos -h` shows you options.
|
18
|
+
|
19
|
+
```
|
20
|
+
Options
|
21
|
+
-p, --path PATH
|
22
|
+
-n, --name NAME
|
23
|
+
-z, --zip
|
24
|
+
-h, --help
|
25
|
+
-v, --version
|
26
|
+
```
|
27
|
+
|
28
|
+
###Examples:
|
29
|
+
|
30
|
+
`fos -p /path/to/folder`
|
31
|
+
|
32
|
+
Archives the contents of /path/to/folder into /path/to/folder/archive
|
33
|
+
|
34
|
+
`fos -n new_name`
|
35
|
+
|
36
|
+
Archives the contents of ~/Desktop and ~/Downloads into ~/Desktop/new_name and ~/Downloads/new_name respectively.
|
37
|
+
|
38
|
+
`fos -z`
|
39
|
+
|
40
|
+
Archives and zips the contents of ~/Desktop and ~/Downloads into ~/Desktop/archive.zip and ~/Downloads/archive.zip respectively.
|
41
|
+
|
42
|
+
`fos -p /path/to/folder -n new_name -z`
|
43
|
+
|
44
|
+
Archives and zips the contents of /path/to/folder into /path/to/folder/new_name.zip.
|
45
|
+
|
46
|
+
###Config
|
47
|
+
|
48
|
+
Config file located at ~/.fos/config.yml
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
First time installing for dev on your system run `bundle install`
|
53
|
+
|
54
|
+
Then run `rake install` to build Fos from source
|
12
55
|
|
13
56
|
## Roadmap
|
14
57
|
|
15
|
-
- Archive specific
|
16
|
-
-
|
58
|
+
- Archive specific names[testing]
|
59
|
+
- Archive specific paths[testing]
|
60
|
+
- Zip archive[testing]
|
17
61
|
|
18
62
|
## Contributing
|
19
63
|
|
data/Rakefile
CHANGED
data/bin/fos
CHANGED
data/fos.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Fos::VERSION
|
9
9
|
spec.authors = ["Scott Gordon"]
|
10
10
|
spec.email = ["me@scottyg.net"]
|
11
|
-
spec.summary = %q{
|
12
|
-
spec.description = %q{
|
11
|
+
spec.summary = %q{a folder archive tool for Linux or Mac}
|
12
|
+
spec.description = %q{a folder archive tool for Linux or Mac}
|
13
13
|
spec.homepage = "http://scottyg.github.io/fos/"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,4 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
22
22
|
spec.add_development_dependency "rake"
|
23
|
-
|
23
|
+
spec.add_development_dependency "colorize", "~> 0.7.3"
|
24
|
+
|
25
|
+
end
|
data/lib/fos/version.rb
CHANGED
data/lib/fos.rb
CHANGED
@@ -1,50 +1,142 @@
|
|
1
|
+
# Full Of Shit
|
1
2
|
require "fos/version"
|
3
|
+
require 'optparse'
|
4
|
+
require 'colorize'
|
5
|
+
require 'yaml'
|
2
6
|
|
3
7
|
module Fos
|
8
|
+
|
4
9
|
class Action
|
5
|
-
def
|
10
|
+
def archive
|
11
|
+
|
12
|
+
options = {}
|
6
13
|
|
7
|
-
#
|
8
|
-
|
9
|
-
|
14
|
+
# Option parser 'optparse'
|
15
|
+
opt_parser = OptionParser.new do |opt|
|
16
|
+
opt.banner = "Fos is a folder archive tool for Linux or Mac."
|
17
|
+
opt.separator ""
|
18
|
+
opt.separator "Archives ~/Desktop and ~/Downloads by default"
|
19
|
+
opt.separator ""
|
20
|
+
opt.separator "Usage: fos [OPTIONS]"
|
21
|
+
opt.separator ""
|
22
|
+
opt.separator "Options"
|
23
|
+
opt.on("-p","--path PATH","Input path(s), BE CAREFUL WITH THIS") do |path|
|
24
|
+
options[:path] = path
|
25
|
+
end
|
26
|
+
opt.on("-n","--name NAME","Output name, default is archive") do |name|
|
27
|
+
options[:name] = name
|
28
|
+
end
|
29
|
+
opt.on("-z","--zip","Output as zip file, default is false") do |zip|
|
30
|
+
options[:zip] = zip
|
31
|
+
end
|
32
|
+
opt.on("-h","--help","help") do |help|
|
33
|
+
puts opt_parser
|
34
|
+
options[:help] = help
|
35
|
+
end
|
36
|
+
opt.on("-v","--version","version") do |version|
|
37
|
+
puts Fos::VERSION
|
38
|
+
options[:version] = version
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
begin opt_parser.parse! ARGV
|
43
|
+
rescue OptionParser::InvalidOption => e
|
44
|
+
puts e
|
45
|
+
puts "Try fos -h"
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
user_path = File.expand_path('~')
|
50
|
+
|
51
|
+
# Config file
|
52
|
+
if !File.directory?("#{user_path}/.fos")
|
53
|
+
`mkdir #{user_path}/.fos`
|
54
|
+
`touch #{user_path}/.fos/config.yml`
|
55
|
+
open("#{user_path}/.fos/config.yml", 'w') { |f|
|
56
|
+
f.puts "name: archive"
|
57
|
+
f.puts "paths: [#{user_path}/Desktop, #{user_path}/Downloads]"
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
hash = YAML.load(File.read("#{user_path}/.fos/config.yml"))
|
62
|
+
|
63
|
+
# Option variables
|
64
|
+
path = options[:path] || nil
|
65
|
+
archive_name = options[:name] || hash['name']
|
66
|
+
zip = options[:zip] || false
|
67
|
+
version = options[:version] || false
|
68
|
+
help = options[:help] || false
|
69
|
+
|
70
|
+
folders = hash['paths']
|
10
71
|
today = Time.now.strftime("%B %e %Y").gsub(' ', '_').gsub(/:.*/, '')
|
11
|
-
|
72
|
+
|
73
|
+
# Look for commands
|
74
|
+
case ARGV[0]
|
75
|
+
when "shit"
|
76
|
+
puts "I can clean that up for you"
|
77
|
+
else
|
78
|
+
do_archive = true
|
79
|
+
end
|
12
80
|
|
13
|
-
#
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
81
|
+
# Check if help or version option, Disable archive
|
82
|
+
if help == true || version == true
|
83
|
+
do_archive = false
|
84
|
+
end
|
85
|
+
|
86
|
+
# Set new path if option is set
|
87
|
+
if !path.nil?
|
88
|
+
folders = path.split(',')
|
89
|
+
folders.each do |f|
|
90
|
+
f.sub! "~", "#{user_path}"
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
if do_archive == true
|
95
|
+
# Do for each folder
|
96
|
+
folders.each do |current_path|
|
18
97
|
|
19
|
-
|
20
|
-
|
98
|
+
# Get files
|
99
|
+
current_files = Dir.entries(current_path)
|
21
100
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
101
|
+
# Create folders
|
102
|
+
if !File.directory?("#{current_path}/#{archive_name}")
|
103
|
+
`mkdir #{current_path}/#{archive_name}`
|
104
|
+
puts "[ " + "Creating".yellow + ": "+"#{current_path}/#{archive_name}"+" ]"
|
105
|
+
end
|
106
|
+
if !File.directory?("#{current_path}/#{archive_name}/#{today}")
|
107
|
+
`mkdir #{current_path}/#{archive_name}/#{today}`
|
108
|
+
puts "[ " + "Creating".yellow + ": "+"#{current_path}/#{archive_name}/#{today}"+" ]"
|
109
|
+
end
|
29
110
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
111
|
+
# Remove system folders and our new folder
|
112
|
+
current_files.delete_if{|x| (x =~ /^\./) == 0 }
|
113
|
+
current_files.delete_if{|x| x == "#{archive_name}"}
|
114
|
+
current_files.delete_if{|x| (x =~ /Macintosh/) == 0}
|
34
115
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
# Do The Moving
|
39
|
-
current_files.each do |filename|
|
40
|
-
`mv #{current_path}/#{filename} #{current_path}/#{folder}/#{today}`
|
41
|
-
end
|
116
|
+
# Clean file names
|
117
|
+
current_files = current_files.map{|x| x.gsub(" ", '\ ').gsub("(", '\(').gsub(")", '\)')}
|
42
118
|
|
43
|
-
|
44
|
-
|
119
|
+
# Do the moving
|
120
|
+
current_files.each do |filename|
|
121
|
+
`mv #{current_path}/#{filename} #{current_path}/#{archive_name}/#{today}`
|
122
|
+
puts "[ " + "Archiving".yellow + ": "+"#{current_path}/#{filename}"+" ]"
|
123
|
+
end
|
45
124
|
|
125
|
+
# Do zip if option is set
|
126
|
+
if zip == true
|
127
|
+
puts "[ " + "Zipping".yellow + ": #{current_path} ]"
|
128
|
+
`zip -r #{current_path}/#{archive_name}.zip #{current_path}/#{archive_name}`
|
129
|
+
# Add extension name for finishing message
|
130
|
+
tmp_archive_name = archive_name + ".zip"
|
131
|
+
else
|
132
|
+
tmp_archive_name = archive_name
|
133
|
+
end
|
134
|
+
|
135
|
+
# Finished
|
136
|
+
puts "[ " + "Archived".colorize(:green) + ": "+"#{current_path} "+"into"+" #{current_path}/#{tmp_archive_name}"+" ]"
|
137
|
+
|
138
|
+
end
|
46
139
|
end
|
47
|
-
|
48
140
|
end
|
49
141
|
end
|
50
142
|
end
|
metadata
CHANGED
@@ -1,49 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fos
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Scott Gordon
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '1.6'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '1.6'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rake
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.7.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.7.3
|
55
|
+
description: a folder archive tool for Linux or Mac
|
47
56
|
email:
|
48
57
|
- me@scottyg.net
|
49
58
|
executables:
|
@@ -51,7 +60,8 @@ executables:
|
|
51
60
|
extensions: []
|
52
61
|
extra_rdoc_files: []
|
53
62
|
files:
|
54
|
-
- .gitignore
|
63
|
+
- ".gitignore"
|
64
|
+
- ".travis.yml"
|
55
65
|
- Gemfile
|
56
66
|
- LICENSE
|
57
67
|
- README.md
|
@@ -63,26 +73,25 @@ files:
|
|
63
73
|
homepage: http://scottyg.github.io/fos/
|
64
74
|
licenses:
|
65
75
|
- MIT
|
76
|
+
metadata: {}
|
66
77
|
post_install_message:
|
67
78
|
rdoc_options: []
|
68
79
|
require_paths:
|
69
80
|
- lib
|
70
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
82
|
requirements:
|
73
|
-
- -
|
83
|
+
- - ">="
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '0'
|
76
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
87
|
requirements:
|
79
|
-
- -
|
88
|
+
- - ">="
|
80
89
|
- !ruby/object:Gem::Version
|
81
90
|
version: '0'
|
82
91
|
requirements: []
|
83
92
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.2.2
|
85
94
|
signing_key:
|
86
|
-
specification_version:
|
87
|
-
summary:
|
95
|
+
specification_version: 4
|
96
|
+
summary: a folder archive tool for Linux or Mac
|
88
97
|
test_files: []
|