active-orient 0.5 → 0.6

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +3 -2
  3. data/README.md +78 -35
  4. data/VERSION +1 -1
  5. data/active-orient.gemspec +4 -4
  6. data/bin/active-orient-console +8 -5
  7. data/config/boot.rb +2 -4
  8. data/config/config.yml +1 -1
  9. data/config/connect.yml +2 -2
  10. data/examples/time_graph.md +162 -0
  11. data/gratefuldeadconcerts.md +94 -0
  12. data/lib/active-orient.rb +4 -2
  13. data/lib/base.rb +53 -20
  14. data/lib/base_properties.rb +2 -3
  15. data/lib/class_utils.rb +3 -4
  16. data/lib/database_utils.rb +14 -5
  17. data/lib/init.rb +11 -1
  18. data/lib/model/edge.rb +12 -10
  19. data/lib/model/model.rb +17 -3
  20. data/lib/model/the_class.rb +60 -40
  21. data/lib/model/the_record.rb +63 -51
  22. data/lib/model/vertex.rb +114 -10
  23. data/lib/orient.rb +24 -33
  24. data/lib/orientdb_private.rb +31 -31
  25. data/lib/other.rb +55 -5
  26. data/lib/rest/change.rb +17 -4
  27. data/lib/rest/create.rb +38 -24
  28. data/lib/rest/delete.rb +3 -2
  29. data/lib/rest/operations.rb +37 -27
  30. data/lib/rest/read.rb +2 -2
  31. data/lib/rest/rest.rb +4 -3
  32. data/lib/support.rb +17 -16
  33. data/linkmap.md +75 -0
  34. data/namespace.md +111 -0
  35. data/rails.md +125 -0
  36. data/rails/activeorient.rb +53 -0
  37. data/{examples/time_graph/config → rails}/config.yml +3 -1
  38. data/{examples/time_graph/config → rails}/connect.yml +2 -2
  39. data/usecase_oo.md +3 -1
  40. metadata +21 -38
  41. data/examples/createTime.rb +0 -91
  42. data/examples/time_graph/Gemfile +0 -21
  43. data/examples/time_graph/Guardfile +0 -26
  44. data/examples/time_graph/README.md +0 -129
  45. data/examples/time_graph/bin/active-orient-console +0 -35
  46. data/examples/time_graph/config/boot.rb +0 -119
  47. data/examples/time_graph/config/init_db.rb +0 -59
  48. data/examples/time_graph/createTime.rb +0 -51
  49. data/examples/time_graph/lib/createTime.rb +0 -82
  50. data/examples/time_graph/model/day_of.rb +0 -3
  51. data/examples/time_graph/model/e.rb +0 -6
  52. data/examples/time_graph/model/edge.rb +0 -53
  53. data/examples/time_graph/model/monat.rb +0 -19
  54. data/examples/time_graph/model/stunde.rb +0 -16
  55. data/examples/time_graph/model/tag.rb +0 -29
  56. data/examples/time_graph/model/time_base.rb +0 -6
  57. data/examples/time_graph/model/time_of.rb +0 -4
  58. data/examples/time_graph/model/v.rb +0 -3
  59. data/examples/time_graph/model/vertex.rb +0 -32
  60. data/examples/time_graph/spec/lib/create_time_spec.rb +0 -50
  61. data/examples/time_graph/spec/rest_helper.rb +0 -37
  62. data/examples/time_graph/spec/spec_helper.rb +0 -46
  63. data/usecase.md +0 -104
@@ -1,51 +0,0 @@
1
- #require 'time'
2
-
3
-
4
-
5
- class CreateTime
6
- class << self # singleton class
7
- def populate_month year = Date.today.year, month = Date.today.month
8
- timestamp = DateTime.new year, month,1
9
- if Monat.where( :value => month ).blank?
10
- der_monat= Monat.create value_string: timestamp.strftime("%B"), value: timestamp.month.to_i
11
- last_month_day = (DateTime.new( year, month+1, 1)-1).day rescue 31 # rescue covers month > 12
12
- (0 .. last_month_day ).each do | tag |
13
- der_tag = Tag.create value_string: "March #{timestamp.day}", value: tag
14
- print der_tag.value.to_s + " > "
15
- ( 0 .. 23 ).each do | stunde |
16
- die_stunde = Stunde.create value_string: "March #{timestamp.day} #{timestamp.hour}:00", value: stunde
17
- print die_stunde.value.to_s + " .. "
18
- TIME_OF.create_edge from: der_tag, to: die_stunde
19
- timestamp += Rational(1,24) # + 1 hour
20
- end
21
- print "\n"
22
- DAY_OF.create_edge from: der_monat, to: der_tag
23
- end
24
- else
25
- "Month #{timestamp.strftime("%B %Y ") } exists "
26
- end
27
- end
28
- end
29
- end # class
30
-
31
- ## here we start if the file is called from the command-lind
32
- if $0 == __FILE__
33
- require './config/boot'
34
- ActiveOrient::OrientSetup.init_database # --> config/init_db
35
- CreateTime.populate_month
36
-
37
-
38
-
39
- puts "Features of the DateTime Graph"
40
- puts '-' * 40
41
- puts
42
- puts "Allocated Month => Monat.first.value :" + Monat.first.value.to_s
43
- puts
44
- puts "Adressing Days => Monat.first.tag[2].value:" + Monat.first.tag[2].value.to_s
45
- puts
46
- puts "Adressing Hours => Monat.first.tag[2].stunde[4].value :" + Monat.first.tag[5].stunde[4].value.to_s
47
-
48
-
49
-
50
-
51
- end
@@ -1,82 +0,0 @@
1
- #require 'time'
2
-
3
-
4
-
5
- class CreateTime
6
- class << self # singleton class
7
- ## simple version: connecting vertices as they are created
8
- def pop_month year = Date.today.year, month = Date.today.month
9
- timestamp = DateTime.new year, month,1
10
- if Monat.where( :value => month ).blank?
11
- der_monat= Monat.create value_string: timestamp.strftime("%B"), value: timestamp.month.to_i
12
- last_month_day = (DateTime.new( year, month+1, 1)-1).day rescue 31 # rescue covers month > 12
13
- (0 .. last_month_day ).each do | tag |
14
- der_tag = Tag.create value_string: "March #{timestamp.day}", value: tag
15
- print der_tag.value.to_s + " > "
16
- ( 0 .. 23 ).each do | stunde |
17
- die_stunde = Stunde.create value_string: "March #{timestamp.day} #{timestamp.hour}:00", value: stunde
18
- print die_stunde.value.to_s + " .. "
19
- TIME_OF.create_edge from: der_tag, to: die_stunde
20
- timestamp += Rational(1,24) # + 1 hour
21
- end
22
- print "\n"
23
- DAY_OF.create_edge from: der_monat, to: der_tag
24
- end
25
- else
26
- "Month #{timestamp.strftime("%B %Y ") } exists "
27
- end
28
- end
29
- ## we populate the graph with a 1:n-Layer
30
- # month --> n[day --> n[hour] ]
31
- # thus creating edges is providing a static :from-vertex to numerous :to-vertices
32
- # the to:vertices are first created and fenced in an array. Then all edges are created at once.
33
- # In Rest-Mode this is much quicker.
34
- def populate_month year = Date.today.year, month = Date.today.month
35
- timestamp = DateTime.new year, month,1
36
- days = []
37
- if Monat.where( :value => month ).blank?
38
- der_monat= Monat.create value_string: timestamp.strftime("%B"), value: timestamp.month.to_i
39
- last_month_day = (DateTime.new( year, month+1, 1)-1).day rescue 31 # rescue covers month > 12
40
- (0 .. last_month_day ).each do | tag |
41
- der_tag = Tag.create value_string: "March #{timestamp.day}", value: tag
42
- edges = []
43
- ( 0 .. 23 ).each do | stunde |
44
- edges << Stunde.create( value_string: "March #{timestamp.day} #{timestamp.hour}:00", value: stunde)
45
- timestamp += Rational(1,24) # + 1 hour
46
- end
47
- ## insert all edges of the day as batch (in rest-mode)
48
- TIME_OF.create from: der_tag, to: edges
49
- days << der_tag
50
- end
51
- DAY_OF.create from: der_monat, to: days
52
- else
53
- "Month #{timestamp.strftime("%B %Y ") } exists "
54
- end
55
- end
56
- end
57
- end # class
58
-
59
- ## here we start if the file is called from the command-lind
60
- if $0 == __FILE__
61
- require './config/boot'
62
- ActiveOrient::OrientSetup.init_database # --> config/init_db
63
- CreateTime.populate_month
64
-
65
-
66
- print "\n" * 4
67
- puts '-' * 40
68
- puts "Features of the DateTime Graph"
69
- puts '-' * 40
70
- puts
71
- puts "Allocated Month => Monat.first.value:\t\t" + Monat.first.value.to_s
72
- puts
73
- puts "Adressing Days => Monat.first.tag[2].value:\t" + Monat.first.tag[2].value.to_s
74
- puts
75
- puts "Display Date => Monat.first.tag[13].datum:\t"+ Monat.first.tag[13].datum.to_s
76
-
77
- puts "Display next Date => Monat.first.tag[13].next.datum:\t"+ Monat.first.tag[13].next.datum.to_s
78
-
79
-
80
-
81
-
82
- end
@@ -1,3 +0,0 @@
1
- class DAY_OF < E
2
-
3
- end
@@ -1,6 +0,0 @@
1
- class E < ActiveOrient::Model
2
- ## Edges are referenced with UPCASE-NAMES ---> went to config/boot.rb
3
- # def self.naming_convention name=nil
4
- # name.present? ? name.upcase : ref_name.upcase
5
- # end
6
- end
@@ -1,53 +0,0 @@
1
- # to do
2
- # instead of creating a class, use a module which is included on startup
3
- # then, after specifying the namespace and before autoaccolating the database-classes create the proper E-Base-class and include this stuff
4
- class E < ActiveOrient::Model
5
- ## link to the library-class
6
- class << self
7
- =begin
8
- establish contrains on Edges
9
-
10
- Edges are uniq!
11
-
12
- Creates individual indices for child-classes if applied to the class itself.
13
- =end
14
- def uniq_index
15
- create_property :in, type: :link, linked_class: :V
16
- create_property :out, type: :link, linked_class: :V
17
- create_index "#{self.name}_idx", on: [ :in, :out ]
18
- end
19
- =begin
20
- Instantiate a new Edge between two Vertices
21
-
22
- The parameters »from« **or** »to« can take a list of model-records. Then subsequent edges are created.
23
-
24
- :call-seq:
25
- Model.create from:, to:, attributes:{}
26
- =end
27
-
28
-
29
- def create **keyword_arguments
30
- new_edge = db.create_edge self, **keyword_arguments
31
- new_edge = new_edge.pop if new_edge.is_a?( Array) && new_edge.size == 1
32
- # vertices must be reloaded
33
-
34
- new_edge # returns the created edge (or an array of created edges
35
- end
36
-
37
- # to do
38
- # def delete
39
- # delete an edge (as class method)
40
- # and
41
- # def remove
42
- # delete an edge (as instance method)
43
- #
44
- def delete where: attributes
45
- puts "work in progress"
46
- end
47
-
48
- # remove works on record-level
49
- end
50
- def remove
51
- db.delete_edge self
52
- end
53
- end
@@ -1,19 +0,0 @@
1
- #ActiveOrient::Model.orientdb_class name: 'time_base', superclass: 'V'
2
- class Monat < TimeBase
3
- def der_tag d
4
- # d=d-1
5
- d >0 && d<31 ? out_day_of[d].in : nil
6
- end
7
-
8
- # returns an array of days
9
- # thus enables the use as
10
- # Monat[9].tag[9]
11
- def tag
12
- out_day_of.in
13
- end
14
-
15
- # returns the specified edge
16
- # i.e. Monat[9]
17
- #
18
-
19
- end
@@ -1,16 +0,0 @@
1
- class Stunde < TimeBase
2
-
3
- def tag
4
- in_time_of.out
5
- end
6
-
7
- def datum
8
- month = in_time_of.out.in_day_of.out.value
9
- day = in_time_of.out.value
10
- "#{day.first}.#{month.flatten.first}.#{Date.today.year} #{value}:00"
11
- end
12
- def next
13
- puts value.inspect
14
- in_day_of.out.first.tag( value + 1 )
15
- end
16
- end
@@ -1,29 +0,0 @@
1
- #ActiveOrient::Model.orientdb_class name: 'time_base', superclass: 'V'
2
- class Tag < TimeBase
3
- def monat
4
- in_day_of.out.value_string.first
5
- end
6
-
7
- def die_stunde h
8
- h.to_i >0 && h.to_i<31 ? out_time_of[h].in : nil
9
- end
10
-
11
-
12
- def stunde
13
- out_time_of.in
14
- end
15
-
16
- def monat
17
- in_day_of.out.first
18
- end
19
- def next
20
- monat.tag[ value + 1 ]
21
- end
22
- def prev
23
- monat.tag[ value - 1 ]
24
- end
25
-
26
- def datum
27
- "#{ value}.#{monat.value}.#{Date.today.year}"
28
- end
29
- end
@@ -1,6 +0,0 @@
1
- class TimeBase < V
2
-
3
- def self.[] key
4
- where( value: key).first
5
- end
6
- end
@@ -1,4 +0,0 @@
1
- #ActiveOrient::Model.orientdb_class name: 'time_base', superclass: 'V'
2
- class TIME_OF < E
3
-
4
- end
@@ -1,3 +0,0 @@
1
- class V < ActiveOrient::Model
2
- # placeholder for project-specific methods on vertices
3
- end
@@ -1,32 +0,0 @@
1
- class V < ActiveOrient::Model
2
- ## link to the library-class
3
- # create
4
- # seems not to be nessesary as its identically to the universal create
5
-
6
-
7
- # to do
8
-
9
- # def delete
10
- # delete an edge (as class method)
11
- # and
12
- # def remove
13
- # delete an edge (as instance method)
14
-
15
- def edges kind=:all # :all, :in, :out
16
- expression = case kind
17
- when :all
18
- /^in|^out/
19
- when :in
20
- /^in/
21
- when :out
22
- /^out/
23
- end
24
- edges = attributes.keys.find_all{ |x| x =~ expression }
25
- edges.map{|x| attributes[x]}.flatten
26
- end
27
-
28
- def remove
29
- db.delete_vertex self
30
- end
31
-
32
- end
@@ -1,50 +0,0 @@
1
- require 'spec_helper'
2
- require 'rest_helper'
3
-
4
- describe CreateTime do
5
- before( :all ) do
6
- reset_database
7
- ActiveOrient::OrientSetup.init_database
8
- end
9
- context "check environment" do
10
- it "nessesary classes are allocated" do
11
- [ Monat, Tag, Stunde ].each do | klass |
12
- expect( klass.superclass).to eq TimeBase
13
- end
14
- end
15
- end
16
-
17
- context "populate" do
18
- before( :all ) do
19
- CreateTime.populate_month
20
- end
21
- let( :month){ Date.today.month }
22
-
23
- it "The actual Month is used" do
24
- expect( Monat.count ).to eq 1
25
- expect( Monat.first.value ).to eq Date.today.month
26
- end
27
-
28
- it "The actual Month has several days" do
29
- expect( Monat.first.tag.count ).to be >= 28
30
- end
31
-
32
- it "Address a specific day", focus: true do
33
-
34
- expect( Monat[month].tag[5].value ).to eq 5
35
- end
36
-
37
- it "Address a specific hour" do
38
- expect( Monat[month].tag[5].value ).to eq 5
39
- expect( Monat[month].tag[7].stunde[5].value ).to eq 5
40
- end
41
- it "Switch to the next hour" do
42
-
43
- expect( Monat[month].tag[7].stunde[5].next.value ).to eq 6
44
- end
45
- end
46
-
47
-
48
-
49
-
50
- end
@@ -1,37 +0,0 @@
1
- # deletes the working database and recreates it
2
- # reassignes ORD and DB
3
- def reset_database
4
- db = ActiveOrient.database
5
-
6
- # ORD.database_classes.reverse.each do | klass_name |
7
- # klass = ActiveOrient::Model.orientdb_class name: klass_name
8
- # klass.delete_class rescue nil
9
- # end
10
- ORD.delete_database database: db
11
- Object.send :remove_const, :ORD
12
- Object.send :remove_const, :DB
13
- ActiveOrient.database = db
14
- Object.send :const_set, :ORD, ActiveOrient::OrientDB.new( preallocate: true )
15
- if OrientDB::UsingJava
16
- Object.send :const_set, :DB, ActiveOrient::API.new( preallocate: false)
17
- else
18
- Object.send :const_set, :DB, ActiveOrient::OrientDB.new( preallocate: true )
19
- end
20
- end
21
-
22
-
23
- shared_examples_for 'correct allocated classes' do |input|
24
- it "has allocated all classes" do
25
- case input
26
- when Array
27
- input.each{|y| expect( ORD.database_classes ).to include ORD.classname(y) }
28
- expect( classes ).to have( input.size ).items
29
- when Hash
30
- else
31
- expect( classes ).to be_kind_of ActiveOrient::Model
32
-
33
- end
34
- end
35
-
36
- end
37
-
@@ -1,46 +0,0 @@
1
- ARGV << 'test'
2
- @do_not_preallocate = true
3
- require './config/boot'
4
- #bundler/setup'
5
- require 'rspec'
6
- require 'rspec/its'
7
- require 'rspec/collection_matchers'
8
- require 'yaml'
9
- require 'active_support'
10
- project_root = File.expand_path('../..', __FILE__)
11
- #require 'my_spec_helper'
12
-
13
- unless defined?(SPEC_HELPER_LOADED)
14
- SPEC_HELPER_LOADED = true
15
- RSpec.configure do |config|
16
- config.mock_with :rspec
17
- config.color = true
18
- # ermöglicht die Einschränkung der zu testenden Specs
19
- # durch >>it "irgendwas", :focus => true do <<
20
- config.filter_run :focus => true
21
- config.run_all_when_everything_filtered = true
22
- config.order = 'defined' # "random"
23
- end
24
-
25
- RSpec.shared_context 'private', private: true do
26
-
27
- before :all do
28
- described_class.class_eval do
29
- @original_private_instance_methods = private_instance_methods
30
- public *@original_private_instance_methods
31
- end
32
- end
33
-
34
- after :all do
35
- described_class.class_eval do
36
- private *@original_private_instance_methods
37
- end
38
- end
39
-
40
- end
41
- else
42
- puts "*** ---- *** \n"*3
43
- puts "Reusing rspec configuration "
44
- puts "*** ---- *** \n"*3
45
- end
46
- #require 'model_helper'