local_model 0.1.3 → 0.1.4
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/README.md +30 -0
- data/lib/local_model.rb +1 -1
- data/lib/local_model/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32aaa0557b37154955a584e86ddafab8b7dc5dac3731f77edb0817beeb511739
|
4
|
+
data.tar.gz: 731283ec3e8f5577551247b006d29f919cc22dc5bbef5726ee60e008f19fe35b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af60390ff697de0be4c0b873af689ce0ad9f8169a883fab25a5b2ff933ce56e3603fa602d76fae1c36f966c71392eb3844c117f6614d228bde7a0c9a5aebc073
|
7
|
+
data.tar.gz: d1e7e26d09cbd221f29ac75ba885577fa78ed01170aeaf1a9c09501b1046f2824a4a1ac807a2ff22373a8c39a584aba4f749795bdc5e7d5d8ba6f29bda1bbb4d
|
data/README.md
CHANGED
@@ -84,6 +84,36 @@ Does not support yet (notably):
|
|
84
84
|
- .build, .update, validations, #<< to add many relationships
|
85
85
|
- object equivalence if gotten from source twice
|
86
86
|
|
87
|
+
|
88
|
+
### Namespace Methods
|
89
|
+
|
90
|
+
```rb
|
91
|
+
|
92
|
+
LocalModel.config do |c|
|
93
|
+
c.path = "/home/me/data/"
|
94
|
+
c.cleanup_on_start = true # delete ALL files in path on startup
|
95
|
+
c.namespace = "InMemory" # Expect ALL LocalModels to be namespaced via this string
|
96
|
+
end
|
97
|
+
|
98
|
+
```
|
99
|
+
|
100
|
+
```rb
|
101
|
+
# in_memory/pokemon.rb
|
102
|
+
|
103
|
+
class InMemory::Pokemon < LocalModel::CSV
|
104
|
+
|
105
|
+
schema do |t|
|
106
|
+
t.string :name
|
107
|
+
t.string :nickname
|
108
|
+
t.integer :hp
|
109
|
+
t.string :species
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
```
|
116
|
+
|
87
117
|
## Development
|
88
118
|
|
89
119
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/local_model.rb
CHANGED
@@ -45,7 +45,7 @@ module LocalModel
|
|
45
45
|
@@namespace = configuration.namespace
|
46
46
|
Dir.mkdir(configuration.path) unless Dir.exist?(configuration.path)
|
47
47
|
if configuration.cleanup_on_start
|
48
|
-
Dir.foreach do |f|
|
48
|
+
Dir.foreach(configuration.path) do |f|
|
49
49
|
fn = File.join(configuration.path, f)
|
50
50
|
File.delete(fn) if f != '.' && f != '..'
|
51
51
|
end
|
data/lib/local_model/version.rb
CHANGED