active-orient 0.4 → 0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/Gemfile +8 -3
  4. data/Guardfile +12 -4
  5. data/README.md +221 -201
  6. data/VERSION +1 -1
  7. data/active-orient.gemspec +3 -2
  8. data/bin/active-orient-console +35 -0
  9. data/config/boot.rb +84 -16
  10. data/config/config.yml +10 -0
  11. data/config/connect.yml +6 -2
  12. data/create_project +19 -0
  13. data/examples/books.rb +86 -39
  14. data/examples/createTime.rb +91 -0
  15. data/examples/streets.rb +85 -84
  16. data/examples/test_commands.rb +92 -0
  17. data/examples/test_commands_2.rb +54 -0
  18. data/examples/test_commands_3.rb +48 -0
  19. data/examples/test_commands_4.rb +28 -0
  20. data/examples/time_graph/Gemfile +21 -0
  21. data/examples/time_graph/Guardfile +26 -0
  22. data/examples/time_graph/README.md +129 -0
  23. data/examples/time_graph/bin/active-orient-console +35 -0
  24. data/examples/time_graph/config/boot.rb +119 -0
  25. data/examples/time_graph/config/config.yml +8 -0
  26. data/examples/time_graph/config/connect.yml +17 -0
  27. data/examples/time_graph/config/init_db.rb +59 -0
  28. data/examples/time_graph/createTime.rb +51 -0
  29. data/examples/time_graph/lib/createTime.rb +82 -0
  30. data/examples/time_graph/model/day_of.rb +3 -0
  31. data/examples/time_graph/model/e.rb +6 -0
  32. data/examples/time_graph/model/edge.rb +53 -0
  33. data/examples/time_graph/model/monat.rb +19 -0
  34. data/examples/time_graph/model/stunde.rb +16 -0
  35. data/examples/time_graph/model/tag.rb +29 -0
  36. data/examples/time_graph/model/time_base.rb +6 -0
  37. data/examples/time_graph/model/time_of.rb +4 -0
  38. data/examples/time_graph/model/v.rb +3 -0
  39. data/examples/time_graph/model/vertex.rb +32 -0
  40. data/examples/time_graph/spec/lib/create_time_spec.rb +50 -0
  41. data/examples/time_graph/spec/rest_helper.rb +37 -0
  42. data/examples/time_graph/spec/spec_helper.rb +46 -0
  43. data/lib/active-orient.rb +56 -6
  44. data/lib/base.rb +149 -147
  45. data/lib/base_properties.rb +40 -41
  46. data/lib/class_utils.rb +301 -0
  47. data/lib/database_utils.rb +97 -0
  48. data/lib/init.rb +35 -0
  49. data/lib/java-api.rb +437 -0
  50. data/lib/jdbc.rb +211 -0
  51. data/lib/model/edge.rb +53 -0
  52. data/lib/model/model.rb +77 -0
  53. data/lib/model/the_class.rb +480 -0
  54. data/lib/model/the_record.rb +310 -0
  55. data/lib/model/vertex.rb +32 -0
  56. data/lib/orient.rb +113 -50
  57. data/lib/orientdb_private.rb +48 -0
  58. data/lib/other.rb +280 -0
  59. data/lib/query.rb +71 -73
  60. data/lib/rest/change.rb +124 -0
  61. data/lib/rest/create.rb +474 -0
  62. data/lib/rest/delete.rb +133 -0
  63. data/lib/rest/operations.rb +150 -0
  64. data/lib/rest/read.rb +150 -0
  65. data/lib/rest/rest.rb +111 -0
  66. data/lib/rest_disabled.rb +24 -0
  67. data/lib/support.rb +387 -296
  68. data/old_lib_functions/two_general_class.rb +139 -0
  69. data/usecase.md +49 -36
  70. data/usecase_oo.md +59 -0
  71. metadata +73 -9
  72. data/lib/model.rb +0 -461
  73. data/lib/rest.rb +0 -1036
  74. data/test.rb +0 -4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4
1
+ 0.5
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.summary = 'Pure ruby client for OrientDB based on ActiveModel'
12
12
  s.description = 'Persistent ORM for OrientDB, based on ActiveModel'
13
13
  s.platform = Gem::Platform::RUBY
14
- s.required_ruby_version = '>= 2.2.0'
14
+ s.required_ruby_version = '>= 2.2.5'
15
15
  s.date = Time.now.strftime "%Y-%m-%d"
16
16
  s.test_files = `git ls-files -- {spec,features}/*`.split("\n")
17
17
  s.require_paths = ["lib"]
@@ -22,6 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency "bundler", "~> 1.8"
23
23
  s.add_development_dependency "rake", "~> 10.0"
24
24
  s.add_dependency 'activesupport', "~> 4.2"
25
- s.add_dependency 'rest-client', "~> 2.0"
25
+ s.add_dependency 'activemodel', "~> 4.2"
26
+ s.add_dependency 'rest-client'
26
27
 
27
28
  end
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ ## loads the active-orient environment
3
+ ## and starts an interactive shell
4
+ ## Parameter: production (p)
5
+ ## development (d) [default]
6
+ ## test (t)
7
+ require 'logger'
8
+ LogLevel = Logger::WARN
9
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
10
+
11
+ require 'orientdb' if RUBY_PLATFORM == 'java'
12
+ require 'yaml'
13
+
14
+ puts "ORD points to the REST-Instance, Database: #{ActiveOrient.database}"
15
+ puts "DB is the API-Instance of the database, DB.db gets the DB-Api-base " if RUBY_PLATFORM == 'java'
16
+
17
+ puts '-'* 35
18
+ ns= case ActiveOrient::Model.namespace
19
+ when Object
20
+ "No Prefix, just ClassName#CamelCase"
21
+ else
22
+ ActiveOrient::Model.namespace.to_s + "{ClassName.camelcase}"
23
+ end
24
+ puts "Namespace for model-classes : #{ns}"
25
+ puts "Allocated Classes (Hierarchy) ( Modelclasses are Camelized ):"
26
+ puts '-'* 35
27
+
28
+ puts ORD.class_hierarchy.to_yaml
29
+
30
+
31
+ include OrientDB
32
+
33
+ require 'irb'
34
+ ARGV.clear
35
+ IRB.start(__FILE__)
@@ -1,24 +1,92 @@
1
1
  require 'bundler/setup'
2
2
  require 'yaml'
3
+ if RUBY_VERSION == 'java'
4
+ require 'orientdb'
5
+ end
3
6
  project_root = File.expand_path('../..', __FILE__)
4
- require "#{project_root}/lib/support.rb"
5
- require "#{project_root}/lib/base.rb"
6
- require "#{project_root}/lib/base_properties.rb"
7
-
8
- require "#{project_root}/lib/model.rb"
9
- require "#{project_root}/lib/orient.rb"
10
- require "#{project_root}/lib/rest.rb"
11
- #require "#{project_root}/lib/graph.rb"
12
-
13
- # require all the models and libraries
14
- libs= Dir.glob(File.join( project_root, "lib",'**', "*rb"))
15
- result = libs.reverse.collect { |file| [file, require( file )] }
16
-
17
- logger = Logger.new '/dev/stdout'
18
- #REST::Graph.logger = logger
19
- ActiveOrient::Model.logger = logger
7
+ require "#{project_root}/lib/active-orient.rb"
8
+ # mixin for define_namespace
9
+ include ActiveOrient::Init
10
+ begin
11
+ connect_file = File.expand_path('../../config/connect.yml', __FILE__)
12
+ config_file = File.expand_path('../../config/config.yml', __FILE__)
13
+ connectyml = YAML.load_file( connect_file )[:orientdb][:admin] if connect_file.present?
14
+ configyml = YAML.load_file( config_file )[:active_orient] if config_file.present?
15
+ databaseyml = YAML.load_file( connect_file )[:orientdb][:database] if connect_file.present?
16
+ rescue Errno::ENOENT => e
17
+ ActiveOrient::Base.logger = Logger.new('/dev/stdout')
18
+ ActiveOrient::OrientDB.logger.error{ "config/connectyml not present" }
19
+ ActiveOrient::OrientDB.logger.error{ "Using defaults to connect database-server" }
20
+
21
+ end
22
+
23
+ e= ARGV.present? ? ARGV.last.downcase : 'development'
24
+ env = if e =~ /^p/
25
+ 'production'
26
+ elsif e =~ /^t/
27
+ 'test'
28
+ else
29
+ 'development'
30
+ end
31
+ puts "Using #{env}-environment"
32
+
33
+ ActiveOrient::Model.model_dir = "#{project_root}/#{ configyml.present? ? configyml[:model_dir] : "model" }"
34
+
35
+ # lib/init.rb
36
+ define_namespace yml: configyml, namespace: @namespace
37
+
38
+
39
+ log_file = if config_file.present?
40
+ dev = YAML.load_file( connect_file )[:orientdb][:logger]
41
+ if dev.blank? || dev== 'stdout'
42
+ '/dev/stdout'
43
+ else
44
+ project_root+'/log/'+env+'.log'
45
+ end
46
+ end
47
+
48
+
49
+ logger = Logger.new log_file
50
+ logger.level = case env
51
+ when 'production'
52
+ Logger::ERROR
53
+ when 'development'
54
+ Logger::WARN
55
+ else
56
+ Logger::INFO
57
+ end
58
+ logger.formatter = proc do |severity, datetime, progname, msg|
59
+ "#{datetime.strftime("%d.%m.(%X)")}#{"%5s" % severity}->#{progname}:..:#{msg}\n"
60
+ end
61
+ ActiveOrient::Base.logger = logger
20
62
  ActiveOrient::OrientDB.logger = logger
21
63
 
64
+ if connectyml.present? and connectyml[:user].present? and connectyml[:pass].present?
65
+ ActiveOrient.default_server= { user: connectyml[:user], password: connectyml[:pass] ,
66
+ server: 'localhost', port: 2480 }
67
+ ActiveOrient.database = @configDatabase.presence || databaseyml[env.to_sym]
68
+
69
+ ORD = ActiveOrient::OrientDB.new preallocate: @do_not_preallocate.present? ? false : true
70
+ if RUBY_PLATFORM == 'java'
71
+ DB = ActiveOrient::API.new preallocate: false
72
+ else
73
+ DB = ORD
74
+ end
75
+ # ActiveOrient::Init.vertex_and_edge_class
76
+
77
+ ORD.create_classes 'E', 'V'
78
+ E.ref_name = 'E'
79
+ V.ref_name = 'V'
80
+ # require model files after initializing the database
81
+ require "#{project_root}/lib/model/edge.rb"
82
+ require "#{project_root}/lib/model/vertex.rb"
83
+ ## attention: if the Egde- or Vertex-Base-Class is deleted (V.delte_class) the model-methods are gone.
84
+ ## After recreating the BaseClass by ORD.create_class('V'), the model-classes have to be loaded manually (require does not work))
85
+ else
86
+ ActiveOrient::Base.logger = Logger.new('/dev/stdout')
87
+ ActiveOrient::OrientDB.logger.error{ "config/connectyml is misconfigurated" }
88
+ ActiveOrient::OrientDB.logger.error{ "Database Server is NOT available"}
89
+ end
22
90
 
23
91
 
24
92
 
@@ -0,0 +1,10 @@
1
+ ---
2
+ :active_orient:
3
+ ## Namespace: Prefix of Model-Objects. :self -> ActiveOrient::Model::{name}
4
+ ## :object => No Prefix
5
+ ## :active_orient => ActiveOrient::{name}
6
+ :namespace: :object
7
+ ## model_dir: Path to model-files relative to the root of the application
8
+ ## ie. app/model or model
9
+ :model_dir: 'model'
10
+
@@ -1,8 +1,12 @@
1
1
  ---
2
2
  :orientdb:
3
- :server: localhost
3
+ :server: localhost # 172.28.50.109 # localhost #mailout.halfgarten-capital.de
4
4
  :port: 2480
5
- :database: hc_database
5
+ :logger: stdout # 'file' or 'stdout'
6
+ :database:
7
+ :development: DEV
8
+ :production: hcn_data
9
+ :test: tempera
6
10
  :admin:
7
11
  :user: hctw
8
12
  :pass: hc
@@ -0,0 +1,19 @@
1
+ # create a dir bin
2
+ # and move bin/activeorient-console.sh into that dir
3
+
4
+ # create a dir config
5
+ # and create a sample connect.yml
6
+ # and copy boot.rb
7
+
8
+ # create a schema dir
9
+ # and put stuff to administrate the database-structure there
10
+
11
+ # create a dir model
12
+ # and put a sample model-file into it
13
+ # create model-files according to the database-schema
14
+
15
+ # create a dir spec
16
+ # and copy spec-helper.rb into it
17
+
18
+ # create a Guard and a Gemfile in the root-directory
19
+
@@ -5,74 +5,121 @@ There are several Books. And there is a Table with Keywords. These are our Verte
5
5
 
6
6
  The Keywords are associated to the books, this is realized via an Edge »has_content«
7
7
 
8
- This Example demonstrates how to build a query by using OrientSupport::OrientQuery
8
+ This Example demonstrates how create a simple graph:
9
+
10
+ Book --> HasContent --> KeyWord
11
+
12
+ and to query it dynamically using OrientSupport::OrientQuery
13
+
14
+ REQUIREMENT: Configurate config/connectyml (admin/user+pass)
15
+
16
+ There are 3 default search items provided. They are used if no parameter is given.
17
+ However, any parameter given is transmitted as serach-criteria, ie.
18
+ ruby books.rb Juli August
19
+ defines two search criteria.
20
+
9
21
  =end
22
+
10
23
  class BooksExample
11
24
 
12
- def initialize db, rebuild: true
25
+ def initialize rebuild: true
13
26
  if rebuild
14
- db.delete_class :book
15
- db.delete_class :keyword
16
- db.delete_class :has_content
17
- db.create_vertex_class :book
18
- db.create_vertex_class :keyword
19
- db.create_edge_class :has_content
20
- ActiveOrient::Model::Keyword.create_property( :item , type: :string, index: :unique )
21
- ActiveOrient::Model::Book.create_property( :title, type: :string, index: :unique )
27
+ print "\n === REBUILD === \n"
28
+ ## check wether the database tables exist. Then delete Database-Class and preallocated ruby-Object
29
+ database_classes = [ :book, :keyword, :has_content ]
30
+ puts "allocated-database-classes: #{ORD.database_classes.join(" , ")} "
31
+ if database_classes.map{|c| ORD.database_classes.include?( c.to_s ) ? c : nil }.compact.size == 3
32
+ print " deleting database tables \n"
33
+ database_classes.each{ | c | d_class= c.to_s.classify.constantize # works if namespace=Object
34
+ d_class.delete_class if d_class.present? }
35
+ else
36
+ puts " omitting deletion of database-classes "
37
+ end
38
+ print " creating Book and Keyword as Vertex; HasContent as Edge \n"
39
+ ORD.create_classes( { V: [:book, :keyword], E: :has_content })
40
+ print "\n === PROPERTY === \n"
41
+ Keyword.create_property :item, type: :string, index: :unique
42
+ Book.create_property :title, type: :string, index: :unique
43
+ print "\n === Unique Edges === \n"
44
+ HasContent.uniq_index
22
45
  end
23
46
  end
24
47
 
25
48
 
26
49
  def read_samples
27
- fill_database = ->(sentence, this_book ) do
28
- sentence.split(' ').each do |x|
29
- this_word = Keyword.update_or_create where: { item: x }
30
- this_edge = HC.create_edge from: this_book, to: this_word if this_word.present?
31
- end
50
+ print "\n === READ SAMPLES === \n"
51
+ ## Lambda fill databasea
52
+ # Anaylse a sentence
53
+ # Split into words and upsert them to Word-Class.
54
+ # The Block is only performed, if a new Word is inserted.
55
+ fill_database = ->(sentence, this_book ) do
56
+
57
+ sentence.split(' ').map do | word |
58
+ Keyword.upsert where: { item: word } do | new_keyword |
59
+ HasContent.create from: this_book, to: new_keyword
60
+ end
61
+ end
62
+
32
63
  end
33
- words = 'Die Geschäfte in der Industrie im wichtigen US-Bundesstaat New York sind im August so schlecht gelaufen wie seit mehr als sechs Jahren nicht mehr Der entsprechende Empire-State-Index fiel überraschend von plus Punkten im Juli auf minus 14,92 Zähler Dies teilte die New Yorker Notenbank Fed heut mit Bei Werten im positiven Bereich signalisiert das Barometer ein Wachstum Ökonomen hatten eigentlich mit einem Anstieg auf 5,0 Punkte gerechnet'
64
+ ## Lambda end
65
+ words = 'Die Geschäfte in der Industrie im wichtigen US-Bundesstaat New York sind im August so schlecht gelaufen wie seit mehr als sechs Jahren nicht mehr Der entsprechende Empire-State-Index fiel überraschend von plus Punkten im Juli auf minus 14,92 Zähler Dies teilte die New Yorker Notenbank Fed heute mit. Bei Werten im positiven Bereich signalisiert das Barometer ein Wachstum Ökonomen hatten eigentlich mit einem Anstieg auf 5,0 Punkte gerechnet'
34
66
  this_book = Book.create title: 'first'
35
67
  fill_database[ words, this_book ]
36
68
 
37
69
  words2 = 'Das Bruttoinlandsprodukt BIP in Japan ist im zweiten Quartal mit einer aufs Jahr hochgerechneten Rate von Prozent geschrumpft Zu Jahresbeginn war die nach den USA und China drittgrößte Volkswirtschaft der Welt noch um Prozent gewachsen Der Schwächeanfall wird auch als Rückschlag für Ministerpräsident Shinzo Abe gewertet der das Land mit einem Mix aus billigem Geld und Konjunkturprogramm aus der Flaute bringen will Allerdings wirkte sich die heutige Veröffentlichung auf die Märkten nur wenig aus da Ökonomen mit einem schwächeren zweiten Quartal gerechnet hatten'
38
70
  this_book = Book.create title: 'second'
39
71
  fill_database[ words2, this_book ]
72
+ puts "#{Keyword.count} keywords inserted into Database"
40
73
  end
41
-
74
+
42
75
  def display_books_with *desired_words
43
- query = OrientSupport::OrientQuery.new from: Keyword, projection: "expand(in('HasContent'))"
44
- q = OrientSupport::OrientQuery.new projection: 'expand( $z )'
76
+
77
+ ## Each serach criteria becomes a subquery
78
+ ## This is integrated into the main_query using 'let'.
79
+ ## Subquery: let ${a-y} = select expand(in('has_content')) from keyword where item = {search_word}
80
+ ## combine with intercect: $z = Intercect( $a ... $y )
81
+ ## Main Query is just
82
+ ## select expand( $z ) followed by all let-statements and finalized by "intercect"
83
+ #
84
+ print("\n === display_books_with » #{ desired_words.join "," } « === \n")
85
+ main_query = OrientSupport::OrientQuery.new projection: 'expand( $z )'
45
86
 
46
87
  intersects = Array.new
47
88
  desired_words.each_with_index do | word, i |
48
- symbol = ( i+97 ).chr # convert 1 -> 'a'
49
- query.where = { item: word }
50
- q.let << { symbol => query }
51
- intersects << "$#{symbol}"
89
+ symbol = ( i+97 ).chr # convert 1 -> 'a', 2 -> 'b' ...
90
+ subquery = OrientSupport::OrientQuery.new from: Keyword, projection: "expand(in('has_content'))"
91
+ subquery.where = { item: word }
92
+ main_query.let << { symbol => subquery }
93
+ intersects << "$#{symbol}"
52
94
  end
53
- q.let << "$z = Intersect(#{intersects.join(', ')}) "
95
+ main_query.let << "$z = Intersect(#{intersects.join(', ')}) "
54
96
  puts "generated Query:"
55
- puts q.to_s
56
- result = Keyword.query_database q, set_from: false
97
+ puts main_query.compose
98
+ result = Keyword.query_database main_query, set_from: false
99
+ puts '-' * 23
57
100
  puts "found books: "
58
- puts result.map( &:title ).join("; ")
101
+ puts result.map( &:title ).join("; ")
59
102
  puts " -- None -- " if result.empty?
103
+ puts '-_' * 23
104
+ puts "that's it folks"
60
105
  end
61
106
  end
62
107
 
63
108
  if $0 == __FILE__
64
109
 
65
- require '../config/boot'
66
-
67
- ActiveOrient::OrientDB.default_server = { user: 'hctw', password: 'hc' }
68
- ActiveOrient::OrientDB.logger.level = Logger::WARN
69
- r = ActiveOrient::OrientDB.new database: 'BookTest'
70
- b= BooksExample.new r, rebuild: true
71
-
72
- Book = r.open_class :book
73
- Keyword = r.open_class :keyword
74
- HC = r.open_class :has_content
75
-
110
+ search_items = ARGV.empty? ? ['China', 'aus', 'Flaute'] : ARGV
111
+ ARGV = [ 'd' ] # development-mode
112
+ @configDatabase = 'BookTest'
113
+
114
+ require '../config/boot'
115
+
116
+ # search_items = ARGV.empty? ? ['China', 'aus', 'Flaute'] : ARGV
117
+ b = BooksExample.new rebuild: true
118
+
119
+ ORD.create_classes([ "Book", "Keyword" ]){ "V" }
120
+ ORD.create_edge_class 'has_content'
121
+
76
122
  b.read_samples if Keyword.count.zero?
77
- b.display_books_with 'Land', 'Quartal'
123
+ b.display_books_with *search_items
124
+
78
125
  end
@@ -0,0 +1,91 @@
1
+ if $0 == __FILE__
2
+ puts "the time-graph example is completely rewritten"
3
+ puts "changing into the directory and starting the demo in 10 sec."
4
+ sleep 10
5
+ print %x{ cd #{File.expand_path(File.dirname(__FILE__))}/time_graph ; ruby createTime.rb }
6
+
7
+ Kernel.exit
8
+ end
9
+ #require 'time'
10
+ require '../config/boot'
11
+
12
+ ## historic stuff
13
+
14
+ def create1month
15
+
16
+ database_classes = [:hour, :day, :month, :time_base, :time_of ]
17
+ puts "allocated-database-classes: #{ORD.database_classes.join(" , ")} "
18
+ puts database_classes.map{|c| ORD.database_classes.include?( c.to_s ) ? c : nil }.compact.size
19
+ if database_classes.map{|c| ORD.database_classes.include?( c.to_s ) ? c : nil }.compact.size <= 5
20
+ print " deleting database tables \n"
21
+ database_classes.each{ | c | d_class= c.to_s.classify.constantize # works if namespace=Object
22
+ d_class.delete_class if d_class.present? }
23
+ else
24
+ puts " omitting deletion of database-classes "
25
+ end
26
+ ORD.create_vertex_class :time_base
27
+ ORD.create_classes( :hour, :day, :month ){ :time_base } # create three vertex classes
28
+ TimeBase.create_property :value_string, type: :string
29
+ TimeBase.create_property :value, type: :string
30
+ ORD.create_edge_class :time_of
31
+ ORD.create_edge_class :day_of
32
+
33
+
34
+ # hour_class = r.create_vertex_class "Hour", properties: {value_string: {type: :string}, value: {type: :integer}}
35
+ # hour_class.alter_property property: "value", attribute: "MIN", alteration: 0
36
+ # hour_class.alter_property property: "value", attribute: "MAX", alteration: 23
37
+ #
38
+ # day_class = r.create_vertex_class "Day", properties: {value_string: {type: :string}, value: {type: :integer}}
39
+ # day_class.alter_property property: "value", attribute: "MIN", alteration: 1
40
+ # day_class.alter_property property: "value", attribute: "MAX", alteration: 31
41
+ #
42
+ # month_class = r.create_vertex_class "Month", properties: {value_string: {type: :string}, value: {type: :integer}}
43
+ # month_class.alter_property property: "value", attribute: "MIN", alteration: 1
44
+ # month_class.alter_property property: "value", attribute: "MAX", alteration: 12
45
+ #
46
+
47
+ # timeof_class = r.create_edge_class "TIMEOF"
48
+
49
+ timestamp = DateTime.new 2016,2,29 # or strptime "1456704000",'%s'
50
+ month_vertex =Month.create value_string: "March", value: 3
51
+ for day in 1..31
52
+ day_vertex = Day.create value_string: "March #{timestamp.day}", value: day
53
+ for hour in 0..23
54
+ print "#{timestamp.year} #{timestamp.month} #{timestamp.day} #{timestamp.hour} \n"
55
+ hour_vertex = Hour.create value_string: "March #{timestamp.day} #{timestamp.hour}:00", value: hour
56
+ TimeOf.create_edge from: day_vertex, to: hour_vertex
57
+ timestamp += Rational(1,24) # + 1 hour
58
+ end
59
+ DayOf.create_edge from: month_vertex, to: day_vertex
60
+ end
61
+ end
62
+
63
+
64
+ create1month
65
+
66
+ print "1 #{Month.all} \n \n"
67
+
68
+ firstmonth = Month.first
69
+ print "2 #{firstmonth.to_human} \n \n"
70
+ print "2.5 #{firstmonth.value} \n \n"
71
+
72
+ puts firstmonth.inspect
73
+ days = firstmonth.out_day_of
74
+ print "3 #{days.to_human} \n \n"
75
+
76
+ first_day = firstmonth.out_day_of[0].in
77
+ print "4 #{first_day.to_human} \n \n"
78
+
79
+ puts Month.first.out_day_of[0].in.out_time_of[12].inspect
80
+ thirteen_hour = firstmonth.out_day_of[0].in.out_time_of[12].in
81
+ print "5 #{thirteen_hour.value} \n \n"
82
+ print "6 #{thirteen_hour.to_human} \n \n"
83
+
84
+ test2 = firstmonth["out_day_of"].map{|x| x["in"]}
85
+ print "7 #{test2} \n \n"
86
+
87
+ mon.add_edge_link name: "days", direction: "out", edge: "time_of"
88
+ print "8 #{firstmonth.days.map{|x| x.value}} \n \n"
89
+
90
+ print "9 #{firstmonth.days.value_string} \n \n"
91
+