file_db 0.6.0 → 0.7.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
  SHA1:
3
- metadata.gz: e6c33fd0d57a8c8bf520982e9914dc83bb8a9619
4
- data.tar.gz: 9d93792d4e0f210e6f17520bf4b37686ffb9f758
3
+ metadata.gz: 24e147af83c09e392af68b2d35ba364359222dc0
4
+ data.tar.gz: a14ad70583def016b74a250cfb147734cf5b5afb
5
5
  SHA512:
6
- metadata.gz: ec98935114be896a730a553c94d330bdc93aa6132c9ad7705155b9164abbce87ba33bc9d9e1376c993e6bcbc6d35c5129bc849ef730eaeac781716ce79ad0b86
7
- data.tar.gz: b952c883bc1883ceb249e272d161aa81c88b413bac3976b6b795503637ffa3bb2d4ebb31f54ee5f9acfe38bbd44bcb6dd42c8d6d561b71d288723d18074a62b6
6
+ metadata.gz: 00ef2f85b0fe7017354b1be6afb198dd71c204e8dd928692ee0123cbacf0e9d377bd42cb38965a39dd28002e0051a1ba7c9d5b935c96852ace50e7dde90ad709
7
+ data.tar.gz: ab4e957e912e51413f85e3d08bd7445e6db12faa6af3b085e9e595e90454e3db78f04f2d0c557ada78b4661d1d8d7a122494f03bd198dde302828f354da35c58
data/README.md CHANGED
@@ -7,7 +7,7 @@ You need to store data into a small type of database, like CSV and want a better
7
7
  hm, yeah. just add this to your Gemfile:
8
8
 
9
9
  ```ruby
10
- gem 'file_db', '~> 0.6.0'
10
+ gem 'file_db', '~> 0.7.0'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -30,11 +30,11 @@ First configure the storage directory:
30
30
  ```ruby
31
31
  FileDb::Configuration.configure data_directory: 'data'
32
32
  ```
33
- Subdirectory is the default for storing the tables. If you change the configuration, the `database_check!` will be automaticly executed
33
+ Subdirectory is the default for storing the tables. If you change the configuration, the `FileDb` will be automaticly create a new database.
34
34
 
35
35
  If you running a clean instance with no configuration changes so make sure, the storage directory exists or use the build in check for checking and creating the data directory:
36
36
  ```ruby
37
- FileDb::Database.database_check!
37
+ FileDb::System::Check.run!
38
38
  ```
39
39
 
40
40
  Let's start with creating a model called `User`.
data/file_db.gemspec CHANGED
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency "bundler", "~> 1.12"
23
23
  spec.add_development_dependency "rake", "~> 10.0"
24
24
  spec.add_development_dependency "rspec", "~> 3.0"
25
- spec.required_ruby_version = '>= 1.9.3'
25
+ spec.required_ruby_version = '>= 2.0.0'
26
26
  end
@@ -2,7 +2,7 @@ module FileDb
2
2
  module Configuration
3
3
  def self.configure options = {}
4
4
  @configuration = default_options.merge(options)
5
- FileDb::Database.database_check!
5
+ System::Check.run!
6
6
  end
7
7
 
8
8
  def self.configured option
@@ -4,7 +4,7 @@ module FileDb
4
4
  include Singleton
5
5
 
6
6
  def self.database_check!
7
- instance.create_data_directory! unless instance.exist_data_directory?
7
+ System::Check.run!
8
8
  end
9
9
 
10
10
  def search model
@@ -42,14 +42,6 @@ module FileDb
42
42
  end
43
43
  end
44
44
 
45
- def exist_data_directory?
46
- File.exist? data_directory
47
- end
48
-
49
- def create_data_directory!
50
- Dir.mkdir data_directory
51
- end
52
-
53
45
  private
54
46
 
55
47
  def build_object clazz, data
@@ -0,0 +1,26 @@
1
+ module FileDb
2
+ module System
3
+ class Check
4
+ def self.run!
5
+ new.create_database_if_not_exist!
6
+ end
7
+
8
+ def create_database_if_not_exist!
9
+ return if exist_data_directory?
10
+ create_data_directory!
11
+ end
12
+
13
+ def exist_data_directory?
14
+ File.exist? data_directory
15
+ end
16
+
17
+ def create_data_directory!
18
+ Dir.mkdir data_directory
19
+ end
20
+
21
+ def data_directory
22
+ Configuration.configured(:data_directory)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module FileDb
2
- VERSION = "0.6.0"
2
+ VERSION = "0.7.0"
3
3
  end
data/lib/file_db.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "csv"
2
2
  require "file_db/version"
3
+ require "file_db/system/check"
3
4
  require "file_db/configuration"
4
5
  require "file_db/database"
5
6
  require "file_db/columns"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Starke
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-31 00:00:00.000000000 Z
11
+ date: 2016-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,6 +80,7 @@ files:
80
80
  - lib/file_db/database.rb
81
81
  - lib/file_db/model.rb
82
82
  - lib/file_db/query.rb
83
+ - lib/file_db/system/check.rb
83
84
  - lib/file_db/table.rb
84
85
  - lib/file_db/version.rb
85
86
  homepage: https://github.com/robst/file_db
@@ -94,7 +95,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
95
  requirements:
95
96
  - - ">="
96
97
  - !ruby/object:Gem::Version
97
- version: 1.9.3
98
+ version: 2.0.0
98
99
  required_rubygems_version: !ruby/object:Gem::Requirement
99
100
  requirements:
100
101
  - - ">="
@@ -102,7 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
103
  version: '0'
103
104
  requirements: []
104
105
  rubyforge_project:
105
- rubygems_version: 2.4.6
106
+ rubygems_version: 2.5.1
106
107
  signing_key:
107
108
  specification_version: 4
108
109
  summary: Use CSV Files like a Database with ActiveRecord Feeling.