file_db 0.5.0 → 0.6.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: 87178fd3990a62e452fcaec537b440e7e8cd3d1e
4
- data.tar.gz: 0c5859ca95b0ceaf41e1c9b6f84c2203eb4751c3
3
+ metadata.gz: e6c33fd0d57a8c8bf520982e9914dc83bb8a9619
4
+ data.tar.gz: 9d93792d4e0f210e6f17520bf4b37686ffb9f758
5
5
  SHA512:
6
- metadata.gz: 93690b7267241a8d7241ffa6a94b78e8c53fb68604818a1667b9f6310dc8481b37c587e52957e5b6b3ee7cb10e49afc8a8c0c4f9c57a37d1a19ee73afd6a22c2
7
- data.tar.gz: 9fd4bc2856b480005d1f8af579e6e1a27ce4bbaee6eecdc3e580815b62920b6b81988b0ba035384b860abb29d170848dced1d8dacec2ab39c163c44c7187afed
6
+ metadata.gz: ec98935114be896a730a553c94d330bdc93aa6132c9ad7705155b9164abbce87ba33bc9d9e1376c993e6bcbc6d35c5129bc849ef730eaeac781716ce79ad0b86
7
+ data.tar.gz: b952c883bc1883ceb249e272d161aa81c88b413bac3976b6b795503637ffa3bb2d4ebb31f54ee5f9acfe38bbd44bcb6dd42c8d6d561b71d288723d18074a62b6
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.5.0'
10
+ gem 'file_db', '~> 0.6.0'
11
11
  ```
12
12
 
13
13
  And then execute:
@@ -100,6 +100,21 @@ User.where(name: 'rob', email: nil)
100
100
  -> [#<User:0x00000004651798 @name="rob", @id="1", @email=nil>]
101
101
  ```
102
102
 
103
+ For the first User with name rob you can use:
104
+
105
+ ```ruby
106
+ User.where(name: 'rob', email: nil).first
107
+ -> #<User:0x00000004651798 @name="rob", @id="1", @email=nil>
108
+ ```
109
+
110
+ or
111
+
112
+ ```ruby
113
+ User.find_by(:name, 'rob')
114
+ -> [#<User:0x00000004651798 @name="rob", @id="1", @email=nil>]
115
+ ```
116
+
117
+
103
118
  You can also use `first` and `last` to get the first and last user
104
119
  ```ruby
105
120
  User.first
data/lib/file_db/query.rb CHANGED
@@ -15,7 +15,11 @@ module FileDb
15
15
  end
16
16
 
17
17
  def find id
18
- where(id: id).first
18
+ find_by(:id, id)
19
+ end
20
+
21
+ def find_by attribute, search_value
22
+ where("#{attribute}".to_sym => search_value).first
19
23
  end
20
24
 
21
25
  def where conditions
@@ -1,3 +1,3 @@
1
1
  module FileDb
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.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.5.0
4
+ version: 0.6.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-28 00:00:00.000000000 Z
11
+ date: 2016-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler