file_db 0.3.1 → 0.4.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: a5d11ea78113cb406dae04047a08aab1699ce34b
4
- data.tar.gz: 2e6858e0bb56771cdcd328fb4f878a608f1ed018
3
+ metadata.gz: 3fb2a37f42eb60fdd2a57b7997cac9e0c55a45bd
4
+ data.tar.gz: 9238653b18bc14f02d6871967b0f01a51712598a
5
5
  SHA512:
6
- metadata.gz: c15f3cb05c011bdf07a932b34ffc8cb7a4e09c2cda7b1e594ff57c94220b6536f06ce8e1336fdba050e17f0330af1468c36bad95c6b95e65daeac10e3a837618
7
- data.tar.gz: 6e87ab33cac789bae1147de5b470ec2cd8530cdb2507c4c355eca3683de4bed772f4c104c36a83755b2ae807470212cd36b5342c41a56120a36505c377468a77
6
+ metadata.gz: 2c0baa029b66c032c38a334ca582fc06d48f611408a058c1d9cbdd3c75360feed6b4950be8f820fe59a3a63f5b04573c2cb2cf617c819f23c538a3bcc4dafefa
7
+ data.tar.gz: 9ee6c86bbb9b70e18c0ea1eca3b627d76c759766f83c545497ef59c4c1030053fe186343540700c51539bc973364f232707fce56d4e4fe72fd8921d021bbdabb
data/2 ADDED
@@ -0,0 +1,23 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'file_db'
3
+
4
+ RSpec.configure do |config|
5
+ config.before(:suite) do
6
+ class User < FileDb::Model
7
+ columns :name, :test
8
+ end
9
+ FileDb::Configuration.configure data_directory: 'data'
10
+ FileDb::Database.database_check!
11
+ new_time = Time.local(2013, 12, 11, 11, 28, 0)
12
+ Timecop.freeze(new_time)
13
+ User.create name: 'max', test: 'test'
14
+ end
15
+
16
+ config.after(:suite) do
17
+ File.delete File.join(
18
+ FileDb::Configuration.configured(:data_directory),
19
+ "#{User.table_name}.csv"
20
+ )
21
+ Dir.delete(FileDb::Configuration.configured :data_directory)
22
+ end
23
+ end
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.3.0'
10
+ gem 'file_db', '~> 0.4.0'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -92,6 +92,24 @@ User.where(name: 'rob')
92
92
  -> [#<User:0x00000004651798 @name="rob", @id="1466311874", @email=nil>]
93
93
  ```
94
94
 
95
+ You can also use `first` and `last` to get the first and last user
96
+ ```ruby
97
+ User.first
98
+ -> #<User:0x00000004651798 @name="rob", @id="1466311874", @email=nil>
99
+ ```
100
+
101
+ ```ruby
102
+ User.last
103
+ -> #<User:0x00000004651798 @name="rob", @id="1466311874", @email=nil>
104
+ ```
105
+
106
+ Or you use `all` to get really all users.
107
+
108
+ ```ruby
109
+ User.all
110
+ -> [#<User:0x00000004651798 @name="rob", @id="1466311874", @email=nil>]
111
+ ```
112
+
95
113
  rename the user:
96
114
 
97
115
  ```ruby
data/file_db.gemspec CHANGED
@@ -22,4 +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.add_development_dependency "timecop", "~> 0.8"
25
26
  end
data/lib/file_db/query.rb CHANGED
@@ -2,6 +2,18 @@ module FileDb
2
2
  module Query
3
3
  include FileDb::Columns
4
4
  include FileDb::Table
5
+ def first
6
+ all.first
7
+ end
8
+
9
+ def last
10
+ all.last
11
+ end
12
+
13
+ def all
14
+ where({})
15
+ end
16
+
5
17
 
6
18
  def find id
7
19
  where(id: id).first
@@ -1,3 +1,3 @@
1
1
  module FileDb
2
- VERSION = "0.3.1"
2
+ VERSION = "0.4.0"
3
3
  end
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.3.1
4
+ version: 0.4.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-06-21 00:00:00.000000000 Z
11
+ date: 2016-06-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: timecop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.8'
55
69
  description: You need to store informationen in a CSV File, because there is no need
56
70
  for a database? You can use FileDb to store all informationen in a CSV File and
57
71
  search in it like ActiveRecord (User.find(1212). See detailed Information at the
@@ -65,6 +79,7 @@ files:
65
79
  - ".gitignore"
66
80
  - ".rspec"
67
81
  - ".travis.yml"
82
+ - '2'
68
83
  - Gemfile
69
84
  - LICENSE.txt
70
85
  - README.md