kitkat 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -0
- data/CHANGELOG.md +7 -0
- data/README.md +18 -6
- data/lib/kitkat/database.rb +8 -0
- data/lib/kitkat/file_info.rb +1 -0
- data/lib/kitkat/reader.rb +2 -0
- data/lib/kitkat/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4d628ae53c4814952a15decd1ad945e63582df6a0021b50a642e21aeae3ddfd2
|
4
|
+
data.tar.gz: 67d0781bb56c93cc7c1d3476a0d19dabb2df09140c831ae30b83b7f99af970c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e13624e8469b16e2286be815c37340b5402d0697023831f56f32256c66aae9480b5b0a920df1298016eb72f3065ba1f13b1984c3b05402f078bf54736b0eb59d
|
7
|
+
data.tar.gz: cc72cb9c18db99192df99f5572d5c229c1c6eaf50372b88cf80421d12bf9e032449799d4aa299810f4070b8144a9e50a54e594af073d42c165e18abe0b022d25
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -2,9 +2,19 @@
|
|
2
2
|
|
3
3
|
#### File/Metadata Database Populator
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/kitkat.svg)](https://badge.fury.io/rb/kitkat) [![Ruby Gem CI](https://github.com/mattruggio/kitkat/actions/workflows/rubygem.yml/badge.svg)](https://github.com/mattruggio/kitkat/actions/workflows/rubygem.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/kitkat.svg)](https://badge.fury.io/rb/kitkat) [![Ruby Gem CI](https://github.com/mattruggio/kitkat/actions/workflows/rubygem.yml/badge.svg)](https://github.com/mattruggio/kitkat/actions/workflows/rubygem.yml) [![Maintainability](https://api.codeclimate.com/v1/badges/7d9a8642cf5bd88a550d/maintainability)](https://codeclimate.com/github/mattruggio/kitkat/maintainability) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
|
6
6
|
|
7
|
-
I had a need to recursively enumerate a directory and load the paths, and some metadata about the files, into a SQLite file.
|
7
|
+
I had a need to recursively enumerate a directory and load the paths, and some metadata about the files, into a SQLite file. Currently, the following metadata is stored in the SQLite file
|
8
|
+
|
9
|
+
field | description
|
10
|
+
----- | ------------
|
11
|
+
path | path of the file (with the root removed)
|
12
|
+
mime_type | left-side mime type (i.e. image)
|
13
|
+
mime_subtype | right-side mime type (i.e. jpeg)
|
14
|
+
bytesize | size in bytes of the file.
|
15
|
+
last_modified_at | last time the file was reported to be modified by the filesystem.
|
16
|
+
digest | SHA256 hash of the file's contents.
|
17
|
+
created_at | UTC date and time when the record was inserted into the DB.
|
8
18
|
|
9
19
|
## Installation
|
10
20
|
|
@@ -24,15 +34,17 @@ bundle add kitkat
|
|
24
34
|
|
25
35
|
### Executable
|
26
36
|
|
27
|
-
This library ships with an executable: `
|
37
|
+
This library ships with an executable: `kitkat`. Simply run this from your shell:
|
28
38
|
|
29
39
|
````zsh
|
30
|
-
|
40
|
+
bundle exec kitkat <path> <database>
|
31
41
|
````
|
32
42
|
|
33
|
-
For Example: `
|
43
|
+
For Example: `bundle exec kitkat some_directory some_directory_contents.db`. This will recursively scan the relative path at: `some_directory` and list all its contents in a SQLite database file relatively located at: `some_directory_contents.db`.
|
44
|
+
|
45
|
+
Notes:
|
34
46
|
|
35
|
-
|
47
|
+
* The database positional argument is optional. If it is not supplied then it will default to: `kitkat.db`
|
36
48
|
|
37
49
|
### Ruby API
|
38
50
|
|
data/lib/kitkat/database.rb
CHANGED
@@ -4,6 +4,8 @@ module Kitkat
|
|
4
4
|
# Database-level operations.
|
5
5
|
class Database
|
6
6
|
def initialize(path)
|
7
|
+
ensure_dir_exists(path)
|
8
|
+
|
7
9
|
@connection = SQLite3::Database.new(path)
|
8
10
|
|
9
11
|
load_schema
|
@@ -30,6 +32,12 @@ module Kitkat
|
|
30
32
|
|
31
33
|
attr_reader :connection
|
32
34
|
|
35
|
+
def ensure_dir_exists(path)
|
36
|
+
dir = File.dirname(path)
|
37
|
+
|
38
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
39
|
+
end
|
40
|
+
|
33
41
|
def sql_statement
|
34
42
|
'INSERT OR IGNORE INTO files VALUES (?, ?, ?, ?, ?, ?, ?)'
|
35
43
|
end
|
data/lib/kitkat/file_info.rb
CHANGED
data/lib/kitkat/reader.rb
CHANGED
data/lib/kitkat/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kitkat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sqlite3
|
@@ -178,6 +178,7 @@ files:
|
|
178
178
|
- ".gitignore"
|
179
179
|
- ".rubocop.yml"
|
180
180
|
- ".tool-versions"
|
181
|
+
- CHANGELOG.md
|
181
182
|
- CODE_OF_CONDUCT.md
|
182
183
|
- Gemfile
|
183
184
|
- Guardfile
|