kitkat 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/rubygem.yml +3 -5
- data/.rubocop.yml +11 -1
- data/.tool-versions +1 -1
- data/CHANGELOG.md +11 -0
- data/README.md +18 -6
- data/exe/kitkat +1 -1
- data/kitkat.gemspec +1 -1
- data/lib/kitkat/database.rb +8 -0
- data/lib/kitkat/file_info.rb +1 -0
- data/lib/kitkat/reader.rb +7 -5
- data/lib/kitkat/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17654438fa4ef7a3ed4c7050ccccfa152d315a233a3776e3ddc64a234f8f0d7b
|
4
|
+
data.tar.gz: 7a9d327cc6cc8cf6dbdaff076f4b1e0d3c6cc39822a8aeeb4d95b2db1f43aa0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa9081036b32b79d977c32416db7ab733007cd6d55bb0ff2f898852a065a57cf556d579399dc0047083f6c2b29ae4e54ba4a56f6cb397e42b0d9ab9f339585fb
|
7
|
+
data.tar.gz: f9af84a84eebd3b1f7723b7fe3428ebb1eea95bf58cfb6677af8a70d0228ee0b64b93ef677e520ceeeb38e7fcb96168fda691e4fd0d165b706f7615ab7334419
|
@@ -11,15 +11,13 @@ jobs:
|
|
11
11
|
runs-on: ubuntu-latest
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
|
-
ruby-version: ['
|
14
|
+
ruby-version: ['3.2.1']
|
15
15
|
|
16
16
|
steps:
|
17
17
|
- uses: actions/checkout@v2
|
18
|
+
# https://github.com/ruby/setup-ruby#versioning
|
18
19
|
- name: Set up Ruby
|
19
|
-
|
20
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
21
|
-
# uses: ruby/setup-ruby@v1
|
22
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
20
|
+
uses: ruby/setup-ruby@v1
|
23
21
|
with:
|
24
22
|
ruby-version: ${{ matrix.ruby-version }}
|
25
23
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
data/.rubocop.yml
CHANGED
@@ -1,9 +1,19 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rake
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
NewCops: enable
|
3
|
-
TargetRubyVersion: 2
|
7
|
+
TargetRubyVersion: 3.2
|
4
8
|
Exclude:
|
5
9
|
- bin/*
|
6
10
|
- vendor/bundle/**/*
|
7
11
|
|
12
|
+
Gemspec/DevelopmentDependencies:
|
13
|
+
EnforcedStyle: gemspec
|
14
|
+
|
8
15
|
Metrics/MethodLength:
|
9
16
|
Max: 20
|
17
|
+
|
18
|
+
RSpec/ExampleLength:
|
19
|
+
Max: 10
|
data/.tool-versions
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby 2.
|
1
|
+
ruby 3.2.1
|
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/exe/kitkat
CHANGED
data/kitkat.gemspec
CHANGED
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)
|
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
@@ -5,6 +5,8 @@ require_relative 'file_info'
|
|
5
5
|
module Kitkat
|
6
6
|
# Directory operations.
|
7
7
|
class Reader
|
8
|
+
include Enumerable
|
9
|
+
|
8
10
|
attr_reader :root
|
9
11
|
|
10
12
|
def initialize(root)
|
@@ -13,21 +15,21 @@ module Kitkat
|
|
13
15
|
freeze
|
14
16
|
end
|
15
17
|
|
16
|
-
def each(&
|
18
|
+
def each(&)
|
17
19
|
return enum_for(:each) unless block_given?
|
18
20
|
|
19
|
-
traverse(root, &
|
21
|
+
traverse(root, &)
|
20
22
|
|
21
23
|
self
|
22
24
|
end
|
23
25
|
|
24
26
|
private
|
25
27
|
|
26
|
-
def traverse(dir, &
|
28
|
+
def traverse(dir, &)
|
27
29
|
Dir[File.join(dir, '*')].each do |path|
|
28
|
-
yield FileInfo.new(path, root:
|
30
|
+
yield FileInfo.new(path, root:)
|
29
31
|
|
30
|
-
traverse(path, &
|
32
|
+
traverse(path, &) if File.directory?(path)
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
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: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-12 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
|
@@ -216,14 +217,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
216
217
|
requirements:
|
217
218
|
- - ">="
|
218
219
|
- !ruby/object:Gem::Version
|
219
|
-
version:
|
220
|
+
version: 3.2.1
|
220
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
222
|
requirements:
|
222
223
|
- - ">="
|
223
224
|
- !ruby/object:Gem::Version
|
224
225
|
version: '0'
|
225
226
|
requirements: []
|
226
|
-
rubygems_version: 3.
|
227
|
+
rubygems_version: 3.4.6
|
227
228
|
signing_key:
|
228
229
|
specification_version: 4
|
229
230
|
summary: File/Metadata Database Populator
|