static_db 0.0.2 → 0.0.4

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: 479d7410cc5f976ed22e42d910e249055c741df4e4c6cdf8267b01bea16f8217
4
- data.tar.gz: 7b9e03429fa960d457e60a49055eacdabdd55d987e73243a8beb56d72f7437de
3
+ metadata.gz: 02b96ad6eca0c26259e1e12e6ff9b83e770d37d2070487c011f6f2f1472c3a75
4
+ data.tar.gz: b1be8d64e52becc77b4163e3d3d521a42c046a799d73035624015074bf9d077e
5
5
  SHA512:
6
- metadata.gz: 0e6ef11395d226a4c53bd953ca08c103509dae4c85330c797b7620b28360366815e32942a2284430be8437220f6433766a0ed0206582b56d823e80779cc00bde
7
- data.tar.gz: d7bef38d14c21fcbbbf321756ec4d9319b90ef7d45ccd408de7bc80c596eb4c88f0a83b98b0f4b92e9fa0875973d45086b57745ea2a2782196001e3300f12a1e
6
+ metadata.gz: 29df6c00287bb63cab1b235b610d375521b689d1b4b1cc5823f53b8a395030437e3d119315ae68b7682c2a5266cd80a3c3658346d77a8304547d8e1a3bfe2889
7
+ data.tar.gz: 3d0631350c93afb497bef3b8205135a7ca6207927f67dc6426e8a13dc5fe4dbe3fc941512968097cdb8b305ee6838a7c71da9db8fbc5973f4e43a14d9441e806
data/CHANGELOG.md CHANGED
@@ -1,3 +1,13 @@
1
- # Change log
1
+ # Changelog
2
2
 
3
- ## master
3
+ > :warning: This project is not inteded for public usage yet.
4
+
5
+ I will start keeping a changelog as soon as that happens.
6
+
7
+ This project adheres to [Break Versioning](https://www.taoensso.com/break-versioning).
8
+
9
+ ## [Unreleased]
10
+
11
+ ### Breaking
12
+
13
+ ### Non-breaking
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2024 Klaus Weidinger
1
+ Copyright (c) 2026 Klaus Weidinger
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,47 +1,43 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/static_db.svg)](https://rubygems.org/gems/static_db)
2
2
  [![Build](https://github.com/dunkelziffer/static_db/workflows/Build/badge.svg)](https://github.com/dunkelziffer/static_db/actions)
3
- [![JRuby Build](https://github.com/dunkelziffer/static_db/workflows/JRuby%20Build/badge.svg)](https://github.com/dunkelziffer/static_db/actions)
4
3
 
5
4
  # static_db
6
5
 
7
- TBD
6
+ Dump DB contents to YAML and load them back again. Aimed at SQLite. Committable to git.
8
7
 
9
8
  ## Installation
10
9
 
11
- Adding to a gem:
10
+ WARNING: This gem modifies the Rails startup sequence. Don't use this gem unless you want to build a static site generator. This gem also creates and drops the DB for you.
12
11
 
13
- ```ruby
14
- # my-cool-gem.gemspec
15
- Gem::Specification.new do |spec|
16
- # ...
17
- spec.add_dependency "static_db"
18
- # ...
19
- end
20
- ```
21
-
22
- Or adding to your project:
12
+ Add it to your Rails project:
23
13
 
24
14
  ```ruby
25
15
  # Gemfile
26
16
  gem "static_db"
17
+
18
+ # config/initializer/static_db.rb
19
+ StaticDb.configure do |config|
20
+ # `content/data` is the default. You only need this initializer,
21
+ # if you want a custom path.
22
+ config.fixture_path = Rails.root.join("content", "data")
23
+ end
27
24
  ```
28
25
 
29
- ### Supported Ruby versions
26
+ ## Usage
30
27
 
31
- - Ruby (MRI) >= 2.7.0
32
- - JRuby >= 9.3.0
28
+ Only use on Rails projects with SQLite. Have a valid `db/schema.rb`. For additional dramatic effect, do a `rails db:drop`.
33
29
 
34
- ## Usage
30
+ Start your app with `bin/dev`. You will notice that a DB gets created for you. It will be empty.
35
31
 
36
- TBD
32
+ Create some records. Then, stop your server with Ctrl+C.
37
33
 
38
- ## Contributing
34
+ The DB contents will have been dumped to `content/data`. Your SQLite DB will be gone.
39
35
 
40
- Bug reports and pull requests are welcome on GitHub at [https://github.com/dunkelziffer/static_db](https://github.com/dunkelziffer/static_db).
36
+ Restart your server with `bin/dev`. Your SQLite DB will be back and populated with all previously stored data, recreated from `content/data`.
41
37
 
42
- ## Credits
38
+ ## Contributing
43
39
 
44
- This gem is generated via [`newgem` template](https://github.com/palkan/newgem) by [@palkan](https://github.com/palkan).
40
+ Bug reports and pull requests are welcome on GitHub at [https://github.com/dunkelziffer/static_db](https://github.com/dunkelziffer/static_db).
45
41
 
46
42
  ## License
47
43
 
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ begin
7
+ require "rubocop/rake_task"
8
+ RuboCop::RakeTask.new
9
+ rescue LoadError
10
+ task(:rubocop) {}
11
+ end
12
+
13
+ task default: %w[rubocop spec]
@@ -1,9 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
1
  module StaticDb
4
2
  class Dump
5
3
 
6
- attr_reader :fixture_path
4
+ attr_reader :fixture_path, :models_to_be_saved
7
5
 
8
6
  def initialize(fixture_path:)
9
7
  @fixture_path = Pathname.new(fixture_path)
@@ -37,9 +35,7 @@ module StaticDb
37
35
 
38
36
  errors = []
39
37
 
40
- ActiveRecord::Base.descendants.each do |model|
41
- next if model.abstract_class?
42
-
38
+ models_to_be_saved.each do |model|
43
39
  model.find_each do |record|
44
40
  unless record.valid?
45
41
  errors << { model: model.name, slug: record.slug, errors: record.errors.full_messages }
@@ -65,7 +61,7 @@ module StaticDb
65
61
 
66
62
  def dump_fixtures!
67
63
  reset_data_directory!
68
- @models_to_be_saved.each { |model| format_and_write_yaml_file!(model) }
64
+ models_to_be_saved.each { |model| format_and_write_yaml_file!(model) }
69
65
  end
70
66
 
71
67
  def reset_data_directory!
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "static_db/initializer"
4
2
 
5
3
  module StaticDb # :nodoc:
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "ostruct"
4
2
 
5
3
  module StaticDb
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module StaticDb
4
2
  class Load
5
3
 
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  namespace :static do
4
2
  desc "Create fixtures from database; accepts optional path argument"
5
3
  task :dump, [:path] => :environment do |t, args|
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module StaticDb # :nodoc:
4
- VERSION = "0.0.2"
2
+ VERSION = "0.0.4"
5
3
  end
data/lib/static_db.rb CHANGED
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  require "static_db/version"
4
2
  require "static_db/dump"
5
3
  require "static_db/load"
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: static_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Klaus Weidinger
8
- bindir: bin
8
+ bindir: exe
9
9
  cert_chain: []
10
10
  date: 1980-01-02 00:00:00.000000000 Z
11
11
  dependencies:
@@ -15,73 +15,32 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '7.2'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '7.2'
26
26
  - !ruby/object:Gem::Dependency
27
- name: bundler
27
+ name: ostruct
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
- version: '1.15'
33
- type: :development
34
- prerelease: false
35
- version_requirements: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '1.15'
40
- - !ruby/object:Gem::Dependency
41
- name: combustion
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '1.1'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '1.1'
54
- - !ruby/object:Gem::Dependency
55
- name: rake
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '13.0'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: '13.0'
68
- - !ruby/object:Gem::Dependency
69
- name: rspec
70
- requirement: !ruby/object:Gem::Requirement
71
- requirements:
72
- - - ">="
73
- - !ruby/object:Gem::Version
74
- version: '3.9'
75
- type: :development
32
+ version: '0.6'
33
+ type: :runtime
76
34
  prerelease: false
77
35
  version_requirements: !ruby/object:Gem::Requirement
78
36
  requirements:
79
37
  - - ">="
80
38
  - !ruby/object:Gem::Version
81
- version: '3.9'
82
- description: Example description
39
+ version: '0.6'
40
+ description: Dump DB contents to YAML and load them back again. Aimed at SQLite. Committable
41
+ to git.
83
42
  email:
84
- - Klaus Weidinger
43
+ - weidkl@gmx.de
85
44
  executables: []
86
45
  extensions: []
87
46
  extra_rdoc_files: []
@@ -89,6 +48,7 @@ files:
89
48
  - CHANGELOG.md
90
49
  - LICENSE.txt
91
50
  - README.md
51
+ - Rakefile
92
52
  - lib/static_db.rb
93
53
  - lib/static_db/dump.rb
94
54
  - lib/static_db/engine.rb
@@ -100,12 +60,12 @@ homepage: https://github.com/dunkelziffer/static_db
100
60
  licenses:
101
61
  - MIT
102
62
  metadata:
63
+ source_code_uri: https://github.com/dunkelziffer/static_db
103
64
  homepage_uri: https://github.com/dunkelziffer/static_db
104
65
  changelog_uri: https://github.com/dunkelziffer/static_db/blob/main/CHANGELOG.md
105
66
  bug_tracker_uri: https://github.com/dunkelziffer/static_db/issues
106
67
  documentation_uri: https://github.com/dunkelziffer/static_db/blob/main/README.md
107
- source_code_uri: https://github.com/dunkelziffer/static_db
108
- custom_attribute: a, b, c
68
+ rubygems_mfa_required: 'true'
109
69
  rdoc_options: []
110
70
  require_paths:
111
71
  - lib
@@ -120,7 +80,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
80
  - !ruby/object:Gem::Version
121
81
  version: '0'
122
82
  requirements: []
123
- rubygems_version: 3.6.7
83
+ rubygems_version: 4.0.8
124
84
  specification_version: 4
125
- summary: Example description
85
+ summary: Dump DB contents to YAML and load them back again. Aimed at SQLite. Committable
86
+ to git.
126
87
  test_files: []