bombay 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rubocop.yml +13 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +40 -0
- data/README.md +53 -0
- data/Rakefile +8 -0
- data/bombay.gemspec +29 -0
- data/lib/bombay/version.rb +5 -0
- data/lib/bombay.rb +72 -0
- data/sig/bombay.rbs +4 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6995fb52e822ad155c50c7929a7739b5ec7d33634adf40406f922d2a7c5986a2
|
4
|
+
data.tar.gz: d580dba8b3d38f32c47e7fec855292203d91cc2a15f2f18d2a25e3210f47530f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bdcaa147d64877122dae7fb9b16260a6c54c5cc83ee65f31a8ff0acc66dbed17007c11aa2e6a54be94a44480362c89491aa1a8630a6b79ba2c59d99609d98210
|
7
|
+
data.tar.gz: 7703560c17159d3a2230f01f5f7afed389f528843e68450240b7a977045512fc2787bb58648e7824196c72f17d064cc54f3329a745992a3c858f8dabf2860c25
|
data/.rubocop.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
bombay (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.2)
|
10
|
+
parallel (1.22.1)
|
11
|
+
parser (3.1.2.0)
|
12
|
+
ast (~> 2.4.1)
|
13
|
+
rainbow (3.1.1)
|
14
|
+
rake (13.0.6)
|
15
|
+
regexp_parser (2.4.0)
|
16
|
+
rexml (3.2.5)
|
17
|
+
rubocop (1.29.1)
|
18
|
+
parallel (~> 1.10)
|
19
|
+
parser (>= 3.1.0.0)
|
20
|
+
rainbow (>= 2.2.2, < 4.0)
|
21
|
+
regexp_parser (>= 1.8, < 3.0)
|
22
|
+
rexml (>= 3.2.5, < 4.0)
|
23
|
+
rubocop-ast (>= 1.17.0, < 2.0)
|
24
|
+
ruby-progressbar (~> 1.7)
|
25
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
26
|
+
rubocop-ast (1.18.0)
|
27
|
+
parser (>= 3.1.1.0)
|
28
|
+
ruby-progressbar (1.11.0)
|
29
|
+
unicode-display_width (2.1.0)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
x86_64-linux
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
bombay!
|
36
|
+
rake (~> 13.0)
|
37
|
+
rubocop (~> 1.21)
|
38
|
+
|
39
|
+
BUNDLED WITH
|
40
|
+
2.3.14
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# bombay
|
2
|
+
|
3
|
+
`bombay` sorts the files in your working directory by filetype, and
|
4
|
+
sends them to their appropriate `$XDG_*_DIR`.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
Imagine you had this mess in your `~/Downloads`:
|
9
|
+
|
10
|
+
```bash
|
11
|
+
$ ls -al ~/Downloads
|
12
|
+
.
|
13
|
+
..
|
14
|
+
badger-sock.pdf
|
15
|
+
parallel-muffin.png
|
16
|
+
virtual-monkey.webp
|
17
|
+
student-steak.svg
|
18
|
+
kind-vulture.epub
|
19
|
+
funny-dialect.mp4
|
20
|
+
summer-dance.gif
|
21
|
+
[redacted]
|
22
|
+
```
|
23
|
+
|
24
|
+
Let's tell `bombay` to clean it up:
|
25
|
+
|
26
|
+
```bash
|
27
|
+
~ $ cd Downloads
|
28
|
+
|
29
|
+
~/Downloads $ bombay
|
30
|
+
|
31
|
+
~ $ ls ~/Pictures
|
32
|
+
parallel-muffin.png student-steak.svg virtual-monkey.webp
|
33
|
+
|
34
|
+
~ $ ls ~/Documents
|
35
|
+
badger-sock.pdf kind-vulture.epub
|
36
|
+
|
37
|
+
~ $ ls ~/Videos
|
38
|
+
summer-dance.gif funny-dialect.mp4
|
39
|
+
```
|
40
|
+
|
41
|
+
`bombay` will parse your `$XDG_CONFIG_HOME/user-dirs.dirs` to locate
|
42
|
+
the directories inside of which the files will be organized. Because
|
43
|
+
of this, it is limited to *Linux* for the moment.
|
44
|
+
|
45
|
+
## Installation
|
46
|
+
|
47
|
+
```
|
48
|
+
gem install bombay
|
49
|
+
```
|
50
|
+
|
51
|
+
## Copying
|
52
|
+
|
53
|
+
This software is licensed under the MIT license.
|
data/Rakefile
ADDED
data/bombay.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/bombay/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "bombay"
|
7
|
+
spec.version = Bombay::VERSION
|
8
|
+
spec.authors = ["grtcdr"]
|
9
|
+
spec.email = ["ba.tahaaziz@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = "Organize your $(pwd)"
|
12
|
+
spec.homepage = "https://github.com/grtcdr/bombay"
|
13
|
+
spec.license = "MIT"
|
14
|
+
spec.required_ruby_version = ">= 2.6.0"
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(__dir__) do
|
22
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
23
|
+
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
end
|
data/lib/bombay.rb
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "bombay/version"
|
4
|
+
require "fileutils"
|
5
|
+
|
6
|
+
# This module exposes the methods used to organize your $(pwd).
|
7
|
+
module Bombay
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def pwd_files
|
11
|
+
Dir.entries(FileUtils.pwd)
|
12
|
+
end
|
13
|
+
|
14
|
+
def filter_files(regexp)
|
15
|
+
pwd_files.keep_if { |ext| ext.match(regexp) }
|
16
|
+
end
|
17
|
+
|
18
|
+
def stack(files, dest_dir)
|
19
|
+
src_dir = FileUtils.pwd
|
20
|
+
|
21
|
+
return if src_dir == dest_dir
|
22
|
+
|
23
|
+
return if files.empty?
|
24
|
+
|
25
|
+
FileUtils.mkdir(dest_dir) unless File.directory?(dest_dir)
|
26
|
+
|
27
|
+
files.each { |f| FileUtils.mv(f, dest_dir) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Retrieves the values found inside $XDG_CONFIG_HOME/user-dirs.dirs.
|
32
|
+
class Directories
|
33
|
+
attr_reader :pictures, :videos, :documents
|
34
|
+
|
35
|
+
def config_directory
|
36
|
+
ENV["XDG_CONFIG_HOME"] || File.join(Dir.home, ".config")
|
37
|
+
end
|
38
|
+
|
39
|
+
def user_dirs
|
40
|
+
File.join(config_directory, "user-dirs.dirs")
|
41
|
+
end
|
42
|
+
|
43
|
+
def parse_entry(line)
|
44
|
+
entry = line.split("=")
|
45
|
+
key = entry.first
|
46
|
+
value = entry.last.tr('"', "").gsub("$HOME", Dir.home).strip
|
47
|
+
[key, value]
|
48
|
+
end
|
49
|
+
|
50
|
+
def initialize
|
51
|
+
File.open(user_dirs).each do |line|
|
52
|
+
xdg_dir = parse_entry(line)
|
53
|
+
case xdg_dir.first
|
54
|
+
when "XDG_DOCUMENTS_DIR" then @documents = xdg_dir.last
|
55
|
+
when "XDG_PICTURES_DIR" then @pictures = xdg_dir.last
|
56
|
+
when "XDG_VIDEOS_DIR" then @videos = xdg_dir.last
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Defines the regular expressions used by bombay to
|
63
|
+
# determine which folder a particular file belongs to.
|
64
|
+
class Filetypes
|
65
|
+
attr_reader :pictures, :videos, :documents
|
66
|
+
|
67
|
+
def initialize
|
68
|
+
@pictures = /\.(ico|svg|png|jpe?g|webp|avif)$/
|
69
|
+
@videos = /\.(gif|mp4|weba|mpeg)$/
|
70
|
+
@documents = /\.(pdf|epub|xml|txt|x?html|pptx?|docx?|rtf|md|org)$/
|
71
|
+
end
|
72
|
+
end
|
data/sig/bombay.rbs
ADDED
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bombay
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- grtcdr
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-05-21 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- ba.tahaaziz@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".rubocop.yml"
|
21
|
+
- Gemfile
|
22
|
+
- Gemfile.lock
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- bombay.gemspec
|
26
|
+
- lib/bombay.rb
|
27
|
+
- lib/bombay/version.rb
|
28
|
+
- sig/bombay.rbs
|
29
|
+
homepage: https://github.com/grtcdr/bombay
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata:
|
33
|
+
homepage_uri: https://github.com/grtcdr/bombay
|
34
|
+
source_code_uri: https://github.com/grtcdr/bombay
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.6.0
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.3.8
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Organize your $(pwd)
|
54
|
+
test_files: []
|