xiki 0.5.0a

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 (252) hide show
  1. data/Gemfile +11 -0
  2. data/LICENSE +22 -0
  3. data/README.markdown +83 -0
  4. data/Rakefile +8 -0
  5. data/bin/xiki +46 -0
  6. data/etc/command/xiki_command.rb +203 -0
  7. data/etc/command/xiki_process.rb +52 -0
  8. data/etc/command/xiki_wrapper +2 -0
  9. data/etc/js/menu1.js +55 -0
  10. data/etc/js/xiki.js +259 -0
  11. data/etc/logo.png +0 -0
  12. data/etc/presentations/bootstrap.deck +5 -0
  13. data/etc/presentations/databases.deck +41 -0
  14. data/etc/presentations/diffs.deck +23 -0
  15. data/etc/presentations/documentation.deck +14 -0
  16. data/etc/presentations/effects.deck +5 -0
  17. data/etc/presentations/face.deck +297 -0
  18. data/etc/presentations/files.deck +79 -0
  19. data/etc/presentations/icons.deck +22 -0
  20. data/etc/presentations/images.deck +24 -0
  21. data/etc/presentations/key_shortcuts.deck +16 -0
  22. data/etc/presentations/macros.deck +18 -0
  23. data/etc/presentations/menu_classes.deck +44 -0
  24. data/etc/presentations/menu_directories.deck +30 -0
  25. data/etc/presentations/notes.deck +19 -0
  26. data/etc/presentations/other_languages.deck +55 -0
  27. data/etc/presentations/other_wiki_syntaxes.deck +4 -0
  28. data/etc/presentations/piano.deck +5 -0
  29. data/etc/presentations/potential/diffs.deck +38 -0
  30. data/etc/presentations/potential/evolution.deck +18 -0
  31. data/etc/presentations/potential/intro.deck +711 -0
  32. data/etc/presentations/potential/intro1.deck +711 -0
  33. data/etc/presentations/potential/intro2.deck +97 -0
  34. data/etc/presentations/potential/make_mysql_menu.deck +36 -0
  35. data/etc/presentations/potential/ruby_development.deck +17 -0
  36. data/etc/presentations/potential/ui_prototyping.deck +50 -0
  37. data/etc/presentations/potential/web_dev.deck +4 -0
  38. data/etc/presentations/potential/web_development.deck +10 -0
  39. data/etc/presentations/potential/wiki.deck +45 -0
  40. data/etc/presentations/presentations.deck +24 -0
  41. data/etc/presentations/rails_development.deck +29 -0
  42. data/etc/presentations/search_key_shortcuts.deck +37 -0
  43. data/etc/presentations/simplest_possible_ui.deck +37 -0
  44. data/etc/presentations/svg.deck +5 -0
  45. data/etc/presentations/testing.deck +28 -0
  46. data/etc/presentations/the_end.deck +13 -0
  47. data/etc/presentations/type_something_and_double_click.deck +57 -0
  48. data/etc/presentations/type_the_acronym.deck +144 -0
  49. data/etc/presentations/web_browser.deck +56 -0
  50. data/etc/presentations/xiki_command.deck +20 -0
  51. data/etc/presentations/xiki_url.deck +14 -0
  52. data/etc/shark.icns +0 -0
  53. data/etc/shark_script.icns +0 -0
  54. data/etc/snippets/html.notes +7 -0
  55. data/etc/snippets/notes.notes +20 -0
  56. data/etc/snippets/rb.notes +38 -0
  57. data/etc/templates/menu_template.menu +2 -0
  58. data/etc/templates/menu_template.rb +8 -0
  59. data/etc/templates/template.rb +5 -0
  60. data/etc/themes/Dark_Metal.notes +28 -0
  61. data/etc/themes/Orange_Path.notes +15 -0
  62. data/etc/themes/Shiny_Blue.notes +27 -0
  63. data/etc/themes/Shiny_Green.notes +27 -0
  64. data/etc/wrappers/wrapper.js +17 -0
  65. data/etc/wrappers/wrapper.py +20 -0
  66. data/etc/wrappers/wrapper.rb +25 -0
  67. data/lib/block.rb +72 -0
  68. data/lib/bookmarks.rb +352 -0
  69. data/lib/buffers.rb +170 -0
  70. data/lib/clipboard.rb +333 -0
  71. data/lib/code.rb +860 -0
  72. data/lib/code_tree.rb +476 -0
  73. data/lib/color.rb +274 -0
  74. data/lib/console.rb +557 -0
  75. data/lib/control_lock.rb +9 -0
  76. data/lib/control_tab.rb +176 -0
  77. data/lib/core_ext.rb +31 -0
  78. data/lib/cursor.rb +111 -0
  79. data/lib/deletes.rb +65 -0
  80. data/lib/diff_log.rb +297 -0
  81. data/lib/effects.rb +145 -0
  82. data/lib/environment.rb +5 -0
  83. data/lib/file_tree.rb +1875 -0
  84. data/lib/files.rb +334 -0
  85. data/lib/hide.rb +259 -0
  86. data/lib/history.rb +286 -0
  87. data/lib/image.rb +51 -0
  88. data/lib/incrementer.rb +15 -0
  89. data/lib/insert.rb +7 -0
  90. data/lib/irc.rb +22 -0
  91. data/lib/key_bindings.rb +658 -0
  92. data/lib/keys.rb +754 -0
  93. data/lib/launcher.rb +1351 -0
  94. data/lib/line.rb +429 -0
  95. data/lib/links.rb +6 -0
  96. data/lib/location.rb +175 -0
  97. data/lib/macros.rb +48 -0
  98. data/lib/man.rb +19 -0
  99. data/lib/menu.rb +708 -0
  100. data/lib/merb.rb +259 -0
  101. data/lib/message.rb +5 -0
  102. data/lib/meths.rb +56 -0
  103. data/lib/mode.rb +34 -0
  104. data/lib/move.rb +248 -0
  105. data/lib/notes.rb +1000 -0
  106. data/lib/numbers.rb +45 -0
  107. data/lib/ol.rb +203 -0
  108. data/lib/ol_helper.rb +44 -0
  109. data/lib/overlay.rb +167 -0
  110. data/lib/pause_means_space.rb +68 -0
  111. data/lib/php.rb +22 -0
  112. data/lib/projects.rb +21 -0
  113. data/lib/relinquish_exception.rb +2 -0
  114. data/lib/remote.rb +206 -0
  115. data/lib/requirer.rb +46 -0
  116. data/lib/rest_tree.rb +108 -0
  117. data/lib/ruby.rb +57 -0
  118. data/lib/ruby_console.rb +165 -0
  119. data/lib/search.rb +1572 -0
  120. data/lib/search_term.rb +40 -0
  121. data/lib/snippet.rb +68 -0
  122. data/lib/specs.rb +229 -0
  123. data/lib/styles.rb +274 -0
  124. data/lib/svn.rb +682 -0
  125. data/lib/text_util.rb +110 -0
  126. data/lib/tree.rb +1871 -0
  127. data/lib/tree_cursor.rb +87 -0
  128. data/lib/trouble_shooting.rb +27 -0
  129. data/lib/url_tree.rb +11 -0
  130. data/lib/view.rb +1474 -0
  131. data/lib/window.rb +133 -0
  132. data/lib/xiki.rb +404 -0
  133. data/menus/accounts.rb +5 -0
  134. data/menus/address_book.rb +21 -0
  135. data/menus/agenda.rb +28 -0
  136. data/menus/all.rb +5 -0
  137. data/menus/amazon.rb +16 -0
  138. data/menus/app.rb +16 -0
  139. data/menus/applescript.rb +46 -0
  140. data/menus/as.rb +15 -0
  141. data/menus/bookmarklet.rb +63 -0
  142. data/menus/bootstrap.rb +568 -0
  143. data/menus/browse.rb +13 -0
  144. data/menus/browser.rb +78 -0
  145. data/menus/cassandra_db.rb +36 -0
  146. data/menus/chmod.rb +27 -0
  147. data/menus/classes.rb +5 -0
  148. data/menus/coffee_script.rb +35 -0
  149. data/menus/computer.rb +24 -0
  150. data/menus/contacts.rb +5 -0
  151. data/menus/cookies.rb +25 -0
  152. data/menus/couch.rb +184 -0
  153. data/menus/crop.rb +45 -0
  154. data/menus/css.rb +55 -0
  155. data/menus/current.rb +5 -0
  156. data/menus/db.rb +12 -0
  157. data/menus/deck.rb +219 -0
  158. data/menus/dictionary.rb +9 -0
  159. data/menus/dir.rb +8 -0
  160. data/menus/disk.rb +5 -0
  161. data/menus/do.rb +13 -0
  162. data/menus/docs.rb +58 -0
  163. data/menus/dotsies.rb +107 -0
  164. data/menus/edited.rb +18 -0
  165. data/menus/emacs.rb +17 -0
  166. data/menus/enter.rb +13 -0
  167. data/menus/eval.rb +17 -0
  168. data/menus/executable.rb +16 -0
  169. data/menus/filter.rb +46 -0
  170. data/menus/firefox.rb +607 -0
  171. data/menus/foo.rb +30 -0
  172. data/menus/french.rb +7 -0
  173. data/menus/git.rb +185 -0
  174. data/menus/gito.rb +785 -0
  175. data/menus/google.rb +35 -0
  176. data/menus/google_images.rb +11 -0
  177. data/menus/google_patents.rb +10 -0
  178. data/menus/gutenberg.rb +13 -0
  179. data/menus/head.rb +10 -0
  180. data/menus/headings.rb +39 -0
  181. data/menus/html.rb +61 -0
  182. data/menus/icon.rb +40 -0
  183. data/menus/images.menu +2 -0
  184. data/menus/img.rb +15 -0
  185. data/menus/info.rb +9 -0
  186. data/menus/ip.rb +10 -0
  187. data/menus/iterm.rb +36 -0
  188. data/menus/itunes.rb +78 -0
  189. data/menus/javascript.rb +74 -0
  190. data/menus/layout.rb +18 -0
  191. data/menus/local_storage.rb +67 -0
  192. data/menus/ls.rb +19 -0
  193. data/menus/mac.rb +87 -0
  194. data/menus/maps.rb +18 -0
  195. data/menus/matches.rb +18 -0
  196. data/menus/memcache.rb +117 -0
  197. data/menus/mkdir.rb +23 -0
  198. data/menus/mongo.rb +83 -0
  199. data/menus/mysql.rb +294 -0
  200. data/menus/node.rb +88 -0
  201. data/menus/open.rb +19 -0
  202. data/menus/outline.rb +24 -0
  203. data/menus/piano.rb +746 -0
  204. data/menus/postgres.rb +34 -0
  205. data/menus/pre.rb +5 -0
  206. data/menus/python.rb +39 -0
  207. data/menus/rails.rb +160 -0
  208. data/menus/rake.rb +12 -0
  209. data/menus/redmine.rb +168 -0
  210. data/menus/riak_tree.rb +204 -0
  211. data/menus/rss.rb +15 -0
  212. data/menus/safari.rb +11 -0
  213. data/menus/sass.rb +15 -0
  214. data/menus/say.rb +6 -0
  215. data/menus/scale.rb +49 -0
  216. data/menus/serve.rb +78 -0
  217. data/menus/shuffle.rb +24 -0
  218. data/menus/spanish.rb +7 -0
  219. data/menus/standalone.rb +57 -0
  220. data/menus/tail.rb +41 -0
  221. data/menus/technologies.rb +19 -0
  222. data/menus/themes.rb +32 -0
  223. data/menus/thesaurus.rb +13 -0
  224. data/menus/to.rb +24 -0
  225. data/menus/twitter.rb +57 -0
  226. data/menus/wikipedia.rb +34 -0
  227. data/menus/words.rb +11 -0
  228. data/spec/code_tree_spec.rb +59 -0
  229. data/spec/diff_log_spec.rb +40 -0
  230. data/spec/file_tree_spec.rb +102 -0
  231. data/spec/keys_spec.rb +24 -0
  232. data/spec/line_spec.rb +68 -0
  233. data/spec/menu_spec.rb +50 -0
  234. data/spec/ol_spec.rb +98 -0
  235. data/spec/remote_spec.rb +43 -0
  236. data/spec/search_spec.rb +162 -0
  237. data/spec/text_util_spec.rb +119 -0
  238. data/spec/tree_cursor_spec.rb +91 -0
  239. data/spec/tree_spec.rb +955 -0
  240. data/tests/console_test.rb +11 -0
  241. data/tests/couch_db_test.rb +12 -0
  242. data/tests/diff_log_test.rb +43 -0
  243. data/tests/el_mixin.rb +16 -0
  244. data/tests/git_test.rb +95 -0
  245. data/tests/keys_test.rb +19 -0
  246. data/tests/line_test.rb +38 -0
  247. data/tests/merb_test.rb +11 -0
  248. data/tests/redmine_test.rb +50 -0
  249. data/tests/remote_test.rb +31 -0
  250. data/tests/rest_tree_test.rb +70 -0
  251. data/xiki.gemspec +37 -0
  252. metadata +332 -0
@@ -0,0 +1,34 @@
1
+ class Wikipedia
2
+
3
+ def self.menu name=nil
4
+ "
5
+ > See
6
+ << wp/
7
+ "
8
+ end
9
+
10
+ def self.wp name=nil
11
+ if name.nil?
12
+ # TODO: how to deal with fact that history will have wp and wikipedia? - pass in list:
13
+ # Maybe get the actual root pass it (wikipedia or wp)
14
+ # How to get it?
15
+ # Do: pass list into Launcher.last
16
+ # Launcher.last(["wp", "wikipedia"], :exclude_path=>1)
17
+ # or, just make it a regex?
18
+ # And add ^...$ inside .last
19
+
20
+ return (
21
+ Launcher.last("wp", :exclude_path=>1) +
22
+ Launcher.last("wikipedia", :exclude_path=>1)
23
+ )
24
+
25
+ end
26
+
27
+ Firefox.url "http://en.wikipedia.org/wiki/#{TextUtil.title_case name}"
28
+ ".flash - opened in browser!"
29
+ end
30
+ end
31
+
32
+ Menu.wp {|path|
33
+ Wikipedia.wp Tree.rootless(path)
34
+ }
@@ -0,0 +1,11 @@
1
+ class Words
2
+ def self.menu *args
3
+
4
+ # If no args, explain what it does
5
+ if args.empty?
6
+ return View.prompt "Add some text to count the words."
7
+ end
8
+
9
+ txt = ENV['txt'].scan(/[a-z']+/i).length.to_s
10
+ end
11
+ end
@@ -0,0 +1,59 @@
1
+ $:.unshift "spec/"
2
+ require 'xiki'
3
+ require 'code_tree'
4
+ # require 'core_ext'
5
+
6
+ describe CodeTree, "#extract_class" do
7
+
8
+ it "should extract method" do
9
+ CodeTree.extract_method("- .you/").should == "you"
10
+ CodeTree.extract_method("- Hey.you").should == "you"
11
+ CodeTree.extract_method("- .you").should == "you"
12
+ CodeTree.extract_method("- Wiki.menu('hey')").should == "menu('hey')"
13
+ CodeTree.extract_method("- .pages('new')").should == "pages('new')"
14
+ CodeTree.extract_method("- Wiki1.menu('hey')").should == "menu('hey')"
15
+ CodeTree.extract_method("- .merb_local").should == "merb_local"
16
+ CodeTree.extract_method("- Remote.dir 'f.com:21'").should == "dir 'f.com:21'"
17
+
18
+ end
19
+
20
+ it "should extract method with junk at beginning" do
21
+ CodeTree.extract_method("you there/").should == nil
22
+ CodeTree.extract_method(".you 'Bla.there'/").should == "you 'Bla.there'"
23
+ end
24
+
25
+ it "should extract class" do
26
+ CodeTree.extract_class("wiki1.menu('hey')").should == nil
27
+ CodeTree.extract_class("Wiki1.menu('hey')").should == "Wiki1"
28
+ CodeTree.extract_class("blaa Wiki1.menu('hey')").should == nil
29
+ end
30
+
31
+ it "should get class from parent" do
32
+ code = CodeTree.determine_code_from_path([
33
+ "Wiki.menu('hey')",
34
+ ".pages"])
35
+ code.should == "Wiki.pages()"
36
+ # assert_equal("Wiki.pages()", code)
37
+ end
38
+
39
+ it "should ignore parent when child is root" do
40
+ code = CodeTree.determine_code_from_path([
41
+ "Red.herring/", "Foo.menu/", ".php/"])
42
+ code.should == "Foo.php()"
43
+ end
44
+
45
+ it "should add curlies when hash" do
46
+ code = CodeTree.determine_code_from_path(["CodeTree.menu/",
47
+ "ProtoNight.menu/", ".data/", ".local/",
48
+ ".send_invite_emails :date=>'2010-02-17'", "- Hey\n- You"])
49
+ code.should == "ProtoNight.send_invite_emails( {:date=>'2010-02-17'}, \"Hey\n- You\")"
50
+ end
51
+
52
+ # # Should get class from parent
53
+ # def test_with_params
54
+ # code = CodeTree.determine_code_from_path(["Foo.menu/", ".php(10)/", "mt"])
55
+ # assert_equal("Foo.php(10, 'mt')", code)
56
+ # end
57
+
58
+ end
59
+
@@ -0,0 +1,40 @@
1
+ $:.unshift "spec/"
2
+ require 'line'
3
+ require 'ol'
4
+ require 'diff_log'
5
+ # require 'core_ext'
6
+
7
+ describe Line, "#parse_tree_diffs" do
8
+ # it "parses a rename" do
9
+ # DiffLog.parse_tree_diffs("d5 1\na5 1\n - cccc\n").should == [[[5, " - cccc"]], [5]]
10
+ # end
11
+
12
+ it "parses a delete" do
13
+ DiffLog.parse_tree_diffs("d3 2\nd6 1\n").should == [[], [3, 4, 6]]
14
+ end
15
+
16
+ # it "parses a move" do
17
+ # DiffLog.parse_tree_diffs("d4 1\na7 1\n - bb\n").should == [[[7, " - bb"]], [4]]
18
+ # end
19
+
20
+ # it "parses an add" do
21
+ # DiffLog.parse_tree_diffs("a24 1\n - nn\n").should == [[[24, " - nn"]], []]
22
+ # end
23
+
24
+ # it "parses 2 adds and 2 deletes" do
25
+ # DiffLog.parse_tree_diffs("d12 2\na15 2\n - cc\n - dd\n").should == [[[15, " - cc"], [16, " - dd"]], [12, 13]]
26
+ # end
27
+ end
28
+
29
+ describe Line, "#last_edit" do
30
+ it "calculates addition" do
31
+ txt = DiffLog.last_intraline_diff "- /tmp/\n - t.txt\n :10\n |-aaaaa\n |+aaHIaaa\n"
32
+ txt.should == ["", "HI"]
33
+ end
34
+
35
+ it "calculates deletion" do
36
+ txt = DiffLog.last_intraline_diff "- /tmp/\n - t.txt\n :10\n |-heyyyy\n |+yyy\n"
37
+ txt.should == ["hey", ""]
38
+ end
39
+ end
40
+
@@ -0,0 +1,102 @@
1
+ $:.unshift "spec/"
2
+ require 'file_tree'
3
+ require 'core_ext'
4
+
5
+
6
+ describe "handles?" do
7
+ it "handles when slash" do
8
+ FileTree.handles?(["/tmp/", "aa/"]).should == 0
9
+ end
10
+
11
+ it "doesn't handle when slash not at root" do
12
+ FileTree.handles?(["foo/", "/tmp/"]).should == nil
13
+ end
14
+ end
15
+
16
+
17
+ describe "matches_root_pattern?" do
18
+ it "handles root" do
19
+ !!FileTree.matches_root_pattern?("/").should == true
20
+ !!FileTree.matches_root_pattern?("/hey").should == true
21
+ end
22
+
23
+ it "handles others" do
24
+ !!FileTree.matches_root_pattern?("~/aa").should == true
25
+ !!FileTree.matches_root_pattern?("./aa").should == true
26
+ end
27
+
28
+ it "declines non-file paths" do
29
+ !!FileTree.matches_root_pattern?("hey").should == false
30
+ !!FileTree.matches_root_pattern?("hey/you").should == false
31
+ end
32
+ end
33
+
34
+
35
+ describe "snippet" do
36
+ it "uses options" do
37
+ FileTree.snippet(:txt=>"hey", :file=>"/tmp/file_tree.rb").should == "/tmp/\n - file_tree.rb\n | hey\n"
38
+ end
39
+ end
40
+
41
+
42
+ # TODO 2011-11-11: turn these into specs!
43
+
44
+
45
+
46
+ # def test_move_dir_to_junior_internal
47
+ # before =
48
+ # "|- /projects/foo/
49
+ # | - pages.rb
50
+ # |".gsub(/^ *\|/, '')
51
+ # after =
52
+ # "|- /projects/
53
+ # | - foo/
54
+ # | - pages.rb
55
+ # |".gsub(/^ *\|/, '')
56
+ # assert_equal after, FileTree.move_dir_to_junior_internal(before)
57
+ # end
58
+ # def test_move_dir_to_junior_internal_indented
59
+ # before =
60
+ # "| - app/controllers/
61
+ # | - pages.rb
62
+ # | |def
63
+ # |".gsub(/^ *\|/, '')
64
+ # after =
65
+ # "| - app/
66
+ # | - controllers/
67
+ # | - pages.rb
68
+ # | |def
69
+ # |".gsub(/^ *\|/, '')
70
+ # assert_equal after, FileTree.move_dir_to_junior_internal(before)
71
+ # end
72
+ # def test_move_dir_to_junior_internal_indented
73
+ # before =
74
+ # "|- app/controllers/
75
+ # | - pages.rb
76
+ # |- stay
77
+ # |".gsub(/^ *\|/, '')
78
+ # after =
79
+ # "|- app/
80
+ # | - controllers/
81
+ # | - pages.rb
82
+ # |- stay
83
+ # |".gsub(/^ *\|/, '')
84
+ # assert_equal after, FileTree.move_dir_to_junior_internal(before)
85
+ # end
86
+
87
+ # def test_move_dir_to_junior_internal_indented_complex
88
+ # before =
89
+ # "| - app/controllers/
90
+ # | - pages.rb
91
+ # | - stay
92
+ # | - stay2
93
+ # |".gsub(/^ *\|/, '')
94
+ # after =
95
+ # "| - app/
96
+ # | - controllers/
97
+ # | - pages.rb
98
+ # | - stay
99
+ # | - stay2
100
+ # |".gsub(/^ *\|/, '')
101
+ # assert_equal after, FileTree.move_dir_to_junior_internal(before)
102
+ # end
@@ -0,0 +1,24 @@
1
+ # $:.unshift "spec/"
2
+ # require 'keys'
3
+ # require 'ol'
4
+
5
+ # describe Keys, "#input" do
6
+ # before(:each) do
7
+
8
+ # View = mock 'View'
9
+ # # Cursor = mock 'Cursor', :remember=>1, :green=>1, :hollow=>1
10
+ # # Cursor = mock 'Cursor', :null_object=>true
11
+ # # Cursor = mock # :null_object=>true
12
+ # # Cursor = mock :null_object=>true
13
+ # # Cursor = mock 'Cursor', :null_object=>true
14
+ # $el = mock "el", :read_char=>98 # doesn't matter what it returns
15
+ # @choices = [['aaa', 'Aye'], ['bbb', 'Bye']]
16
+ # end
17
+
18
+ # it "with :choices param, gives choice according to char typed" do
19
+ # $el.stub!(:char_to_string).and_return "a"
20
+ # Keys.input(:prompt=>'letters: ', :choices=>@choices).should == 'Aye'
21
+ # $el.stub!(:char_to_string).and_return "b"
22
+ # Keys.input(:prompt=>'letters: ', :choices=>@choices).should == 'Bye'
23
+ # end
24
+ # end
@@ -0,0 +1,68 @@
1
+ $:.unshift "spec/"
2
+ require 'line'
3
+ require 'core_ext'
4
+
5
+ describe Line, "#without_label" do
6
+ it "removes bullets" do
7
+ Line.without_label(:line=>"- you").should == "you"
8
+ end
9
+
10
+ it "should remove new parethesis labels" do
11
+ Line.without_label(:line=>"- hey) you").should == "you"
12
+ end
13
+
14
+ it "should keep labels if opening paren" do
15
+ Line.without_label(:line=>"- (hey) you").should == "(hey) you"
16
+ end
17
+
18
+ it "should respect collapse bullets" do
19
+ Line.without_label(:line=>"< hey) you").should == "you"
20
+ end
21
+
22
+ it "should respect multiple collapse bullets" do
23
+ Line.without_label(:line=>"<< hey) you").should == "you"
24
+ end
25
+
26
+ it "should respect multiple collapses and only label" do
27
+ Line.without_label(:line=>"<< hey)").should == ""
28
+ end
29
+
30
+ it "should leave old style labels" do
31
+ Line.without_label(:line=>"- hey: you").should == "hey: you"
32
+ end
33
+
34
+ end
35
+
36
+ # class LineTest < Test::Unit::TestCase
37
+
38
+ # def test_normal
39
+ # assert_equal "you", Line.without_label(:line=>"- hey: you")
40
+ # end
41
+
42
+ # def test_just_bullet
43
+ # assert_equal "you", Line.without_label(:line=>"- you")
44
+ # end
45
+
46
+ # def test_blank
47
+ # assert_equal "", Line.without_label(:line=>"- hey: ")
48
+ # end
49
+
50
+ # def test_with_indent
51
+ # assert_equal "you", Line.without_label(:line=>" - hey: you")
52
+ # assert_equal "", Line.without_label(:line=>" - hey: ")
53
+ # assert_equal "you", Line.without_label(:line=>" - you")
54
+ # end
55
+
56
+ # def test_leave_indent
57
+ # assert_equal " you", Line.without_label(:line=>" - hey: you", :leave_indent=>true)
58
+ # assert_equal " ", Line.without_label(:line=>" - hey: ", :leave_indent=>true)
59
+ # end
60
+
61
+ # # Make sure it doesn't mess up the string
62
+ # def test_side_effects
63
+ # before = " - label: hey1"
64
+ # Line.without_label(:line=>before)
65
+ # assert_equal " - label: hey1", before
66
+ # end
67
+
68
+ # end
@@ -0,0 +1,50 @@
1
+ $:.unshift "spec/"
2
+ require 'ol'
3
+ require 'tree'
4
+ require 'core_ext'
5
+ require 'mode'
6
+ class Mode
7
+ def self.define *args; end
8
+ end
9
+ require 'menu'
10
+
11
+ describe Menu, "#split" do
12
+ it "splits normal strings" do
13
+ Menu.split("bb").should == ["bb"]
14
+ Menu.split("aa/bb").should == ["aa", "bb"]
15
+ Menu.split("aa/|bb").should == ["aa", "|bb"]
16
+ end
17
+
18
+ it "handles :rootless option" do
19
+ Menu.split("bb", :rootless=>1).should == []
20
+ Menu.split("aa/bb", :rootless=>1).should == ["bb"]
21
+ end
22
+
23
+ it "handles trailing slashes" do
24
+ Menu.split("dom/body/").should == ["dom", "body"]
25
+ Menu.split("dom/body/", :rootless=>1).should == ["body"]
26
+ end
27
+
28
+ it "handles pipes" do
29
+ Menu.split("aa/|b/b").should == ["aa", "|b/b"]
30
+ Menu.split("aa/|b/b/|c/c").should == ["aa", "|b/b", "|c/c"]
31
+ end
32
+
33
+ it "handles :rootless with pipes" do
34
+ Menu.split("dom/| </div>", :rootless=>1).should == ["| </div>"]
35
+ end
36
+ end
37
+
38
+ describe Menu, "#menu_to_hash" do
39
+ it "handles simple menu" do
40
+ input = "
41
+ | dotsies.loc : /projects/dotsies.org/www/
42
+ | dotsies.org : /xiki@xiki.org/var/www/dotsies.org/
43
+ ".unindent
44
+
45
+ Menu.menu_to_hash(input).should == {
46
+ "dotsies.loc"=>"/projects/dotsies.org/www/",
47
+ "dotsies.org"=>"/xiki@xiki.org/var/www/dotsies.org/",
48
+ }
49
+ end
50
+ end
@@ -0,0 +1,98 @@
1
+ $:.unshift "spec/"
2
+ require 'line'
3
+ require 'ol'
4
+ require 'core_ext'
5
+
6
+ def define_vars
7
+ @stack = [
8
+ "/projects/moo/moo.merb/app/models/cache.rb:77:in `get'",
9
+ "/projects/moo/moo.merb/app/models/user.rb:28:in `exists?'",
10
+ "/projects/moo/moo.merb/app/controllers/accounts.rb:248:in `check_availability'",
11
+ "/Library/Ruby/Gems/1.8/gems/merb-action-args-1.1/lib/merb-action-args/abstract_controller.rb:42:in `__send__'",
12
+ "/Library/Ruby/Gems/1.8/gems/merb-action-args-1.1/lib/merb-action-args/abstract_controller.rb:42:in `_call_action'"
13
+ ]
14
+ @stack_limited = [
15
+ "/projects/moo/moo.merb/app/controllers/accounts.rb:248:in `check_availability'",
16
+ "/projects/moo/moo.merb/app/models/user.rb:28:in `exists?'",
17
+ "/projects/moo/moo.merb/app/models/cache.rb:77:in `get'"
18
+ ]
19
+ @stack_limited_previous = [
20
+ "/projects/moo/moo.merb/app/controllers/accounts.rb:248:in `check_availability'",
21
+ "/projects/moo/moo.merb/app/models/user.rb:8:in `exists?'",
22
+ "/projects/moo/moo.merb/app/models/cache.rb:7:in `get'"
23
+ ]
24
+ end
25
+
26
+ describe Ol, "#parse_line" do
27
+ it "pulls out relevant parts" do
28
+ h = Ol.parse_line "/projects/moo/moo.merb/app/models/cache.rb:77:in `get'"
29
+ h.should == {:path=>"/projects/moo/moo.merb/app/models/cache.rb", :line=>"77", :method=>'get', :clazz=>'Cache'}
30
+ end
31
+ end
32
+
33
+ describe Ol, "#remove_redundance" do
34
+ before(:each) do
35
+ define_vars
36
+ end
37
+
38
+ it "removes lines outside of a project" do
39
+ stack = Ol.remove_redundance @stack_limited, @stack_limited_previous
40
+ stack.should == [nil, @stack_limited[1], @stack_limited[2]]
41
+ end
42
+
43
+ it "doesn't remove all lines" do
44
+ stack = Ol.remove_redundance @stack_limited, @stack_limited
45
+ stack.should == [nil, nil, @stack_limited[2]]
46
+ end
47
+ end
48
+
49
+ describe Ol, "#limit_stack" do
50
+ before(:each) do
51
+ define_vars
52
+ end
53
+
54
+ it "should remove lines outside of a project" do
55
+ Ol.limit_stack @stack
56
+ @stack.size.should == 3
57
+ @stack.should == @stack_limited
58
+ end
59
+
60
+ it "should leave one line if all don't match" do
61
+ Ol.limit_stack @stack, /^\/xx/
62
+ @stack.size.should == 1
63
+ @stack.should == ["/projects/moo/moo.merb/app/models/cache.rb:77:in `get'"]
64
+ end
65
+ end
66
+
67
+ describe Ol, "#line" do
68
+ before(:each) do
69
+ @line = "/projects/moo/moo.merb/app/controllers/accounts.rb:24:in `check'"
70
+ end
71
+
72
+ it "writes line to log with label like - class.method (line):" do
73
+ Ol.should_receive(:pause_since_last?).and_return false
74
+ Ol.should_receive(:write_to_file).with('/tmp/ds_ol.notes', "- Accounts.check 24) hi\n")
75
+ Ol.should_receive(:write_to_file_lines).with("/tmp/ds_ol.notes", "/projects/moo/moo.merb/app/controllers/accounts.rb:24\n")
76
+
77
+ Ol.line "hi", @line, "", "ds"#, @@last_log
78
+ end
79
+ end
80
+
81
+ describe Ol, "#log" do
82
+ before(:each) do
83
+ define_vars
84
+ # @line = "/projects/moo/moo.merb/app/controllers/accounts.rb:24:in `check'"
85
+ end
86
+
87
+ it "writes lines to log when stack is passed in" do
88
+ Ol.should_receive(:pause_since_last?).and_return false
89
+ Ol.should_receive(:write_to_file).with('/tmp/ds_ol.notes', "- Cache.get 77)\n - User.exists? 28)\n - Accounts.check_availability 248) hi\n")
90
+ Ol.should_receive(:write_to_file_lines).with("/tmp/ds_ol.notes", "/projects/moo/moo.merb/app/models/cache.rb:77\n/projects/moo/moo.merb/app/models/user.rb:28\n/projects/moo/moo.merb/app/controllers/accounts.rb:248\n")
91
+
92
+ Ol.log "hi", @stack[0..2], "ds"#, @@last_log
93
+ end
94
+
95
+ # TODO 1 reverse them
96
+ # TODO 1 make it indent
97
+
98
+ end