redcar 0.9.2 → 0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (234) hide show
  1. data/CHANGES +34 -4
  2. data/Rakefile +2 -1
  3. data/lib/redcar.rb +3 -3
  4. data/lib/redcar/installer.rb +2 -3
  5. data/plugins/application/features/step_definitions/dialog_steps.rb +7 -0
  6. data/plugins/application/features/step_definitions/key_steps.rb +18 -0
  7. data/plugins/application/features/step_definitions/menu_steps.rb +5 -6
  8. data/plugins/application/features/step_definitions/speedbar_steps.rb +29 -9
  9. data/plugins/application/features/step_definitions/tree_steps.rb +13 -0
  10. data/plugins/application/features/support/env.rb +39 -5
  11. data/plugins/application/features/support/fake_event.rb +12 -0
  12. data/plugins/application/lib/application.rb +5 -6
  13. data/plugins/application/lib/application/dialog.rb +53 -10
  14. data/plugins/application/lib/application/dialogs/modeless_list_dialog.rb +85 -0
  15. data/plugins/application/lib/application/keymap.rb +10 -8
  16. data/plugins/application/lib/application/menu.rb +38 -16
  17. data/plugins/application/lib/application/treebook.rb +30 -0
  18. data/plugins/application/lib/application/window.rb +20 -2
  19. data/plugins/application/spec/application/command/executor_spec.rb +1 -0
  20. data/plugins/application/spec/application/menu_spec.rb +26 -26
  21. data/plugins/application/spec/application/treebook_spec.rb +6 -6
  22. data/plugins/application/spec/spec_helper.rb +10 -1
  23. data/plugins/application_swt/lib/application_swt.rb +25 -3
  24. data/plugins/application_swt/lib/application_swt/dialog_adapter.rb +48 -27
  25. data/plugins/application_swt/lib/application_swt/dialogs/filter_list_dialog_controller.rb +22 -11
  26. data/plugins/application_swt/lib/application_swt/dialogs/modeless_dialog.rb +113 -0
  27. data/plugins/application_swt/lib/application_swt/dialogs/modeless_html_dialog.rb +85 -0
  28. data/plugins/application_swt/lib/application_swt/dialogs/modeless_list_dialog_controller.rb +143 -0
  29. data/plugins/application_swt/lib/application_swt/gradient.rb +61 -0
  30. data/plugins/application_swt/lib/application_swt/menu/binding_translator.rb +4 -4
  31. data/plugins/application_swt/lib/application_swt/notebook.rb +5 -8
  32. data/plugins/application_swt/lib/application_swt/speedbar.rb +1 -0
  33. data/plugins/application_swt/lib/application_swt/treebook.rb +6 -8
  34. data/plugins/application_swt/lib/application_swt/window.rb +85 -57
  35. data/plugins/application_swt/lib/swt/graphics_utils.rb +23 -0
  36. data/plugins/application_swt/lib/swt/vtab_folder.rb +7 -0
  37. data/plugins/application_swt/lib/swt/vtab_label.rb +1 -1
  38. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +142 -0
  39. data/plugins/auto_completer/lib/auto_completer.rb +10 -42
  40. data/plugins/auto_completer/lib/auto_completer/list_dialog.rb +21 -0
  41. data/plugins/clojure/lib/clojure.rb +33 -0
  42. data/plugins/{repl/lib/repl/clojure_mirror.rb → clojure/lib/clojure/repl_mirror.rb} +16 -20
  43. data/plugins/clojure/plugin.rb +9 -0
  44. data/plugins/{repl/spec/repl/clojure_mirror_spec.rb → clojure/spec/clojure/repl_mirror_spec.rb} +12 -13
  45. data/plugins/clojure/spec/spec_helper.rb +5 -0
  46. data/plugins/{repl → clojure}/vendor/Wrapper.clj +0 -0
  47. data/plugins/{repl → clojure}/vendor/dummy +0 -0
  48. data/plugins/{repl → clojure}/vendor/enclojure-wrapper.jar +0 -0
  49. data/plugins/connection_manager/lib/connection_manager.rb +13 -13
  50. data/plugins/declarations/lib/declarations.rb +17 -6
  51. data/plugins/document_search/features/find.feature +389 -0
  52. data/plugins/document_search/features/find_and_replace.feature +723 -0
  53. data/plugins/document_search/features/replace.feature +69 -62
  54. data/plugins/document_search/lib/document_search.rb +81 -64
  55. data/plugins/document_search/lib/document_search/commands.rb +258 -0
  56. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +142 -0
  57. data/plugins/document_search/lib/document_search/find_speedbar.rb +102 -0
  58. data/plugins/document_search/lib/document_search/query_options.rb +45 -0
  59. data/plugins/edit_view/features/case_change.feature +9 -5
  60. data/plugins/edit_view/features/step_definitions/editing_steps.rb +19 -0
  61. data/plugins/edit_view/lib/edit_view.rb +15 -12
  62. data/plugins/edit_view/lib/edit_view/actions/arrow_keys.rb +12 -2
  63. data/plugins/edit_view/lib/edit_view/commands/text_conversion_commands.rb +1 -1
  64. data/plugins/edit_view/lib/edit_view/document.rb +129 -99
  65. data/plugins/edit_view_swt/lib/edit_view_swt.rb +33 -15
  66. data/plugins/encryption/encryption.rb +2 -0
  67. data/plugins/find-in-project/lib/find_in_project.rb +3 -5
  68. data/plugins/find-in-project/lib/find_in_project/views/index.html.erb +2 -0
  69. data/plugins/groovy/features/step_definitions/groovy_steps.rb +2 -2
  70. data/plugins/groovy/features/syntax_check_groovy.feature +3 -3
  71. data/plugins/groovy/lib/groovy.rb +38 -0
  72. data/plugins/groovy/lib/groovy/commands.rb +10 -0
  73. data/plugins/{repl/lib/repl/groovy_mirror.rb → groovy/lib/groovy/repl_mirror.rb} +33 -13
  74. data/plugins/groovy/lib/{syntax_check/groovy.rb → groovy/syntax_checker.rb} +13 -8
  75. data/plugins/groovy/plugin.rb +5 -4
  76. data/plugins/{repl/spec/repl/groovy_mirror_spec.rb → groovy/spec/groovy/repl_mirror_spec.rb} +14 -13
  77. data/plugins/groovy/spec/spec_helper.rb +5 -0
  78. data/plugins/html_view/assets/json2.js +476 -0
  79. data/plugins/html_view/lib/html_view.rb +1 -0
  80. data/plugins/java/features/fixtures/test.java +0 -0
  81. data/plugins/java/features/support/env.rb +27 -0
  82. data/plugins/java/features/syntax_check_java.feature +86 -0
  83. data/plugins/java/lib/syntax_check/java.rb +86 -0
  84. data/plugins/java/plugin.rb +7 -0
  85. data/plugins/javascript/features/fixtures/test2.js +5 -0
  86. data/plugins/javascript/features/step_definitions/javascript_steps.rb +16 -0
  87. data/plugins/javascript/features/support/env.rb +14 -0
  88. data/plugins/javascript/features/syntax_check_javascript.feature +46 -3
  89. data/plugins/javascript/lib/syntax_check/javascript.rb +15 -9
  90. data/plugins/line_tools/features/trim_line.feature +49 -0
  91. data/plugins/line_tools/lib/line_tools.rb +5 -1
  92. data/plugins/mirah/README +7 -0
  93. data/plugins/mirah/features/fixtures/test.mirah +2 -0
  94. data/plugins/mirah/features/syntax_check_mirah.feature +46 -0
  95. data/plugins/mirah/lib/mirah.rb +43 -0
  96. data/plugins/mirah/lib/mirah/my_error_handler.rb +22 -0
  97. data/plugins/mirah/lib/mirah/repl_mirror.rb +50 -0
  98. data/plugins/mirah/lib/mirah/syntax_checker.rb +38 -0
  99. data/plugins/mirah/plugin.rb +8 -0
  100. data/plugins/mirah/spec/mirah/repl_mirror_spec.rb +188 -0
  101. data/plugins/mirah/spec/spec_helper.rb +5 -0
  102. data/plugins/mirah/vendor/mirah-parser.jar +0 -0
  103. data/plugins/pair_highlighter/lib/pair_highlighter/document_controller.rb +24 -23
  104. data/plugins/plugin_manager_ui/lib/plugin_manager_ui.rb +10 -1
  105. data/plugins/plugin_manager_ui/views/index.html.erb +2 -0
  106. data/plugins/project/features/find_file.feature +40 -16
  107. data/plugins/project/features/highlight_focussed_tab.feature +16 -10
  108. data/plugins/project/features/step_definitions/find_file_steps.rb +11 -0
  109. data/plugins/project/features/step_definitions/project_tree_steps.rb +5 -1
  110. data/plugins/project/features/support/env.rb +5 -0
  111. data/plugins/project/lib/project/commands.rb +8 -1
  112. data/plugins/project/lib/project/dir_controller.rb +4 -1
  113. data/plugins/project/lib/project/find_file_dialog.rb +16 -12
  114. data/plugins/project/lib/project/manager.rb +30 -1
  115. data/plugins/project_search/vendor/lucene/CHANGELOG +147 -0
  116. data/plugins/project_search/vendor/lucene/CONTRIBUTORS +17 -0
  117. data/plugins/project_search/vendor/lucene/Gemfile +9 -0
  118. data/plugins/project_search/vendor/lucene/Gemfile.lock +33 -0
  119. data/plugins/project_search/vendor/lucene/LICENSE +19 -0
  120. data/plugins/project_search/vendor/lucene/README.rdoc +283 -0
  121. data/plugins/project_search/vendor/lucene/Rakefile +35 -0
  122. data/plugins/project_search/vendor/lucene/examples/active_model/serializers.rb +25 -0
  123. data/plugins/project_search/vendor/lucene/examples/active_model/validation.rb +26 -0
  124. data/plugins/project_search/vendor/lucene/examples/admin/Rakefile +4 -0
  125. data/plugins/project_search/vendor/lucene/examples/admin/admin.rb +29 -0
  126. data/plugins/project_search/vendor/lucene/examples/admin/public/jquery.js +4376 -0
  127. data/plugins/project_search/vendor/lucene/examples/admin/public/neo4j.css +153 -0
  128. data/plugins/project_search/vendor/lucene/examples/admin/public/neo_admin.js +18 -0
  129. data/plugins/project_search/vendor/lucene/examples/admin/spec/admin_spec.rb +26 -0
  130. data/plugins/project_search/vendor/lucene/examples/admin/views/index.erb +21 -0
  131. data/plugins/project_search/vendor/lucene/examples/filetree/README.rdoc +9 -0
  132. data/plugins/project_search/vendor/lucene/examples/filetree/app.rb +7 -0
  133. data/plugins/project_search/vendor/lucene/examples/filetree/batch.props +5 -0
  134. data/plugins/project_search/vendor/lucene/examples/filetree/features/step_definitions/add_steps.rb +121 -0
  135. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/env.rb +30 -0
  136. data/plugins/project_search/vendor/lucene/examples/filetree/features/support/rspec_helper.rb +50 -0
  137. data/plugins/project_search/vendor/lucene/examples/filetree/features/treesizes.feature +19 -0
  138. data/plugins/project_search/vendor/lucene/examples/imdb/1_create_neo_db.rb +66 -0
  139. data/plugins/project_search/vendor/lucene/examples/imdb/2_index_db.rb +23 -0
  140. data/plugins/project_search/vendor/lucene/examples/imdb/README +12 -0
  141. data/plugins/project_search/vendor/lucene/examples/imdb/find_actors.rb +56 -0
  142. data/plugins/project_search/vendor/lucene/examples/imdb/install.sh +12 -0
  143. data/plugins/project_search/vendor/lucene/examples/imdb/model.rb +37 -0
  144. data/plugins/project_search/vendor/lucene/examples/railway/README +111 -0
  145. data/plugins/project_search/vendor/lucene/examples/railway/railnet-app.rb +31 -0
  146. data/plugins/project_search/vendor/lucene/examples/railway/railnet-data.rb +42 -0
  147. data/plugins/project_search/vendor/lucene/examples/rest/example.rb +41 -0
  148. data/plugins/project_search/vendor/lucene/examples/you_might_know/YouMightKnow.java +60 -0
  149. data/plugins/project_search/vendor/lucene/examples/you_might_know/all_simple_paths.rb +34 -0
  150. data/plugins/project_search/vendor/lucene/examples/you_might_know/nodes.rb +34 -0
  151. data/plugins/project_search/vendor/lucene/examples/you_might_know/you_might_know.rb +50 -0
  152. data/plugins/project_search/vendor/lucene/lib/lucene.rb +15 -0
  153. data/plugins/project_search/vendor/lucene/lib/lucene/config.rb +145 -0
  154. data/plugins/project_search/vendor/lucene/lib/lucene/document.rb +96 -0
  155. data/plugins/project_search/vendor/lucene/lib/lucene/field_info.rb +144 -0
  156. data/plugins/project_search/vendor/lucene/lib/lucene/hits.rb +54 -0
  157. data/plugins/project_search/vendor/lucene/lib/lucene/index.rb +267 -0
  158. data/plugins/project_search/vendor/lucene/lib/lucene/index_info.rb +146 -0
  159. data/plugins/project_search/vendor/lucene/lib/lucene/index_searcher.rb +157 -0
  160. data/plugins/project_search/vendor/lucene/lib/lucene/jars.rb +5 -0
  161. data/plugins/project_search/vendor/lucene/lib/lucene/query_dsl.rb +135 -0
  162. data/plugins/project_search/vendor/lucene/lib/lucene/transaction.rb +117 -0
  163. data/plugins/project_search/vendor/lucene/lib/lucene/version.rb +3 -0
  164. data/plugins/project_search/vendor/lucene/lucene.gemspec +23 -0
  165. data/plugins/project_search/vendor/lucene/spec/lucene/document_spec.rb +32 -0
  166. data/plugins/project_search/vendor/lucene/spec/lucene/field_info_spec.rb +70 -0
  167. data/plugins/project_search/vendor/lucene/spec/lucene/index_info_spec.rb +76 -0
  168. data/plugins/project_search/vendor/lucene/spec/lucene/index_spec.rb +643 -0
  169. data/plugins/project_search/vendor/lucene/spec/lucene/query_dsl_spec.rb +142 -0
  170. data/plugins/project_search/vendor/lucene/spec/lucene/sort_spec.rb +101 -0
  171. data/plugins/project_search/vendor/lucene/spec/lucene/spec_helper.rb +10 -0
  172. data/plugins/project_search/vendor/lucene/spec/lucene/transaction_spec.rb +118 -0
  173. data/plugins/redcar/features/alter_font_size.feature +25 -0
  174. data/plugins/redcar/features/step_definitions/font_steps.rb +34 -0
  175. data/plugins/redcar/redcar.rb +256 -43
  176. data/plugins/repl/features/command_editing.feature +55 -0
  177. data/plugins/repl/features/command_history.feature +75 -0
  178. data/plugins/repl/features/step_definitions/repl_steps.rb +17 -1
  179. data/plugins/repl/features/support/env.rb +24 -0
  180. data/plugins/repl/features/support/fake_repl.rb +16 -0
  181. data/plugins/repl/lib/repl.rb +17 -74
  182. data/plugins/repl/lib/repl/repl_command.rb +20 -0
  183. data/plugins/repl/lib/repl/repl_mirror.rb +168 -22
  184. data/plugins/repl/lib/repl/repl_tab.rb +131 -6
  185. data/plugins/repl/plugin.rb +1 -1
  186. data/plugins/repl/spec/repl/repl_mirror_spec.rb +72 -0
  187. data/plugins/repl/spec/spec_helper.rb +1 -1
  188. data/plugins/repl_swt/lib/repl_swt.rb +7 -0
  189. data/plugins/repl_swt/lib/repl_swt/key_listener.rb +43 -0
  190. data/plugins/repl_swt/plugin.rb +8 -0
  191. data/plugins/ruby/lib/ruby.rb +35 -0
  192. data/plugins/{repl/lib/repl/ruby_mirror.rb → ruby/lib/ruby/repl_mirror.rb} +12 -12
  193. data/plugins/ruby/lib/{syntax_check/ruby.rb → ruby/syntax_checker.rb} +3 -3
  194. data/plugins/ruby/plugin.rb +5 -4
  195. data/plugins/{repl/spec/repl/ruby_mirror_spec.rb → ruby/spec/ruby/repl_mirror_spec.rb} +38 -29
  196. data/plugins/ruby/spec/spec_helper.rb +5 -0
  197. data/plugins/runnables/lib/runnables.rb +2 -0
  198. data/plugins/runnables/lib/runnables/command_output_controller.rb +5 -0
  199. data/plugins/runnables/lib/runnables/output_processor.rb +14 -3
  200. data/plugins/runnables/views/command_output.html.erb +3 -2
  201. data/plugins/scm/lib/scm.rb +4 -2
  202. data/plugins/scm/lib/scm/diff_mirror.rb +6 -6
  203. data/plugins/scm_git/lib/scm_git.rb +136 -107
  204. data/plugins/scm_git/lib/scm_git/change.rb +28 -19
  205. data/plugins/snippets/lib/snippets/explorer.rb +2 -2
  206. data/plugins/swt/lib/swt/full_swt.rb +1 -0
  207. data/plugins/syntax_check/features/step_definitions/syntax_check_steps.rb +4 -0
  208. data/plugins/syntax_check/features/support/env.rb +3 -0
  209. data/plugins/syntax_check/lib/syntax_check.rb +71 -5
  210. data/plugins/syntax_check/lib/syntax_check/annotation.rb +61 -0
  211. data/plugins/test_runner/lib/test_runner.rb +39 -0
  212. data/plugins/test_runner/lib/test_runner/rspec_runner.rb +20 -0
  213. data/plugins/test_runner/lib/test_runner/run_test_command.rb +63 -0
  214. data/plugins/test_runner/lib/test_runner/runnable_test_runner.rb +26 -0
  215. data/plugins/test_runner/plugin.rb +8 -0
  216. data/plugins/test_runner/spec/run_test_command_spec.rb +51 -0
  217. data/plugins/test_runner/spec/spec_helper.rb +5 -0
  218. data/plugins/textmate/lib/textmate.rb +12 -2
  219. data/plugins/textmate/vendor/redcar-bundles/Bundles/HTML.tmbundle/Syntaxes/HTML.plist +0 -2
  220. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/Syntaxes/Mirah.plist +22 -0
  221. data/plugins/textmate/vendor/redcar-bundles/Bundles/Mirah.tmbundle/info.plist +12 -0
  222. data/plugins/textmate/vendor/redcar-bundles/Bundles/Ruby.tmbundle/Syntaxes/Ruby.plist +2 -0
  223. data/plugins/todo_list/lib/todo_list.rb +7 -0
  224. data/plugins/todo_list/lib/todo_list/todo_controller.rb +3 -1
  225. data/plugins/tree/lib/tree.rb +4 -0
  226. data/plugins/tree_view_swt/lib/tree_view_swt.rb +5 -0
  227. data/plugins/web_bookmarks/lib/web_bookmarks.rb +10 -0
  228. metadata +137 -22
  229. data/plugins/document_search/features/search.feature +0 -163
  230. data/plugins/document_search/lib/document_search/replace_all_command.rb +0 -27
  231. data/plugins/document_search/lib/document_search/replace_command.rb +0 -38
  232. data/plugins/document_search/lib/document_search/replace_next_command.rb +0 -27
  233. data/plugins/document_search/lib/document_search/search_and_replace.rb +0 -81
  234. data/plugins/ruby/README +0 -6
@@ -0,0 +1,19 @@
1
+ Feature: Tree size calulations
2
+ In order to get some feeling for the file size performance
3
+ As a user
4
+ I want to test some traverse operations on Neo4j
5
+
6
+ # Scenario: Simple tests
7
+ # When I create a filetree with 2 files a 1kb and 1 subfolders in each folder, 3 times nested
8
+ # Then the total number of nodes in the db should be greater than 7
9
+ # Then the total size of one top folder files should be 4 kb and response time less than 0.015 s
10
+
11
+ Scenario: Bigger data sample
12
+ When I create a filetree with 400 files a 1kb and 50 subfolders in each folder, 3 times nested
13
+ Then the total number of nodes in the db should be greater than 20000
14
+ Then the total size of one top folder files should be 20400 kb and response time less than 0.5 s
15
+
16
+ # Scenario: Big data sample
17
+ # When I create a filetree with 3000 files a 1kb and 300 subfolders in each folder, 3 times nested
18
+ # Then the total number of nodes in the db should be greater than 20000
19
+ # Then the total size of one top folder files should be 20400 kb and response time less than 0.5 s
@@ -0,0 +1,66 @@
1
+ IMDB_FILE = 'data/test-actors.list'
2
+
3
+ Neo4j.migration 1, "Create DB by parsing IMDB file" do
4
+ up do
5
+ puts "Migration 1, processing #{IMDB_FILE} file ..."
6
+ Neo4j::Transaction.run do
7
+ movies = {}
8
+ current_actor = nil
9
+ actors = 0
10
+ no_films = 0
11
+
12
+ File.open(IMDB_FILE).each_line do |line|
13
+ next if line.strip.empty?
14
+
15
+ tab_items = line.split("\t")
16
+
17
+ unless tab_items.empty?
18
+ if !tab_items[0].empty?
19
+ current_actor = Actor.new
20
+ current_actor.name = tab_items.shift.strip
21
+ actors += 1
22
+ # puts "Parse new actor no. #{actors} '#{current_actor.name}'"
23
+ end
24
+ tab_items.shift
25
+
26
+ film = tab_items.shift.strip
27
+
28
+ # already created film ?
29
+ movie = movies[film]
30
+ if (movie.nil?)
31
+ movie = Movie.new
32
+ movie.title = film
33
+ movie.year = /\((\d+)(\/.)?\)/.match(film)[1]
34
+ movies[film] = movie
35
+ # puts "Created new film #{film}"
36
+ no_films += 1
37
+ end
38
+
39
+ role = tab_items.shift
40
+ roleNode = current_actor.acted_in.new(movie)
41
+
42
+ unless (role.nil?)
43
+ role.strip!
44
+ # remove []
45
+ role.slice!(0)
46
+ role.chop!
47
+ title, character = role.split('-')
48
+ roleNode.title = title.strip unless title.nil?
49
+ roleNode.character = character.strip unless character.nil?
50
+ end
51
+
52
+ #puts "Actor: '#{current_actor}' Film '#{film}' Year '#{year}' Title '#{title}' Character '#{character}'"
53
+ end
54
+ end
55
+ puts "created #{actors} actors and #{no_films} films"
56
+ end
57
+ end
58
+
59
+ down do
60
+ puts "deleting all movies and actors"
61
+ Neo4j::Transaction.run do
62
+ Actor.all.each {|a| a.del}
63
+ Movie.all.each {|m| m.del}
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,23 @@
1
+ Neo4j.migration 2, "Index DB" do
2
+ up do
3
+
4
+ puts "Migration 2, Index DB on #{Lucene::Config[:storage_path]}"
5
+
6
+ Neo4j::Transaction.run do
7
+ puts "Creating lucene index ..."
8
+ Actor.index :name, :tokenized => true
9
+ start = Time.new
10
+ Actor.update_index
11
+ puts "Index speed #{Time.new - start} sec"
12
+ end
13
+ # only possible to access and query the index after the transaction commits
14
+ end
15
+
16
+ down do
17
+ puts "removing lucene index"
18
+ Actor.remove_index :name
19
+ # Actor.update_index # maybe nicer way of deleting indexes - hmm, does it work ?
20
+ require 'fileutils'
21
+ FileUtils.rm_rf Lucene::Config[:storage_path] # quick and dirty way of killing the lucene index
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ Shows how to store and query a neo4j database
2
+
3
+ 1. Download the database type: ./install.sh
4
+ 2. Run the application: jruby find_actors.rb willis
5
+
6
+ The find_actors.rb uses migration which means that the first time the it is used it will take
7
+ a while to process the imdb file and create the index.
8
+
9
+ Notice that you can play around with migrations by require the 'find_actor' in JIRB and then for example
10
+ Neo4j.migrate! 1
11
+ which will delete the lucene index (migration number 2)
12
+
@@ -0,0 +1,56 @@
1
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../lib")
2
+ require "rubygems"
3
+ require "neo4j"
4
+
5
+ # we have to configure these before the model is loaded
6
+ Lucene::Config[:store_on_file] = true
7
+ Lucene::Config[:storage_path] = "tmp/lucene"
8
+
9
+
10
+ require "model"
11
+ require "neo4j/extensions/reindexer"
12
+
13
+
14
+ # Keep lucene index on file system instead of in memory
15
+
16
+
17
+ # Load Migrations
18
+ # Create Database
19
+ require '1_create_neo_db'
20
+
21
+ # just for fun I have two migrations - first one for importing the database and second for indexing it.
22
+ require '2_index_db'
23
+
24
+ puts "Neo4j Version #{Neo4j::VERSION}"
25
+
26
+ def find_actor(name)
27
+ Neo4j::Transaction.run do
28
+ puts "Find all actors named #{name}"
29
+ result = Actor.find(:name => name)
30
+
31
+ puts "Found #{result.size} actors"
32
+ result.each {|x| puts "#{x.neo_id}\t#{x}"}
33
+ end
34
+ end
35
+
36
+ def find_movies(neo_id)
37
+ Neo4j::Transaction.run do
38
+ actor = Neo4j.load_node(neo_id)
39
+ puts "No actor found with neo id #{neo_id}" if actor.nil?
40
+ return if actor.nil?
41
+
42
+ puts "#{actor} acted in:"
43
+ actor.acted_in_rels.each {|r| puts "Movie #{r.end_node.title} title: #{r.title}"}
44
+ end
45
+ end
46
+
47
+ Neo4j.start
48
+ if (ARGV.size == 1)
49
+ find_actor(ARGV[0])
50
+ elsif ARGV.size == 2 && ARGV[0] == "-m"
51
+ find_movies(ARGV[1])
52
+ else
53
+ puts "Usage: jruby find_actors.rb [-m] <actor name|actor neo_id>\n\n -m \tfinds the movies for the given actor neo_id"
54
+ end
55
+
56
+ Neo4j.stop
@@ -0,0 +1,12 @@
1
+ #!/bin/sh
2
+
3
+ # In order to run this example the following files must be downloaded in unpacked
4
+ # in the data folder
5
+
6
+ mkdir data
7
+ cd data
8
+ wget https://trac.neo4j.org/export/2067/laboratory/users/andersn/imdb-app/src/test/data/test-actors.list.gz --no-check-certificate
9
+ wget https://trac.neo4j.org/export/2067/laboratory/users/andersn/imdb-app/src/test/data/test-movies.list.gz --no-check-certificate
10
+ gunzip test-actors.list.gz
11
+ gunzip test-movies.list.gz
12
+
@@ -0,0 +1,37 @@
1
+
2
+ class Movie; end
3
+
4
+
5
+ class Role
6
+ include Neo4j::RelationshipMixin
7
+ property :title, :character
8
+
9
+ def to_s
10
+ "Role title #{self.title} character #{self.character}"
11
+ end
12
+ end
13
+
14
+ class Actor
15
+ include Neo4j::NodeMixin
16
+ property :name
17
+ has_n(:acted_in).to(Movie).relationship(Role)
18
+ index :name, :tokenized => true
19
+
20
+ def to_s
21
+ "Actor #{self.name}"
22
+ end
23
+ end
24
+
25
+ class Movie
26
+ include Neo4j::NodeMixin
27
+ property :title
28
+ property :year
29
+
30
+ # defines a method for traversing incoming acted_in relationships from Actor
31
+ has_n(:actors).from(Actor, :acted_in)
32
+
33
+ def to_s
34
+ "Movie #{self.title}"
35
+ end
36
+ end
37
+
@@ -0,0 +1,111 @@
1
+ * Railway Network Application Example (with JRuby Neo4j bindings)
2
+ by Bert Fitié
3
+
4
+ ** A. Network application
5
+
6
+ (1) Nodes. The nodes are railway stations
7
+ (2) Arcs. The arcs are the connections between the stations
8
+ (3) Paths. The (named) paths are trains
9
+ (4) Usage. The user performs the following navigation:
10
+ (4.1) The user selects (loads) a start station
11
+ (4.2) The user generates a list of outgoing trains from this station
12
+ (4.3) The user selects the train he wants to board from this station
13
+ (4.4) The user generates the train path, i.e. the sequence of all
14
+ stations visited by this train from this station
15
+ (4.5) The user selects (loads) a destination station from this path
16
+ (4.6) If this station is the final destination, the user is done,
17
+ otherwise, the user continues has travel with (4.2)
18
+
19
+ ** B. Example network
20
+
21
+ (1) The example network has 8 stations:
22
+ Alpha, Bravo, Charlie, Delta, Echo, Foxtrot, Golf, Hotel
23
+ (2) The example network has 8 arcs:
24
+ (2.1) Alpha - Bravo
25
+ (2.2) Bravo - Charlie
26
+ (2.3) Charlie - Delta
27
+ (2.4) Delta - Echo
28
+ (2.5) Alpha - Foxtrot
29
+ (2.6) Foxtrot - Charlie
30
+ (2.7) Delta - Golf
31
+ (2.8) Delta - Hotel
32
+ (3) The example network has 3 trains
33
+ (3.1) Train t1_ae:
34
+ (3.1.1) Alpha (departure 11:00) - Bravo (arrival 11:45)
35
+ (3.1.2) Bravo (departure 11:50) - Charlie (arrival 12:30)
36
+ (3.1.3) Charlie (departure 12:35) - Delta (arrival 13:00)
37
+ (3.1.4) Delta (departure 13:05) - Echo (arrival 14:00)
38
+ (3.2) Train t2_ag:
39
+ (3.2.1) Alpha (departure 13:15) - Foxtrot (arrival 13:45)
40
+ (3.2.2) Foxtrot (departure 13:50) - Charlie (arrival 14:30)
41
+ (3.2.3) Charlie (departure 14:35) - Delta (arrival 15:00)
42
+ (3.2.4) Delta (departure 15:05) - Golf (arrival 15:45)
43
+ (3.3) Train t3_gh:
44
+ (3.3.1) Golf (departure 12:30) - Delta (arrival 13:10)
45
+ (3.3.2) Delta (departure 13:15) - Hotel (arrival 14:30)
46
+
47
+ ** C. Demo objective
48
+
49
+ (1) The user selects start station Alpha
50
+ Result should be:
51
+ You arrived at station Alpha
52
+ (2) The user generates a list of outgoing trains from Alpha
53
+ Result should be:
54
+ Train t1_ae: departure 11:00
55
+ Train t2_ag: departure 13:15
56
+ (3) The user selects Train t1_ae to board from this station
57
+ (4) The user generates the train path for Train t1_ae from Alpha
58
+ Result should be:
59
+ Alpha (departure 11:00) - Bravo (arrival 11:45)
60
+ Bravo (departure 11:50) - Charlie (arrival 12:30)
61
+ Charlie (departure 12:35) - Delta (arrival 13:00)
62
+ Delta (departure 13:05) - Echo (arrival 14:00)
63
+ (5) The user selects destination station Delta from this path
64
+ Result should be:
65
+ You arrived at station Delta
66
+ (6) The user generates a list of outgoing trains from Delta
67
+ Result should be:
68
+ Train t1_ae: departure 13:05
69
+ Train t2_ag: departure 15:05
70
+ Train t3_gh: departure 13:15
71
+ (7) The user selects Train t3_gh to board from this station
72
+ (8) The user generates the train path for Train t3_gh from Delta
73
+ Result should be:
74
+ Delta (departure 13:15) - Hotel (arrival 14:30)
75
+ (9) The user selects final destination station Hotel from this path
76
+ Result should be:
77
+ You arrived at station Hotel
78
+
79
+ ** D. Data file
80
+ See railnet-data.rb
81
+
82
+ ** E. Application file
83
+ See railnet-app.rb
84
+
85
+
86
+ ** F. Demo session
87
+
88
+ ~ $> cd ~/private/sandbox/neo-jruby/examples/railnet
89
+ railnet $> jruby railnet-data.rb
90
+ railnet $> jirb -r railnet-app
91
+ irb(main):001:0> alpha = select_station(1)
92
+ You arrived at station Alpha
93
+ irb(main):002:0> list_trains(alpha)
94
+ Train t2_ag: departure: 13:15
95
+ Train t1_ae: departure: 11:00
96
+ irb(main):003:0> train_path(alpha, :t1_ae)
97
+ Alpha #1 (departure: 11:00) - Bravo #2 (arrival: 11:45)
98
+ Bravo #2 (departure: 11:50) - Charlie #3 (arrival: 12:30)
99
+ Charlie #3 (departure: 12:35) - Delta #4 (arrival: 13:00)
100
+ Delta #4 (departure: 13:05) - Echo #5 (arrival: 14:00)
101
+ irb(main):004:0> delta = select_station(4)
102
+ You arrived at station Delta
103
+ irb(main):005:0> list_trains(delta)
104
+ Train t3_gh: departure: 13:15
105
+ Train t2_ag: departure: 15:05
106
+ Train t1_ae: departure: 13:05
107
+ irb(main):006:0> train_path(delta, :t3_gh)
108
+ Delta #4 (departure: 13:15) - Hotel #8 (arrival: 14:30)
109
+ irb(main):007:0> hotel = select_station(8)
110
+ You arrived at station Hotel
111
+ irb(main):008:0>
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'neo4j'
3
+
4
+ def select_station(id)
5
+ station = nil
6
+ Neo4j::Transaction.run do
7
+ station = Neo4j.load_node(id)
8
+ puts "You arrived at station #{station[:name]}"
9
+ end
10
+ return station
11
+ end
12
+
13
+ def list_trains(station)
14
+ Neo4j::Transaction.run do
15
+ station.rels.outgoing.each do |rel|
16
+ puts "Train #{rel[:train]}: departure: #{rel[:dep]}"
17
+ end
18
+ end
19
+ end
20
+
21
+ def train_path(station, train)
22
+ Neo4j::Transaction.run do
23
+ station.traverse.outgoing(train).depth(:all).each do |station|
24
+ rel = station.rel(train, dir = :incoming)
25
+ puts "#{rel.start_node[:name]} ##{rel.start_node.neo_id}" +
26
+ " (departure: #{rel[:dep]})" +
27
+ " - #{rel.end_node[:name]} ##{rel.end_node.neo_id}" +
28
+ " (arrival: #{rel[:arr]})"
29
+ end;
30
+ end;
31
+ end
@@ -0,0 +1,42 @@
1
+ require 'rubygems'
2
+ require 'neo4j'
3
+
4
+ Neo4j::Transaction.run do
5
+
6
+ # Stations
7
+ alpha = Neo4j::Node.new :name => 'Alpha'
8
+ bravo = Neo4j::Node.new :name => 'Bravo'
9
+ charlie = Neo4j::Node.new :name => 'Charlie'
10
+ delta = Neo4j::Node.new :name => 'Delta'
11
+ echo = Neo4j::Node.new :name => 'Echo'
12
+ foxtrot = Neo4j::Node.new :name => 'Foxtrot'
13
+ golf = Neo4j::Node.new :name => 'Golf'
14
+ hotel = Neo4j::Node.new :name => 'Hotel'
15
+
16
+ # Train t1_ae
17
+ t1_ab = Neo4j::Relationship.new(:t1_ae, alpha, bravo)
18
+ t1_bc = Neo4j::Relationship.new(:t1_ae, bravo, charlie)
19
+ t1_cd = Neo4j::Relationship.new(:t1_ae, charlie, delta)
20
+ t1_de = Neo4j::Relationship.new(:t1_ae, delta, echo)
21
+ t1_ab[:dep] = '11:00'; t1_ab[:arr] = '11:45'; t1_ab[:train] = 't1_ae'
22
+ t1_bc[:dep] = '11:50'; t1_bc[:arr] = '12:30'; t1_bc[:train] = 't1_ae'
23
+ t1_cd[:dep] = '12:35'; t1_cd[:arr] = '13:00'; t1_cd[:train] = 't1_ae'
24
+ t1_de[:dep] = '13:05'; t1_de[:arr] = '14:00'; t1_de[:train] = 't1_ae'
25
+
26
+ # Train t2_ag
27
+ t2_af = Neo4j::Relationship.new(:t2_ag, alpha, foxtrot)
28
+ t2_fc = Neo4j::Relationship.new(:t2_ag, foxtrot, charlie)
29
+ t2_cd = Neo4j::Relationship.new(:t2_ag, charlie, delta)
30
+ t2_dg = Neo4j::Relationship.new(:t2_ag, delta, golf)
31
+ t2_af[:dep] = '13:15'; t2_af[:arr] = '13:45'; t2_af[:train] = 't2_ag'
32
+ t2_fc[:dep] = '13:50'; t2_fc[:arr] = '14:30'; t2_fc[:train] = 't2_ag'
33
+ t2_cd[:dep] = '14:35'; t2_cd[:arr] = '15:00'; t2_cd[:train] = 't2_ag'
34
+ t2_dg[:dep] = '15:05'; t2_dg[:arr] = '15:45'; t2_dg[:train] = 't2_ag'
35
+
36
+ # Train t3_gh
37
+ t3_gd = Neo4j::Relationship.new(:t3_gh, golf, delta)
38
+ t3_dh = Neo4j::Relationship.new(:t3_gh, delta, hotel)
39
+ t3_gd[:dep] = '12:30'; t3_gd[:arr] = '13:10'; t3_gd[:train] = 't3_gh'
40
+ t3_dh[:dep] = '13:15'; t3_dh[:arr] = '14:30'; t3_dh[:train] = 't3_gh'
41
+
42
+ end
@@ -0,0 +1,41 @@
1
+ #####################################
2
+ #
3
+ # A simple example how to expose neo nodes as REST resources.
4
+ #
5
+ # IMPORTANT
6
+ #
7
+ # This example requires the latest version from GITHUB of the sinatra gem
8
+ # and json-jruby (>=1.1.6) (or another compatible json gem)
9
+ #
10
+
11
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/../../lib")
12
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__) + "/..")
13
+ require 'rubygems'
14
+ require 'neo4j'
15
+ require 'neo4j/extensions/rest'
16
+
17
+ FileUtils.rm_rf Neo4j::Config[:storage_path] # NEO_STORAGE
18
+ FileUtils.rm_rf Lucene::Config[:storage_path] unless Lucene::Config[:storage_path].nil?
19
+
20
+
21
+ class Person
22
+ include Neo4j::NodeMixin
23
+ # by includeing the following mixin we will expose this node as a RESTful resource
24
+ include Neo4j::RestMixin
25
+ property :name
26
+ has_n :friends
27
+ index :name
28
+ end
29
+
30
+ Neo4j.start
31
+ puts "-----------------------"
32
+ Neo4j::Transaction.run do
33
+ a = Person.new :name => 'andreas', :foo => 'bar', :fav_number => 14
34
+ b = Person.new :name => 'kalle'
35
+ c = Person.new :name => 'anders'
36
+ a.friends << b
37
+ a.rels.outgoing(:other) << c
38
+ puts "Created Nodes at URI:\n\t#{a._uri}\n\t#{b._uri}\n\t#{c._uri}"
39
+ end
40
+
41
+ Neo4j::Rest::RestServer.thread.join