JSONRecord 0.0.10 → 0.0.11
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.
- data/README.md +21 -14
- data/bin/jsonrecord +9 -4
- data/lib/JSONRecord/version.rb +1 -1
- data/lib/loader.rb +1 -1
- metadata +12 -4
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -17,48 +17,55 @@ And then execute:
|
|
17
17
|
|
18
18
|
Or install it yourself as:
|
19
19
|
|
20
|
-
$ gem install JSONRecord
|
20
|
+
$ gem install JSONRecord
|
21
21
|
|
22
22
|
## Usage
|
23
|
+
It is very easy to use jsondb as a document store in rails, create a model in rails/model
|
24
|
+
and inherit from JSONRecord::Base it gives few mechanisms to search and save data in json files.
|
23
25
|
|
24
|
-
|
25
|
-
it gives few mechanisms to search and save data in json files.
|
26
|
+
In order to generate new models an executable named jsonrecord is included:
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
`jsonrecord generate model apple` (make sure your model name is singular)
|
28
|
+
`$ jsonrecord generate model apple #(make sure your model name is singular)`
|
30
29
|
|
31
|
-
|
30
|
+
then in model/apple.rb
|
32
31
|
|
32
|
+
```ruby
|
33
33
|
class Apple < JSONRecord::Base
|
34
|
-
|
35
34
|
def index
|
36
35
|
end
|
37
|
-
|
38
36
|
end
|
39
|
-
|
40
|
-
|
37
|
+
```
|
41
38
|
|
42
39
|
##Methods include :
|
43
40
|
|
44
|
-
|
41
|
+
```ruby
|
42
|
+
|
43
|
+
find(id)
|
44
|
+
find_by_column_name("column_value")
|
45
|
+
model_instance.update_attributes(:name => "pankaj" , :age => "29")
|
46
|
+
|
47
|
+
```
|
45
48
|
|
46
49
|
also ,
|
47
50
|
|
51
|
+
```ruby
|
48
52
|
Model.new({:name=> "pankaj" , :age => "29"}).save
|
49
|
-
|
53
|
+
```
|
50
54
|
|
51
55
|
In your rails model: In order to define new attributes use `column` method
|
52
56
|
i.e column :column_name , datetype
|
53
57
|
|
54
58
|
|
55
|
-
example => column :name
|
59
|
+
example => `column :name`
|
56
60
|
|
57
61
|
by default if the second parameter is not defined it is taken as a string other wise datatypes can be defined as follows
|
58
62
|
|
63
|
+
|
64
|
+
```ruby
|
59
65
|
column :name, String
|
60
66
|
column :age, Number
|
61
67
|
column :marks, Array
|
68
|
+
```
|
62
69
|
|
63
70
|
Currently JSONRecord supports three datatypes String , Number , Array , More are coming ... As soon as code is modified to use
|
64
71
|
messagepack or BSON.
|
data/bin/jsonrecord
CHANGED
@@ -1,14 +1,19 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'fileutils'
|
3
4
|
require 'optparse'
|
4
|
-
require 'active_support'
|
5
|
+
require 'active_support/inflector'
|
5
6
|
|
6
7
|
tables_dir = File.expand_path('../../lib/tables',__FILE__)
|
7
8
|
|
8
|
-
include ActiveSupport::Inflector
|
9
|
-
|
10
9
|
if ARGV[0] == 'generate' and ARGV[1] == 'model'
|
11
|
-
model_name =
|
10
|
+
model_name = ARGV[2].to_s.pluralize
|
12
11
|
FileUtils.touch "#{tables_dir}/#{model_name}.json"
|
12
|
+
|
13
|
+
#Append an empty Array into the file.
|
14
|
+
File.open("#{tables_dir}/#{model_name}.json", "w+") do |file|
|
15
|
+
file.write("[]")
|
16
|
+
end
|
17
|
+
|
13
18
|
puts "JSONRecord table created : #{tables_dir}/#{model_name}.json"
|
14
19
|
end
|
data/lib/JSONRecord/version.rb
CHANGED
data/lib/loader.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: JSONRecord
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.11
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Pankaj Doharey
|
@@ -13,6 +14,7 @@ dependencies:
|
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: activesupport
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: activemodel
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: yajl-ruby
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -84,26 +91,27 @@ files:
|
|
84
91
|
- test/test_helper.rb
|
85
92
|
homepage: http://jsondb.codemismatch.com
|
86
93
|
licenses: []
|
87
|
-
metadata: {}
|
88
94
|
post_install_message:
|
89
95
|
rdoc_options: []
|
90
96
|
require_paths:
|
91
97
|
- lib
|
92
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
93
100
|
requirements:
|
94
101
|
- - ! '>='
|
95
102
|
- !ruby/object:Gem::Version
|
96
103
|
version: '0'
|
97
104
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
98
106
|
requirements:
|
99
107
|
- - ! '>='
|
100
108
|
- !ruby/object:Gem::Version
|
101
109
|
version: '0'
|
102
110
|
requirements: []
|
103
111
|
rubyforge_project:
|
104
|
-
rubygems_version:
|
112
|
+
rubygems_version: 1.8.24
|
105
113
|
signing_key:
|
106
|
-
specification_version:
|
114
|
+
specification_version: 3
|
107
115
|
summary: JSONRecord is a minimal document storage for rails, with an active record
|
108
116
|
style query interface.
|
109
117
|
test_files:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 5f37ce63a5a610a84186967c0ec555d48bc7a52d
|
4
|
-
data.tar.gz: 9b10ee7d369c578e2a5a7b05af4a98840c407ee3
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: eeaa141d06cb9c5f60a7dba78501b770d00efcbee44bdccac63ddfa2a5bcfd63a7cd160fe374f0bc50ff14fae0631342eff1a8ab71fa024dbca71edc868bdfd5
|
7
|
-
data.tar.gz: a291d9fbae5ad8484af9f2d7e822e8ae9f18f8d5d2999d2fbda18cb5f8668d82b6c313010798eb31dd863ed649c5b5a193760409cc6198acefbe94219b0a7cdf
|