json_model 0.1.1 → 0.1.2
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 +4 -4
- data/.coveralls.yml +1 -0
- data/.gitignore +1 -0
- data/Gemfile.lock +24 -1
- data/{LICENSE.txt → MIT-LICENSE} +2 -2
- data/README.md +58 -41
- data/json_model.gemspec +1 -0
- data/lib/json_model/version.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71f56e8a2fae8df19b097f8562c37ff0d40b4daf
|
4
|
+
data.tar.gz: 5b12fe16a1204b1a940b917d6fcb3f1511b65dae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fcb438f83578201181a17b4900f519c25154268ac03662eabd2514f9960578918e4188d2cc05a533b20eb7669129f3b71baa23af2bd45e15279b77c3344be3a
|
7
|
+
data.tar.gz: a16d16369759ef045bac1ba7a070aab7def07d5130a0d01a268407218154dff03568780a75d90058c0f95bbb51e1ff91a71673bd014eca74f9f6ca2554df7839
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,27 +1,50 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
json_model (0.1.
|
4
|
+
json_model (0.1.2)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ansi (1.5.0)
|
10
10
|
builder (3.2.2)
|
11
|
+
coveralls (0.7.10)
|
12
|
+
multi_json (~> 1.10)
|
13
|
+
rest-client (>= 1.6.8, < 2)
|
14
|
+
simplecov (~> 0.9.1)
|
15
|
+
term-ansicolor (~> 1.3)
|
16
|
+
thor (~> 0.19.1)
|
17
|
+
docile (1.1.5)
|
18
|
+
mime-types (2.4.3)
|
11
19
|
minitest (5.5.1)
|
12
20
|
minitest-reporters (1.0.10)
|
13
21
|
ansi
|
14
22
|
builder
|
15
23
|
minitest (>= 5.0)
|
16
24
|
ruby-progressbar
|
25
|
+
multi_json (1.10.1)
|
26
|
+
netrc (0.10.2)
|
17
27
|
rake (10.4.2)
|
28
|
+
rest-client (1.7.3)
|
29
|
+
mime-types (>= 1.16, < 3.0)
|
30
|
+
netrc (~> 0.7)
|
18
31
|
ruby-progressbar (1.7.1)
|
32
|
+
simplecov (0.9.2)
|
33
|
+
docile (~> 1.1.0)
|
34
|
+
multi_json (~> 1.0)
|
35
|
+
simplecov-html (~> 0.9.0)
|
36
|
+
simplecov-html (0.9.0)
|
37
|
+
term-ansicolor (1.3.0)
|
38
|
+
tins (~> 1.0)
|
39
|
+
thor (0.19.1)
|
40
|
+
tins (1.3.4)
|
19
41
|
|
20
42
|
PLATFORMS
|
21
43
|
ruby
|
22
44
|
|
23
45
|
DEPENDENCIES
|
24
46
|
bundler (~> 1.8)
|
47
|
+
coveralls
|
25
48
|
json_model!
|
26
49
|
minitest (~> 5.5.0)
|
27
50
|
minitest-reporters (~> 1.0.10)
|
data/{LICENSE.txt → MIT-LICENSE}
RENAMED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
MIT LICENSE
|
2
2
|
|
3
|
-
Copyright (c)
|
3
|
+
Copyright (c) 2010 Sven Fuchs <svenfuchs@artweb-design.de>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,7 +1,16 @@
|
|
1
|
-
#
|
1
|
+
# Json Model
|
2
2
|
|
3
3
|
Simple persist your model data to a .json file
|
4
4
|
|
5
|
+
| Project | |
|
6
|
+
|------------------------ | ----------------- |
|
7
|
+
| gem name | json_model |
|
8
|
+
| license | [MIT][license] |
|
9
|
+
| version | [](http://badge.fury.io/rb/json_model) |
|
10
|
+
| continuous integration | [](https://travis-ci.org/endorfin/json_model) |
|
11
|
+
| test coverage | [](https://coveralls.io/r/endorfin/json_model)
|
12
|
+
| homepage | [https://github.com/endorfin/json_model][homepage] |
|
13
|
+
|
5
14
|
## Installation
|
6
15
|
|
7
16
|
Add this line to your application's Gemfile:
|
@@ -20,53 +29,61 @@ Or install it yourself as:
|
|
20
29
|
|
21
30
|
## Usage
|
22
31
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
32
|
+
```ruby
|
33
|
+
require 'json_model'
|
34
|
+
|
35
|
+
class Book
|
36
|
+
include JsonModel
|
37
|
+
|
38
|
+
field :name
|
39
|
+
field :author
|
40
|
+
end
|
41
|
+
|
42
|
+
# create some books
|
43
|
+
Book.new({name: 'Inferno', author: 'Dan Brown'}).save
|
44
|
+
Book.new({name: 'Das verlorene Symbol', author: 'Dan Brown'}).save
|
45
|
+
Book.new({name: 'Diabolus', author: 'Dan Brown'}).save
|
46
|
+
|
47
|
+
# list all books
|
48
|
+
puts "\n--- List all books"
|
49
|
+
Book.all.map{|book| puts "#{book.id} - #{book.name} by #{book.author}" }
|
50
|
+
|
51
|
+
# find a book by id
|
52
|
+
puts "\n--- Find book with id=1"
|
53
|
+
book = Book.find(1)
|
54
|
+
puts "Book: #{book.to_json}"
|
55
|
+
|
56
|
+
# update a book
|
57
|
+
puts "\n--- Update name of book with id=1"
|
58
|
+
book = Book.find(1)
|
59
|
+
book.name = 'Illuminati'
|
60
|
+
book.save
|
61
|
+
Book.all.map{|book| puts "#{book.id} - #{book.name} by #{book.author}" }
|
62
|
+
|
63
|
+
# find a book by name
|
64
|
+
puts "\n--- Find book by name 'Illuminati'"
|
65
|
+
book = Book.find_by(name: 'Illuminati')
|
66
|
+
puts "Book: #{book.to_json}"
|
67
|
+
|
68
|
+
# delete a book
|
69
|
+
puts "\n--- Delete book with Id=2"
|
70
|
+
book = Book.find(2)
|
71
|
+
book.destroy
|
72
|
+
Book.all.map{|book| puts "#{book.id} - #{book.name} by #{book.author}" }
|
73
|
+
```
|
47
74
|
|
48
|
-
|
49
|
-
puts "\n--- Update name of book with id=1"
|
50
|
-
book = Book.find(1)
|
51
|
-
book.name = 'Illuminati'
|
52
|
-
book.save
|
53
|
-
Book.all.map{|book| puts "#{book.id} - #{book.name} by #{book.author}" }
|
75
|
+
$ ruby book.rb
|
54
76
|
|
55
|
-
|
56
|
-
puts "\n--- Find book by name 'Illuminati'"
|
57
|
-
book = Book.find_by(name: 'Illuminati')
|
58
|
-
puts "Book: #{book.to_json}"
|
77
|
+
## License
|
59
78
|
|
60
|
-
|
61
|
-
puts "\n--- Delete book with Id=2"
|
62
|
-
book = Book.find(2)
|
63
|
-
book.destroy
|
64
|
-
Book.all.map{|book| puts "#{book.id} - #{book.name} by #{book.author}" }
|
79
|
+
[MIT License][license]
|
65
80
|
|
81
|
+
[license]: https://github.com/endorfin/json_model/blob/master/MIT-LICENSE
|
82
|
+
[homepage]: https://github.com/endorfin/json_model
|
66
83
|
|
67
84
|
## Contributing
|
68
85
|
|
69
|
-
1. Fork it ( https://github.com/
|
86
|
+
1. Fork it ( https://github.com/endorfin/json_model/fork )
|
70
87
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
71
88
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
72
89
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/json_model.gemspec
CHANGED
data/lib/json_model/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- René Kersten
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 1.0.10
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: coveralls
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description:
|
70
84
|
email:
|
71
85
|
- rene.kersten@gmail.com
|
@@ -73,12 +87,13 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
90
|
+
- .coveralls.yml
|
76
91
|
- .gitignore
|
77
92
|
- .travis.yml
|
78
93
|
- CODE_OF_CONDUCT.md
|
79
94
|
- Gemfile
|
80
95
|
- Gemfile.lock
|
81
|
-
- LICENSE
|
96
|
+
- MIT-LICENSE
|
82
97
|
- README.md
|
83
98
|
- Rakefile
|
84
99
|
- json_model.gemspec
|