whales 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 +33 -0
- data/exe/whales +8 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d8f2f14f3cf26ac324a29bbffc1bd27d074a59a
|
4
|
+
data.tar.gz: d1fddc3bcbf22c047ef0cbf05e19a096f0a666fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a067b04c92ee894fa495ee8209ff022ff786e5f441dbe61fc626260b5754a16018a5dfb0297d4ae3f08bc59ccc1be0a12e0a67215a3c483b09f644c59580868
|
7
|
+
data.tar.gz: 9d6e9a9b8e4d02c842a842b2029b709739f0416a5e5cf4561f8426fe524f35e392c7e09be3019da7162b68bc71fedc38576cf79c42ac70cbc74c5a8009bd3df5
|
data/README.md
CHANGED
@@ -32,6 +32,7 @@ whales server
|
|
32
32
|
WhalesORM is the object-relational mapper behind Whales. It connects to a SQLite
|
33
33
|
database that the user can create and modify in their `db/database.sql` file.
|
34
34
|
|
35
|
+
####`WhalesORM::Base`####
|
35
36
|
The features of WhalesORM are accessed by making a class that inherits from
|
36
37
|
`WhalesORM::Base`. The base class provides the following methods:
|
37
38
|
|
@@ -64,3 +65,35 @@ camel-cased class name.
|
|
64
65
|
`update`.
|
65
66
|
|
66
67
|
`#update`: updates the object's entry in the database
|
68
|
+
|
69
|
+
####`WhalesORM::QueryMethods`####
|
70
|
+
`WhalesORM::Base` gains additional methods by extending the `WhalesORM::QueryMethods`
|
71
|
+
module.
|
72
|
+
|
73
|
+
`::where(params)`: gets objects from the database that match the given params hash.
|
74
|
+
This method is chainable and lazy-evaluating.
|
75
|
+
|
76
|
+
This is implemented using a `WhalesORM::Relation` class that inherits from Ruby's
|
77
|
+
`BasicObject`. It puts off the database call until it gets a method call it doesn't
|
78
|
+
recognize.
|
79
|
+
|
80
|
+
```ruby
|
81
|
+
module WhalesORM
|
82
|
+
class Relation < BasicObject
|
83
|
+
...
|
84
|
+
def method_missing(method, *args, &blk)
|
85
|
+
results = self.execute
|
86
|
+
results.send(method, *args, &blk)
|
87
|
+
end
|
88
|
+
...
|
89
|
+
end
|
90
|
+
end
|
91
|
+
```
|
92
|
+
|
93
|
+
`::includes(relation)`: helps to prevent N+1 queries by including the given relation
|
94
|
+
in the query. Also lazy-evaluating.
|
95
|
+
|
96
|
+
####`WhalesORM::Associatable`####
|
97
|
+
`WhalesORM::Base` also extends `WhalesORM::Associatable`.
|
98
|
+
|
99
|
+
`::belongs_to(relation_name)`: associates the class to `relation_name` via a foreign key `relation_name_id` so that the method `#relation_name` returns an object of class `relation_name` with id equal to `relation__name_id`
|
data/exe/whales
CHANGED
@@ -49,18 +49,18 @@ when 'new'
|
|
49
49
|
touch "routes.rb", display
|
50
50
|
|
51
51
|
File.open("routes.rb", 'w') do |f|
|
52
|
-
f.write File.read(File.
|
52
|
+
f.write File.read(File.expand_path('../template/routes.rb', __FILE__))
|
53
53
|
end
|
54
54
|
|
55
55
|
touch "Gemfile", display
|
56
56
|
File.open("Gemfile", "w") do |f|
|
57
|
-
f.write File.read(File.
|
57
|
+
f.write File.read(File.expand_path('../template/Gemfile', __FILE__))
|
58
58
|
end
|
59
59
|
|
60
60
|
mkdir "config", display
|
61
61
|
touch "config/database.rb", display
|
62
62
|
File.open("config/database.rb", "w") do |f|
|
63
|
-
f.write File.read(File.
|
63
|
+
f.write File.read(File.expand_path('../template/database.rb', __FILE__))
|
64
64
|
end
|
65
65
|
|
66
66
|
mkdir "db", display
|
@@ -75,7 +75,11 @@ when 'new'
|
|
75
75
|
|
76
76
|
cd 'app'
|
77
77
|
mkdir 'models', display
|
78
|
-
mkdir 'views'
|
78
|
+
mkdir 'views', display
|
79
|
+
mkdir 'assets', display
|
80
|
+
cd 'assets'
|
81
|
+
mkdir 'assets/stylesheets'
|
82
|
+
mkdir 'assets/javascripts'
|
79
83
|
when "server" || "s"
|
80
84
|
require_relative pwd + "/routes"
|
81
85
|
require_relative "../server"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whales
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Horton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-12-
|
11
|
+
date: 2015-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.1.
|
47
|
+
version: 0.1.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.1.
|
54
|
+
version: 0.1.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: whales_orm
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.1.
|
61
|
+
version: 0.1.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.1.
|
68
|
+
version: 0.1.4
|
69
69
|
description:
|
70
70
|
email:
|
71
71
|
- wdt.horton@gmail.com
|