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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbdbb6ec1c0293541eed2e6d3227dd23157f6de455499df55d5bc32f6044c025
4
- data.tar.gz: 2c02ad2202530ef1d4d2201711bc4dcf18ef1cfeb3543d3b54756b5238cc3be3
3
+ metadata.gz: 4d628ae53c4814952a15decd1ad945e63582df6a0021b50a642e21aeae3ddfd2
4
+ data.tar.gz: 67d0781bb56c93cc7c1d3476a0d19dabb2df09140c831ae30b83b7f99af970c6
5
5
  SHA512:
6
- metadata.gz: bc533656a79f62e7f1ab832166035c24ad2d614e090b4fec5a08a5b5c4218c987aab94437141870fb02931330785819b467034aa437b5be55fedae37c2c90c54
7
- data.tar.gz: af88084f7c99abcd4c141d419b11628b74178615acf959b667f7d66b1c5881d32e3f64946fb2765c2045094226b28cc8ac0ebb463d2e06744703c05dd3a2429f
6
+ metadata.gz: e13624e8469b16e2286be815c37340b5402d0697023831f56f32256c66aae9480b5b0a920df1298016eb72f3065ba1f13b1984c3b05402f078bf54736b0eb59d
7
+ data.tar.gz: cc72cb9c18db99192df99f5572d5c229c1c6eaf50372b88cf80421d12bf9e032449799d4aa299810f4070b8144a9e50a54e594af073d42c165e18abe0b022d25
data/.rubocop.yml CHANGED
@@ -1,3 +1,7 @@
1
+ require:
2
+ - rubocop-rake
3
+ - rubocop-rspec
4
+
1
5
  AllCops:
2
6
  NewCops: enable
3
7
  TargetRubyVersion: 2.6
@@ -7,3 +11,6 @@ AllCops:
7
11
 
8
12
  Metrics/MethodLength:
9
13
  Max: 20
14
+
15
+ RSpec/ExampleLength:
16
+ Max: 10
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ #### 0.0.2 - June 11th, 2022
2
+
3
+ * Internal API Change: Kitkat::Reader is now Enumerable.
4
+
5
+ #### 0.0.1 - June 10th, 2022
6
+
7
+ * Initial version.
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: `exe/kitkat`. Simply run this from your shell:
37
+ This library ships with an executable: `kitkat`. Simply run this from your shell:
28
38
 
29
39
  ````zsh
30
- exe/kitkat <path> <database>
40
+ bundle exec kitkat <path> <database>
31
41
  ````
32
42
 
33
- For Example: `bin/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`.
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
- Note: database positional argument is optional. If it is not supplied then it will default to: `kitkat.db`
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
 
@@ -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
@@ -32,6 +32,7 @@ module Kitkat
32
32
  full_mime_type.split(MIME_TYPE_SEPARATOR).last
33
33
  end
34
34
 
35
+ # Important note: Calling this on a directory will result in a blank string.
35
36
  def digest
36
37
  File.directory?(path) ? BLANK : Digest::SHA256.file(path).hexdigest
37
38
  end
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kitkat
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
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.1
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-10 00:00:00.000000000 Z
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