active-orient 0.79 → 0.80
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.graphs.txt.swp +0 -0
- data/Gemfile +2 -6
- data/README.md +29 -27
- data/VERSION +1 -1
- data/active-orient.gemspec +4 -3
- data/bin/active-orient-console +18 -6
- data/changelog.md +60 -0
- data/config/connect.yml +8 -8
- data/examples/books.rb +134 -97
- data/graphs.txt +70 -0
- data/lib/active-orient.rb +2 -0
- data/lib/base.rb +38 -17
- data/lib/base_properties.rb +15 -14
- data/lib/class_utils.rb +11 -50
- data/lib/database_utils.rb +23 -22
- data/lib/init.rb +4 -3
- data/lib/model/custom.rb +7 -4
- data/lib/model/e.rb +6 -0
- data/lib/model/edge.rb +74 -30
- data/lib/model/the_class.rb +181 -131
- data/lib/model/the_record.rb +115 -68
- data/lib/model/vertex.rb +261 -126
- data/lib/other.rb +93 -41
- data/lib/rest/change.rb +23 -20
- data/lib/rest/create.rb +71 -63
- data/lib/rest/delete.rb +80 -64
- data/lib/rest/operations.rb +79 -68
- data/lib/rest/read.rb +42 -24
- data/lib/rest/rest.rb +38 -30
- data/lib/support/conversions.rb +42 -0
- data/lib/support/default_formatter.rb +7 -0
- data/lib/support/errors.rb +41 -0
- data/lib/support/orient.rb +167 -58
- data/lib/support/orientquery.rb +526 -348
- data/lib/support/query.rb +92 -0
- metadata +34 -18
- data/examples/test_commands.rb +0 -97
- data/examples/test_commands_2.rb +0 -59
- data/examples/test_commands_3.rb +0 -55
- data/examples/test_commands_4.rb +0 -33
- data/examples/time_graph.md +0 -162
data/examples/time_graph.md
DELETED
@@ -1,162 +0,0 @@
|
|
1
|
-
The Time-Graph Example is outsourced and lives as a seperate gem.
|
2
|
-
|
3
|
-
https://github.com/topofocus/orientdb_time_graph
|
4
|
-
|
5
|
-
from the readme:
|
6
|
-
|
7
|
-
# Time Graph
|
8
|
-
|
9
|
-
Simple Time Graph using ActiveOrient/OrientDB.
|
10
|
-
|
11
|
-
*Prerequisites* :
|
12
|
-
* Install and setup OrientDB
|
13
|
-
* Run "Bundle install" and "Bundle update"
|
14
|
-
* customize config/connect.yml
|
15
|
-
|
16
|
-
**or** start a new project and include the gem in the usual manner.
|
17
|
-
|
18
|
-
To play around, start the console by
|
19
|
-
```
|
20
|
-
cd bin
|
21
|
-
./active-orient-console t # test-modus
|
22
|
-
```
|
23
|
-
The Database is automatically initialized and the following hierarchy is build:
|
24
|
-
|
25
|
-
```ruby
|
26
|
-
- E # ruby-class
|
27
|
-
- - month_of TG::MONTH_OF
|
28
|
-
- - day_of TG::DAY_OF
|
29
|
-
- - time_of TG::TIME_OF
|
30
|
-
- - grid_of TG::GRID_OF
|
31
|
-
- V
|
32
|
-
- - time_base TG::TimeBase
|
33
|
-
- - - jahr TG::Jahr
|
34
|
-
- - - monat TG::Monat
|
35
|
-
- - - stunde TG::Stunde
|
36
|
-
- - - tag TG::Tag
|
37
|
-
```
|
38
|
-
This Graph is realized
|
39
|
-
|
40
|
-
```ruby
|
41
|
-
Jahr -- [Month_of] -- Monat --[DAY_OF]-- Tag --[TIME_OF]-- Stunde
|
42
|
-
```
|
43
|
-
and populated by calling
|
44
|
-
|
45
|
-
```ruby
|
46
|
-
TG::TimeGraph.populate( a single year or a range ) # default: 1900 .. 2050
|
47
|
-
```
|
48
|
-
If only one year is specified, a Monat--Tag--Stunde-Grid is build, otherwise a Jahr--Monat--Tag one.
|
49
|
-
You can check the Status by calling
|
50
|
-
|
51
|
-
```ruby
|
52
|
-
TG::TimeGraph.populate 2000 -2003
|
53
|
-
TG.info
|
54
|
-
-------------- TIME GRAPH ------------------
|
55
|
-
Allocated Years :
|
56
|
-
2000; 2001; 2002; 2003
|
57
|
-
|
58
|
-
```
|
59
|
-
In the Model-directory, customized methods simplify the usage of the graph.
|
60
|
-
|
61
|
-
Some Examples:
|
62
|
-
Assuming, you build a standard day-based grid
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
|
66
|
-
include TG # we can omit the TG prefix
|
67
|
-
|
68
|
-
Jahr[2000] # --> returns a single object
|
69
|
-
=> #<TG::Jahr:0x00000004ced160 @metadata={"type"=>"d", "class"=>"jahr", "version"=>13, "fieldTypes"=>"out_month_of=g", "cluster"=>34, "record"=>101}, @d=nil, @attributes={"value"=>2000, "out_month_of"=>["#53:1209", "#54:1209", "#55:1209", "#56:1209", "#53:1210", "#54:1210", "#55:1210", "#56:1210", "#53:1211", "#54:1211", "#55:1211", "#56:1211"], "created_at"=>Fri, 09 Sep 2016 10:14:30 +0200}>
|
70
|
-
|
71
|
-
|
72
|
-
Jahr[2000 .. 2005].value # returns an array
|
73
|
-
=> [2003, 2000, 2004, 2001, 2005, 2002]
|
74
|
-
|
75
|
-
Jahr[2000 .. 2005].monat(5..7).value # returns the result of the month-attribute (or method)
|
76
|
-
=> [[5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7], [5, 6, 7]]
|
77
|
-
|
78
|
-
Jahr[2000].monat(4, 7).tag(4, 15,24 ).datum # adresses methods or attributes of the specified day's
|
79
|
-
=> [["4.4.2000", "15.4.2000", "24.4.2000"], ["4.7.2000", "15.7.2000", "24.7.2000"]]
|
80
|
-
## unfortunatly »Jahr[2000 .. 2015].monat( 3,5 ).tag( 4 ..6 ).datum « does not fits now
|
81
|
-
## instead »Jahr[2000..2015].map{|y| y.monat( 3,5 ).tag( 4 ..6 ).datum } « does the job.
|
82
|
-
```
|
83
|
-
|
84
|
-
To filter datasets in that way, anything represented is queried from the database. In contrast to
|
85
|
-
a pure ruby implementation, this works for small and large grid's.
|
86
|
-
|
87
|
-
Obviously, you can do neat ruby-array playings, which are limited to the usual sizes.
|
88
|
-
For example. As »TAG[31]« returns an array, the elements can be treated with ruby flavour:
|
89
|
-
|
90
|
-
```ruby
|
91
|
-
|
92
|
-
Tag[31][2..4].datum # display three months with 31 days
|
93
|
-
=> ["31.10.1901", "31.1.1902", "31.5.1902"]
|
94
|
-
|
95
|
-
```
|
96
|
-
First all Tag-Objects with the Value 31 are queried. This gives »Jan, Mar, May ..«. Then one can inspect the array, in this case by slicing a range.
|
97
|
-
|
98
|
-
Not surprisingly, the first occurence of the day is not the earliest date in the grid. Its just the first one,
|
99
|
-
fetched from the database.
|
100
|
-
|
101
|
-
``` ruby
|
102
|
-
Tag[1][1].datum
|
103
|
-
=> "1.5.1900" # Tag[1][0] correctly fetches "1.1.1900"
|
104
|
-
Tag[1].last.datum
|
105
|
-
=> "1.11.2050"
|
106
|
-
## however,
|
107
|
-
Jahr[2050].monat(12).tag(1) # exists:
|
108
|
-
=> [["1.12.2050"]]
|
109
|
-
```
|
110
|
-
|
111
|
-
## Horizontal Connections
|
112
|
-
|
113
|
-
Besides the hierarchically TimeGraph »Jahr <-->Monat <--> Tag <--> Stunde« the Vertices are connected
|
114
|
-
horizontally via »grid_to«-Edges. This enables an easy access to the neighbours.
|
115
|
-
|
116
|
-
On the TG::TimeBase-Level a method »environment« is implemented, that gathers the adjacent vertices
|
117
|
-
via traverse.
|
118
|
-
|
119
|
-
``` ruby
|
120
|
-
start = TG::Jahr[2000].monat(4).tag(7).first.first
|
121
|
-
start.environment(3).datum
|
122
|
-
=> ["4.4.2000", "5.4.2000", "6.4.2000", "7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000"]
|
123
|
-
|
124
|
-
2.3.1 :003 > start.environment(3,4).datum
|
125
|
-
=> ["4.4.2000", "5.4.2000", "6.4.2000", "7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000", "11.4.2000"]
|
126
|
-
|
127
|
-
start.environment(0,3).datum
|
128
|
-
=> ["7.4.2000", "8.4.2000", "9.4.2000", "10.4.2000"]
|
129
|
-
```
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
## Diary
|
134
|
-
|
135
|
-
lets create a simple diary
|
136
|
-
|
137
|
-
```ruby
|
138
|
-
include TG
|
139
|
-
TimeiGraph.populate 2016
|
140
|
-
ORD.create_vertex_class :termin
|
141
|
-
=> Termin
|
142
|
-
ORD.create_edge_class :date_of
|
143
|
-
=> DATE_OF
|
144
|
-
DATE_OF.uniq_index # put contrains to the edge-class, accept only one entry per item
|
145
|
-
|
146
|
-
DATE_OF.create from: Monat[8].tag(9).stunde(12),
|
147
|
-
to: Termin.create( short: 'Mittagessen',
|
148
|
-
long: 'Schweinshaxen essen mit Lieschen Müller',
|
149
|
-
location: 'Hofbauhaus, München' )
|
150
|
-
=> #<DATE_OF:0x0000000334e038 (..) @attributes={"out"=>"#21:57", "in"=>"#41:0", (..)}>
|
151
|
-
# create some regular events
|
152
|
-
# attach breakfirst at 9 o clock from the 10th to the 21st Day in the current month
|
153
|
-
DATE_OF.create from: Monat[8].tag(10 .. 21).stunde( 9 ), to: Termin.create( :short => 'Frühstück' )
|
154
|
-
=> #<DATE_OF:0x000000028d5688 @metadata={(..) "cluster"=>45, "record"=>8},
|
155
|
-
@attributes={"out"=>"#22:188", "in"=>"#42:0",(..)}>
|
156
|
-
|
157
|
-
t = Termin.where short: 'Frühstück'
|
158
|
-
t.in_date_of.out.first.datum
|
159
|
-
=> ["10.8.2016 9:00", "11.8.2016 9:00", "12.8.2016 9:00", "13.8.2016 9:00", "14.8.2016 9:00", "15.8.2016 9:00", "16.8.2016 9:00", "17.8.2016 9:00", "18.8.2016 9:00", "19.8.2016 9:00", "20.8.2016 9:00", "21.8.2016 9:00"]
|
160
|
-
|
161
|
-
```
|
162
|
-
|