active-orient 0.5 → 0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/README.md +78 -35
- data/VERSION +1 -1
- data/active-orient.gemspec +4 -4
- data/bin/active-orient-console +8 -5
- data/config/boot.rb +2 -4
- data/config/config.yml +1 -1
- data/config/connect.yml +2 -2
- data/examples/time_graph.md +162 -0
- data/gratefuldeadconcerts.md +94 -0
- data/lib/active-orient.rb +4 -2
- data/lib/base.rb +53 -20
- data/lib/base_properties.rb +2 -3
- data/lib/class_utils.rb +3 -4
- data/lib/database_utils.rb +14 -5
- data/lib/init.rb +11 -1
- data/lib/model/edge.rb +12 -10
- data/lib/model/model.rb +17 -3
- data/lib/model/the_class.rb +60 -40
- data/lib/model/the_record.rb +63 -51
- data/lib/model/vertex.rb +114 -10
- data/lib/orient.rb +24 -33
- data/lib/orientdb_private.rb +31 -31
- data/lib/other.rb +55 -5
- data/lib/rest/change.rb +17 -4
- data/lib/rest/create.rb +38 -24
- data/lib/rest/delete.rb +3 -2
- data/lib/rest/operations.rb +37 -27
- data/lib/rest/read.rb +2 -2
- data/lib/rest/rest.rb +4 -3
- data/lib/support.rb +17 -16
- data/linkmap.md +75 -0
- data/namespace.md +111 -0
- data/rails.md +125 -0
- data/rails/activeorient.rb +53 -0
- data/{examples/time_graph/config → rails}/config.yml +3 -1
- data/{examples/time_graph/config → rails}/connect.yml +2 -2
- data/usecase_oo.md +3 -1
- metadata +21 -38
- data/examples/createTime.rb +0 -91
- data/examples/time_graph/Gemfile +0 -21
- data/examples/time_graph/Guardfile +0 -26
- data/examples/time_graph/README.md +0 -129
- data/examples/time_graph/bin/active-orient-console +0 -35
- data/examples/time_graph/config/boot.rb +0 -119
- data/examples/time_graph/config/init_db.rb +0 -59
- data/examples/time_graph/createTime.rb +0 -51
- data/examples/time_graph/lib/createTime.rb +0 -82
- data/examples/time_graph/model/day_of.rb +0 -3
- data/examples/time_graph/model/e.rb +0 -6
- data/examples/time_graph/model/edge.rb +0 -53
- data/examples/time_graph/model/monat.rb +0 -19
- data/examples/time_graph/model/stunde.rb +0 -16
- data/examples/time_graph/model/tag.rb +0 -29
- data/examples/time_graph/model/time_base.rb +0 -6
- data/examples/time_graph/model/time_of.rb +0 -4
- data/examples/time_graph/model/v.rb +0 -3
- data/examples/time_graph/model/vertex.rb +0 -32
- data/examples/time_graph/spec/lib/create_time_spec.rb +0 -50
- data/examples/time_graph/spec/rest_helper.rb +0 -37
- data/examples/time_graph/spec/spec_helper.rb +0 -46
- data/usecase.md +0 -104
data/usecase.md
DELETED
@@ -1,104 +0,0 @@
|
|
1
|
-
## Usecase
|
2
|
-
Below some typical features are summarized by example
|
3
|
-
|
4
|
-
Initialize ActiveOrient by calling »bin/active-orient-console t«.
|
5
|
-
This connects to the Test-Database, specified in »config/connect.yml«.
|
6
|
-
|
7
|
-
```bash
|
8
|
-
topo@gamma:~/activeorient/bin$ ./active-orient-console t
|
9
|
-
Using test-environment
|
10
|
-
30.06.(21:36:09) INFO->OrientDB#Connect:..:Connected to database tempera
|
11
|
-
ORD points to the REST-Instance
|
12
|
-
Allocated Classes (Hierarchy)
|
13
|
-
-----------------------------------
|
14
|
-
---
|
15
|
-
- E
|
16
|
-
- - V
|
17
|
-
- - a
|
18
|
-
- b
|
19
|
-
- c
|
20
|
-
|
21
|
-
```
|
22
|
-
The database is almost empty. "E" and "V" are base classes for Edges and Vertices.
|
23
|
-
"a,b,c" are Vertex-Classes.
|
24
|
-
```ruby
|
25
|
-
A,B,C = * ORD.create_classes( [ :a, :b, :c ] ){ :v }
|
26
|
-
```
|
27
|
-
creates them with a single statement and assigns them to Ruby-classes "A","B" and "C".
|
28
|
-
|
29
|
-
#### Object Mapping
|
30
|
-
Lets create a class, put some content in it and perform basic oo-steps.
|
31
|
-
|
32
|
-
Attributes(Properties) do not have to be formaly declared. One can save any Object, which
|
33
|
-
provides a 'to_orient' method. Base-Classes are supported out of the box.
|
34
|
-
»update«
|
35
|
-
|
36
|
-
``` ruby
|
37
|
-
A = ORD.create_class 'my_a_class'
|
38
|
-
=> ActiveOrient::Model::MyAClass
|
39
|
-
a = A.create test: 45
|
40
|
-
a.update set: { a_array: aa= [ 1,4,'r' ] ,
|
41
|
-
a_hash: { :a => 'b', b: 2 } }
|
42
|
-
a.to_human
|
43
|
-
=> <MyAClass: a_array: [1, 4, r], a_hash: { a => b , b =>2}, test: 45>
|
44
|
-
|
45
|
-
```
|
46
|
-
**Notice** Ruby-Symbols are converted to Strings and masked as ":{symbol}:".
|
47
|
-
|
48
|
-
Attibutes/properties of the Database-Record can be handled as normal ruby objects, ie.
|
49
|
-
|
50
|
-
``` ruby
|
51
|
-
a.a_array << "a new element" # changes are updated in the DB, calling »update« is not nesessary
|
52
|
-
a.a_hash[ :a_new_element ] = "value of the new element" # changes are local, »update« stores them in the DB
|
53
|
-
a.test += 3
|
54
|
-
a.test = 567
|
55
|
-
a.update
|
56
|
-
```
|
57
|
-
|
58
|
-
#### Contracts-Example
|
59
|
-
Assume a Database, which is defined as
|
60
|
-
```
|
61
|
-
ORD.create_classes [ :Industry, :Category, :SubCategory ]
|
62
|
-
ORD.create_class :OpenInterest, abstract: true
|
63
|
-
ORD.create_classes { :Contract => [ :Stock, Future, Option, Forex ]}
|
64
|
-
ORD.create_property Industry.categories linkset
|
65
|
-
ORD.create_property Category.subcategories linkset
|
66
|
-
ORD.create_property Category.industry link
|
67
|
-
ORD.create_property SubCategory.category link
|
68
|
-
ORD.create_property SubCategory.contracts linkset
|
69
|
-
|
70
|
-
ORD.create_property Contracts.subcategory link
|
71
|
-
ORD.create_property Contracts.details link
|
72
|
-
ORD.create_property OpenInterest.contracts linkset
|
73
|
-
|
74
|
-
```
|
75
|
-
This defines some conventional relations:
|
76
|
-
|
77
|
-
OpenInterest -> Contract <- Subcategory <- Category <- Industry
|
78
|
-
|
79
|
-
with some oo-Behavior
|
80
|
-
```ruby
|
81
|
-
2.2.1 :003 > ror.class_hierachie base_class: 'Contracts'
|
82
|
-
=> ["Forexes", "Futures", "Options", "Stocks"]
|
83
|
-
```
|
84
|
-
|
85
|
-
then the following ORM-behavior is implemented:
|
86
|
-
```ruby
|
87
|
-
topo@gamma:~/new_hctw$ irb
|
88
|
-
2.2.1 :001 > require './config/boot'
|
89
|
-
Using development-environment
|
90
|
-
-------------------- initialize -------------------- => true
|
91
|
-
2.2.1 :002 > ActiveOrient::Model.orientdb = ror = ActiveOrient::OrientDB.new
|
92
|
-
=> #<ActiveOrient::OrientDB:0x000000046f1a90 @res=#<RestClient::Resource:0x000000046c0af8 @url="http://localhost:2480", @block=nil, @options={:user=>"hctw", :password=>"**"}>, @database="hc_database", @classes=[]>
|
93
|
-
2.2.1 :003 > OpenInterest = ror.open_class 'Openinterest'
|
94
|
-
=> ActiveOrient::Model::Openinterest
|
95
|
-
2.2.1 :004 > first_open_interest = OpenInterest.first
|
96
|
-
=> #<ActiveOrient::Model::Openinterest:0x0000000443ede8 @metadata={"type"=>"d", "class"=>"Openinterest", "version"=>5, "fieldTypes"=>"fetch_date=t,contracts=z", "cluster"=>13, "record"=>0}, @attributes={"fetch_date"=>"2015-06-02 00:00:00", "contracts"=>["#21:36", "#21:35", "#21:34", "#21:33", "#21:32", "#21:31", "#21:30", "#21:29", "#21:28", "#21:27", "#21:26", "#21:25", "#21:24", "#21:23", "#21:22", "#21:21", "#21:51", "#21:49", "#21:50", "#21:47", "#21:48", "#21:45", "#21:46", "#21:43", "#21:44", "#21:41", "#21:42", "#21:39", "#21:40", "#21:37", "#21:38", "#21:4", "#21:3", "#21:0", "#21:17", "#21:18", "#21:19", "#21:20", "#21:13", "#21:14", "#21:15", "#21:16", "#21:9", "#21:10", "#21:11", "#21:12", "#21:5", "#21:6", "#21:7", "#21:8"], "created_at"=>2015-07-01 15:27:41 +0200, "updated_at"=>2015-07-01 15:27:41 +0200}>
|
97
|
-
2.2.1 :005 > first_open_interest.contracts.first.subcategory.category.industry
|
98
|
-
=> #<ActiveOrient::Model::Industries:0x00000004af88f0 @metadata={"type"=>"d", "class"=>"Industries", "version"=>8, "fieldTypes"=>"categories=n", "cluster"=>17, "record"=>1}, @attributes={"categories"=>["#15:13", "#15:4", "#15:1"], "name"=>"Basic Materials", "created_at"=>2015-07-01 15:27:58 +0200, "updated_at"=>2015-07-01 15:27:58 +0200}>
|
99
|
-
|
100
|
-
2.2.1 :006 > first_open_interest.contracts.first.subcategory.category.industry.name
|
101
|
-
=> "Basic Materials"
|
102
|
-
```
|
103
|
-
|
104
|
-
|