bombay 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +22 -0
- data/README.md +57 -0
- data/bin/bombay +1 -1
- data/bombay.gemspec +5 -3
- data/lib/bombay/string.rb +14 -0
- data/lib/bombay/version.rb +1 -1
- data/lib/bombay.rb +36 -15
- metadata +20 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5dab1ffb202a5f13e7b80ef01279739f30c27ce1196182678cf0b462da3817a
|
4
|
+
data.tar.gz: e2edca01c328e65ad217dce1b146f74b06c1be38ec4a89eb5dd02a4f1720c3db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e44c38362c6aeac3e4299cf31e9f6363ee1b4aaeb9e05b8f3d1b2887986e15a6e7f4578a2235300d0f4d0c43cbc6c55bc24033f52064b628d253288441c77138
|
7
|
+
data.tar.gz: b8c6675cd4e6913bd6b542d8817cce600c50d912834d94df95d942fa59eeaa79cf016f757d7aac1e43b93f17825ad16a0119e42ad05d537151c77edbdac9b00b
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2022 Aziz Ben Ali
|
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,57 @@
|
|
1
|
+
# bombay
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/bombay.svg)](https://badge.fury.io/rb/bombay)
|
4
|
+
|
5
|
+
`bombay` sorts the files in your working directory by filetype, and
|
6
|
+
sends them to their appropriate `$XDG_*_DIR`.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
```
|
11
|
+
gem install bombay
|
12
|
+
```
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
Imagine you had this mess in your `~/Downloads`:
|
17
|
+
|
18
|
+
```bash
|
19
|
+
$ ls -al ~/Downloads
|
20
|
+
.
|
21
|
+
..
|
22
|
+
badger-sock.pdf
|
23
|
+
parallel-muffin.png
|
24
|
+
virtual-monkey.webp
|
25
|
+
student-steak.svg
|
26
|
+
kind-vulture.epub
|
27
|
+
funny-dialect.mp4
|
28
|
+
summer-dance.gif
|
29
|
+
[redacted]
|
30
|
+
```
|
31
|
+
|
32
|
+
Let's tell `bombay` to clean it up:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
~ $ cd Downloads
|
36
|
+
|
37
|
+
~/Downloads $ bombay
|
38
|
+
|
39
|
+
~ $ ls ~/Pictures
|
40
|
+
parallel-muffin.png student-steak.svg virtual-monkey.webp
|
41
|
+
|
42
|
+
~ $ ls ~/Documents
|
43
|
+
badger-sock.pdf kind-vulture.epub
|
44
|
+
|
45
|
+
~ $ ls ~/Videos
|
46
|
+
summer-dance.gif funny-dialect.mp4
|
47
|
+
```
|
48
|
+
|
49
|
+
## Platform support
|
50
|
+
|
51
|
+
`bombay` was initially built for Linux with support for XDG user
|
52
|
+
directories, but has been extended to support macOS, although that remains to
|
53
|
+
be tested. The program will not run on any other platforms.
|
54
|
+
|
55
|
+
## Copying
|
56
|
+
|
57
|
+
This software is licensed under the MIT license.
|
data/bin/bombay
CHANGED
data/bombay.gemspec
CHANGED
@@ -5,8 +5,8 @@ require_relative "lib/bombay/version"
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "bombay"
|
7
7
|
spec.version = Bombay::VERSION
|
8
|
-
spec.
|
9
|
-
spec.email =
|
8
|
+
spec.author = "grtcdr"
|
9
|
+
spec.email = "ba.tahaaziz@gmail.com"
|
10
10
|
|
11
11
|
spec.summary = "Organize your $(pwd)."
|
12
12
|
spec.homepage = "https://rubygems.org/gems/bombay"
|
@@ -16,12 +16,14 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
17
|
spec.metadata["source_code_uri"] = "https://github.com/grtcdr/bombay"
|
18
18
|
|
19
|
+
spec.add_runtime_dependency 'os', '~> 0.9.6'
|
20
|
+
|
19
21
|
spec.files = Dir.chdir(__dir__) do
|
20
22
|
`git ls-files -z`.split("\x0").reject do |f|
|
21
23
|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
26
|
+
|
25
27
|
spec.bindir = "bin"
|
26
28
|
spec.executables = ["bombay"]
|
27
29
|
spec.require_paths = ["lib"]
|
data/lib/bombay/version.rb
CHANGED
data/lib/bombay.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative "bombay/version"
|
4
|
+
require_relative "bombay/string"
|
5
|
+
|
4
6
|
require "fileutils"
|
7
|
+
require "os"
|
5
8
|
|
6
9
|
# This module exposes the methods used to organize your $(pwd).
|
7
10
|
module Bombay
|
@@ -19,7 +22,6 @@ module Bombay
|
|
19
22
|
src_dir = FileUtils.pwd
|
20
23
|
|
21
24
|
return if src_dir == dest_dir
|
22
|
-
|
23
25
|
return if files.empty?
|
24
26
|
|
25
27
|
FileUtils.mkdir(dest_dir) unless File.directory?(dest_dir)
|
@@ -36,26 +38,45 @@ class Directories
|
|
36
38
|
ENV["XDG_CONFIG_HOME"] || File.join(Dir.home, ".config")
|
37
39
|
end
|
38
40
|
|
39
|
-
def
|
41
|
+
def xdg_directory_type(dir)
|
42
|
+
dir.delete_prefix("XDG_").delete_suffix("_DIR")
|
43
|
+
end
|
44
|
+
|
45
|
+
def user_dirs_file
|
40
46
|
File.join(config_directory, "user-dirs.dirs")
|
41
47
|
end
|
42
48
|
|
43
|
-
def
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
49
|
+
def xdg_directories
|
50
|
+
dirs = {}
|
51
|
+
File.open(user_dirs_file).each do |line|
|
52
|
+
entry = line.split("=")
|
53
|
+
key = xdg_directory_type(entry.first)
|
54
|
+
value = entry.last.unquote.expand.strip
|
55
|
+
dirs.store(key, value)
|
56
|
+
end
|
57
|
+
dirs
|
58
|
+
end
|
59
|
+
|
60
|
+
def macos_directories
|
61
|
+
dirs = {}
|
62
|
+
dirs.store("DOCUMENTS", File.join(Dir.home, "Documents"))
|
63
|
+
dirs.store("PICTURES", File.join(Dir.home, "Pictures"))
|
64
|
+
dirs.store("VIDEOS", File.join(Dir.home, "Movies"))
|
65
|
+
dirs
|
48
66
|
end
|
49
67
|
|
50
68
|
def initialize
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
69
|
+
dirs = if OS.linux?
|
70
|
+
xdg_directories
|
71
|
+
elsif OS.macos?
|
72
|
+
macos_directories
|
73
|
+
else
|
74
|
+
abort("Unsupported platform.")
|
75
|
+
end
|
76
|
+
|
77
|
+
@documents = dirs["DOCUMENTS"]
|
78
|
+
@pictures = dirs["PICTURES"]
|
79
|
+
@videos = dirs["VIDEOS"]
|
59
80
|
end
|
60
81
|
end
|
61
82
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bombay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- grtcdr
|
@@ -9,10 +9,23 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2022-05-21 00:00:00.000000000 Z
|
12
|
-
dependencies:
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: os
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.9.6
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.9.6
|
13
27
|
description:
|
14
|
-
email:
|
15
|
-
- ba.tahaaziz@gmail.com
|
28
|
+
email: ba.tahaaziz@gmail.com
|
16
29
|
executables:
|
17
30
|
- bombay
|
18
31
|
extensions: []
|
@@ -21,10 +34,13 @@ files:
|
|
21
34
|
- ".rubocop.yml"
|
22
35
|
- Gemfile
|
23
36
|
- Gemfile.lock
|
37
|
+
- LICENSE
|
38
|
+
- README.md
|
24
39
|
- Rakefile
|
25
40
|
- bin/bombay
|
26
41
|
- bombay.gemspec
|
27
42
|
- lib/bombay.rb
|
43
|
+
- lib/bombay/string.rb
|
28
44
|
- lib/bombay/version.rb
|
29
45
|
- sig/bombay.rbs
|
30
46
|
homepage: https://rubygems.org/gems/bombay
|