kitkat 0.0.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbdbb6ec1c0293541eed2e6d3227dd23157f6de455499df55d5bc32f6044c025
4
- data.tar.gz: 2c02ad2202530ef1d4d2201711bc4dcf18ef1cfeb3543d3b54756b5238cc3be3
3
+ metadata.gz: 17654438fa4ef7a3ed4c7050ccccfa152d315a233a3776e3ddc64a234f8f0d7b
4
+ data.tar.gz: 7a9d327cc6cc8cf6dbdaff076f4b1e0d3c6cc39822a8aeeb4d95b2db1f43aa0b
5
5
  SHA512:
6
- metadata.gz: bc533656a79f62e7f1ab832166035c24ad2d614e090b4fec5a08a5b5c4218c987aab94437141870fb02931330785819b467034aa437b5be55fedae37c2c90c54
7
- data.tar.gz: af88084f7c99abcd4c141d419b11628b74178615acf959b667f7d66b1c5881d32e3f64946fb2765c2045094226b28cc8ac0ebb463d2e06744703c05dd3a2429f
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: ['2.6', '2.7', '3.0']
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
- # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
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.6
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.6.6
1
+ ruby 3.2.1
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
1
+ #### 1.0.0 - February 12th, 2023
2
+
3
+ * Update to use Ruby 3.2.1 and later only.
4
+
5
+ #### 0.0.2 - June 11th, 2022
6
+
7
+ * Internal API Change: Kitkat::Reader is now Enumerable.
8
+
9
+ #### 0.0.1 - June 10th, 2022
10
+
11
+ * 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
 
data/exe/kitkat CHANGED
@@ -7,4 +7,4 @@ require 'kitkat'
7
7
  path = ARGV[0].to_s
8
8
  db = ARGV[1].to_s.empty? ? 'kitkat.db' : ARGV[1].to_s
9
9
 
10
- Kitkat.crawl(db: db, path: path)
10
+ Kitkat.crawl(db:, path:)
data/kitkat.gemspec CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |s|
27
27
  'rubygems_mfa_required' => 'true'
28
28
  }
29
29
 
30
- s.required_ruby_version = '>= 2.6'
30
+ s.required_ruby_version = '>= 3.2.1'
31
31
 
32
32
  s.add_dependency('sqlite3')
33
33
 
@@ -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
@@ -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)
@@ -13,21 +15,21 @@ module Kitkat
13
15
  freeze
14
16
  end
15
17
 
16
- def each(&block)
18
+ def each(&)
17
19
  return enum_for(:each) unless block_given?
18
20
 
19
- traverse(root, &block)
21
+ traverse(root, &)
20
22
 
21
23
  self
22
24
  end
23
25
 
24
26
  private
25
27
 
26
- def traverse(dir, &block)
28
+ def traverse(dir, &)
27
29
  Dir[File.join(dir, '*')].each do |path|
28
- yield FileInfo.new(path, root: root)
30
+ yield FileInfo.new(path, root:)
29
31
 
30
- traverse(path, &block) if File.directory?(path)
32
+ traverse(path, &) if File.directory?(path)
31
33
  end
32
34
  end
33
35
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kitkat
4
- VERSION = '0.0.1'
4
+ VERSION = '1.0.0'
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: 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: 2022-06-10 00:00:00.000000000 Z
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: '2.6'
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.0.3
227
+ rubygems_version: 3.4.6
227
228
  signing_key:
228
229
  specification_version: 4
229
230
  summary: File/Metadata Database Populator