rails_static_record 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +54 -2
- data/lib/static_record/version.rb +1 -1
- metadata +2 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af744dc66feb75db3846575e816e053c07aa4bcb
|
4
|
+
data.tar.gz: a28d9fea324d2a5b81911ee6675b36b2b1b746a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83eacf8405f9b6b9ef45fc89db4e510b000fb911a09536d2f3cb35f27be4e8ceb13747a5b7abc0c75bcb9c5ae9da35d00ac23a941cca37640f874f4881d2ec8c
|
7
|
+
data.tar.gz: e5aefa98e822758496d212dd8464e93cd3e0db9f1ef11f3f5e39b338d3b22e4c51afa57eb10cf401d5173f673ad8a9bc9a51bc2f0f9014292fae127d78f72e1c
|
data/README.md
CHANGED
@@ -1,8 +1,60 @@
|
|
1
1
|
# StaticRecord
|
2
|
-
|
2
|
+
Create models with static data provided by YAML file stored
|
3
|
+
locally, is useful for models like categories to store data
|
4
|
+
without have to access to database. Is based on ActiveRecord
|
5
|
+
and it permits relations with native models.
|
3
6
|
|
4
7
|
## Usage
|
5
|
-
|
8
|
+
You can create your own static model, creating a model ruby file in
|
9
|
+
_app/models_. Remember name your model according to the rails convention.
|
10
|
+
|
11
|
+
This is an example of static model for categories
|
12
|
+
```ruby
|
13
|
+
# app/models/category.rb
|
14
|
+
|
15
|
+
class Category < StatucRecord::Base
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
Also you have to create the model data in *_db/static_*, the name of the YAML
|
20
|
+
file is by default the name of the table for model. In other words, if your
|
21
|
+
model name is category, you'll have to name your data file as categories.yml.
|
22
|
+
You can see the rails convention
|
23
|
+
[here](http://guides.rubyonrails.org/active_record_basics.html).
|
24
|
+
|
25
|
+
```yaml
|
26
|
+
# db/static/categories.yml
|
27
|
+
---
|
28
|
+
- id: 1
|
29
|
+
code: 84335d3f-18b8-4934-b1d2-92e2d5228684
|
30
|
+
name: Vehicles and Planes
|
31
|
+
- id: 2
|
32
|
+
code: c4785f56-0a24-4405-9832-0092c7fd21d9
|
33
|
+
name: Dogs and Cats
|
34
|
+
- id: 3
|
35
|
+
code: 8f0be8ed-5cf2-4170-8c96-207dc0193c9a
|
36
|
+
name: Babies
|
37
|
+
- id: 4
|
38
|
+
code: 2974eec1-54ad-4ed5-8f21-af8bc0d5b473
|
39
|
+
name: Technology
|
40
|
+
|
41
|
+
# ...
|
42
|
+
```
|
43
|
+
|
44
|
+
Use the model like an ActiveRecord model, some functionalities doesn't work
|
45
|
+
because it's a static model, but the main functionalities are the same.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# Get all categories
|
49
|
+
Category.all
|
50
|
+
|
51
|
+
# Find category 4 (Technology)
|
52
|
+
Category.find 4
|
53
|
+
|
54
|
+
# Find category 4 (Technology) and 1 (Vehicles and Planes)
|
55
|
+
Category.find 4, 1
|
56
|
+
|
57
|
+
```
|
6
58
|
|
7
59
|
## Installation
|
8
60
|
Add this line to your application's Gemfile:
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_static_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mateo Olaya Bernal
|
@@ -58,20 +58,6 @@ dependencies:
|
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
|
-
- !ruby/object:Gem::Dependency
|
62
|
-
name: factory_girl_rails
|
63
|
-
requirement: !ruby/object:Gem::Requirement
|
64
|
-
requirements:
|
65
|
-
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
67
|
-
version: '0'
|
68
|
-
type: :development
|
69
|
-
prerelease: false
|
70
|
-
version_requirements: !ruby/object:Gem::Requirement
|
71
|
-
requirements:
|
72
|
-
- - ">="
|
73
|
-
- !ruby/object:Gem::Version
|
74
|
-
version: '0'
|
75
61
|
description: |-
|
76
62
|
Create models with static data provided by YAML file stored
|
77
63
|
locally, is useful for models like categories to store data
|
@@ -179,7 +165,7 @@ rubyforge_project:
|
|
179
165
|
rubygems_version: 2.5.1
|
180
166
|
signing_key:
|
181
167
|
specification_version: 4
|
182
|
-
summary:
|
168
|
+
summary: StatucRecord add functionalities for reading model data form a static YAML
|
183
169
|
file.
|
184
170
|
test_files:
|
185
171
|
- spec/dummy/app/assets/config/manifest.js
|