Skip to content
Browse files

Consolidated duplicated support files created by automatic TM bundle …

…conversion.
  • Loading branch information...
1 parent ef8e136 commit 0f5ba78978ff081ec761e848553085c078c1c73f @bobthecow committed May 9, 2010
Showing with 15 additions and 4,040 deletions.
  1. +15 −15 Contents/Info.plist
  2. 0 ...-7A54-4C4E-A315-02247461D9D4/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/add_to_multifile_gist}
  3. 0 ...4FF6-9AB7-46187500012D/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/annotate_blame_comment_line}
  4. 0 ...-4152-923B-99D0B94B46B9/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/create_gist_from_selection}
  5. 0 ...7C-7CF1A56B1710/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/create_private_gist_from_selection}
  6. 0 ...06-0BE2-49EA-B672-B34F56F880EB/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/send_multifile_gist}
  7. 0 ...4DA0-A077-E1396148A1F9/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/send_private_multifile_gist}
  8. 0 ...C4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/script → 452D34DC-9122-4196-9BB1-BA571D21A8BB/show_in_github}
  9. 0 Contents/Resources/452D34DC-9122-4196-9BB1-BA571D21A8BB/{script → show_network_in_github}
  10. +0 −6 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb
  11. +0 −22 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb
  12. +0 −8 ...ts/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb
  13. +0 −6 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb
  14. +0 −15 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb
  15. +0 −16 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb
  16. +0 −129 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb
  17. +0 −6 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb
  18. +0 −131 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb
  19. +0 −30 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb
  20. BIN Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/tmp_gists
  21. +0 −34 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb
  22. +0 −22 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb
  23. +0 −15 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb
  24. +0 −84 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb
  25. +0 −51 ...ces/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb
  26. +0 −6 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb
  27. +0 −22 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb
  28. +0 −8 ...ts/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb
  29. +0 −6 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb
  30. +0 −15 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb
  31. +0 −16 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb
  32. +0 −129 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb
  33. +0 −6 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb
  34. +0 −131 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb
  35. +0 −30 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb
  36. BIN Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/tmp_gists
  37. +0 −34 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb
  38. +0 −22 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb
  39. +0 −15 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb
  40. +0 −84 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb
  41. +0 −51 ...ces/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb
  42. +0 −6 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb
  43. +0 −22 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb
  44. +0 −8 ...ts/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb
  45. +0 −6 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb
  46. +0 −15 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb
  47. +0 −16 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb
  48. +0 −129 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb
  49. +0 −6 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb
  50. +0 −131 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb
  51. +0 −30 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb
  52. BIN Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/tmp_gists
  53. +0 −34 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb
  54. +0 −22 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb
  55. +0 −15 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb
  56. +0 −84 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb
  57. +0 −51 ...ces/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_line_in_commit_in_github.rb
  58. +0 −6 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/add_to_multifile_gist.rb
  59. +0 −22 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/comment_on_line.rb
  60. +0 −8 ...ts/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/create_gist_from_selection.rb
  61. +0 −6 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/send_multifile_gist.rb
  62. +0 −15 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_in_github.rb
  63. +0 −16 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/bin/show_network_in_github.rb
  64. +0 −129 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/gist.rb
  65. +0 −6 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git-ext/commit.rb
  66. +0 −131 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/git_manager.rb
  67. +0 −30 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/show_in_github.rb
  68. BIN Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/lib/tmp_gists
  69. +0 −34 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_manager.rb
  70. +0 −22 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_git_object_commit.rb
  71. +0 −15 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_helper.rb
  72. +0 −84 Contents/Resources/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_in_github.rb
  73. +0 −51 ...ces/67262491-0033-4FF6-9AB7-46187500012D/Support Files/test/test_show_line_in_commit_in_github.rb
  74. +0 −6 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/add_to_multifile_gist.rb
  75. +0 −22 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/comment_on_line.rb
  76. +0 −8 ...ts/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/create_gist_from_selection.rb
  77. +0 −6 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/send_multifile_gist.rb
  78. +0 −15 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_in_github.rb
  79. +0 −16 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/bin/show_network_in_github.rb
  80. +0 −129 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/gist.rb
  81. +0 −6 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git-ext/commit.rb
  82. +0 −131 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/git_manager.rb
  83. +0 −30 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/show_in_github.rb
  84. BIN Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/lib/tmp_gists
  85. +0 −34 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_manager.rb
  86. +0 −22 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_git_object_commit.rb
  87. +0 −15 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_helper.rb
  88. +0 −84 Contents/Resources/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_in_github.rb
  89. +0 −51 ...ces/C5646D06-0BE2-49EA-B672-B34F56F880EB/Support Files/test/test_show_line_in_commit_in_github.rb
  90. +0 −6 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/add_to_multifile_gist.rb
  91. +0 −22 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/comment_on_line.rb
  92. +0 −8 ...ts/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/create_gist_from_selection.rb
  93. +0 −6 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/send_multifile_gist.rb
  94. +0 −15 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_in_github.rb
  95. +0 −16 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/bin/show_network_in_github.rb
  96. +0 −129 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/gist.rb
  97. +0 −6 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git-ext/commit.rb
  98. +0 −131 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/git_manager.rb
  99. +0 −30 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/show_in_github.rb
  100. BIN Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/lib/tmp_gists
  101. +0 −34 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_manager.rb
  102. +0 −22 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_git_object_commit.rb
  103. +0 −15 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_helper.rb
  104. +0 −84 Contents/Resources/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_in_github.rb
  105. +0 −51 ...ces/C8E0241B-0139-4DA0-A077-E1396148A1F9/Support Files/test/test_show_line_in_commit_in_github.rb
  106. +0 −6 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/add_to_multifile_gist.rb
  107. +0 −22 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/comment_on_line.rb
  108. +0 −8 ...ts/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/create_gist_from_selection.rb
  109. +0 −6 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/send_multifile_gist.rb
  110. +0 −15 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_in_github.rb
  111. +0 −16 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/bin/show_network_in_github.rb
  112. +0 −129 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/gist.rb
  113. +0 −6 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git-ext/commit.rb
  114. +0 −131 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/git_manager.rb
  115. +0 −30 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/show_in_github.rb
  116. BIN Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/lib/tmp_gists
  117. +0 −34 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_manager.rb
  118. +0 −22 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_git_object_commit.rb
  119. +0 −15 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_helper.rb
  120. +0 −84 Contents/Resources/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_in_github.rb
  121. +0 −51 ...ces/DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/Support Files/test/test_show_line_in_commit_in_github.rb
View
30 Contents/Info.plist
@@ -38,9 +38,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>annotate_blame_comment_line</string>
<key>uuid</key>
- <string>67262491-0033-4FF6-9AB7-46187500012D</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>input</key>
@@ -54,9 +54,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>add_to_multifile_gist</string>
<key>uuid</key>
- <string>51A5A6E5-7A54-4C4E-A315-02247461D9D4</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>input</key>
@@ -70,9 +70,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>create_private_gist_from_selection</string>
<key>uuid</key>
- <string>4F4468C5-5CF8-4272-B87C-7CF1A56B1710</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>input</key>
@@ -86,9 +86,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>create_gist_from_selection</string>
<key>uuid</key>
- <string>4D3B092F-0ABC-4152-923B-99D0B94B46B9</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>input</key>
@@ -102,9 +102,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>send_private_multifile_gist</string>
<key>uuid</key>
- <string>C8E0241B-0139-4DA0-A077-E1396148A1F9</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>fallbackInput</key>
@@ -120,9 +120,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>show_in_github</string>
<key>uuid</key>
- <string>DC4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>input</key>
@@ -136,9 +136,9 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>send_multifile_gist</string>
<key>uuid</key>
- <string>C5646D06-0BE2-49EA-B672-B34F56F880EB</string>
+ <string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
<dict>
<key>fallbackInput</key>
@@ -154,7 +154,7 @@
<key>output</key>
<string>showAsTooltip</string>
<key>script</key>
- <string>script</string>
+ <string>show_network_in_github</string>
<key>uuid</key>
<string>452D34DC-9122-4196-9BB1-BA571D21A8BB</string>
</dict>
View
0 ...A5A6E5-7A54-4C4E-A315-02247461D9D4/script → ...6-9BB1-BA571D21A8BB/add_to_multifile_gist
File renamed without changes.
View
0 ...262491-0033-4FF6-9AB7-46187500012D/script → ...-BA571D21A8BB/annotate_blame_comment_line
File renamed without changes.
View
0 ...3B092F-0ABC-4152-923B-99D0B94B46B9/script → ...1-BA571D21A8BB/create_gist_from_selection
File renamed without changes.
View
0 ...4468C5-5CF8-4272-B87C-7CF1A56B1710/script → ...21A8BB/create_private_gist_from_selection
File renamed without changes.
View
0 ...646D06-0BE2-49EA-B672-B34F56F880EB/script → ...196-9BB1-BA571D21A8BB/send_multifile_gist
File renamed without changes.
View
0 ...E0241B-0139-4DA0-A077-E1396148A1F9/script → ...-BA571D21A8BB/send_private_multifile_gist
File renamed without changes.
View
0 ...4D5C6F-80DA-4FDF-815F-EEF68C1FC3E9/script → ...122-4196-9BB1-BA571D21A8BB/show_in_github
File renamed without changes.
View
0 ...2D34DC-9122-4196-9BB1-BA571D21A8BB/script → ...-9BB1-BA571D21A8BB/show_network_in_github
File renamed without changes.
View
6 ...Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/add_to_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.process_selection
View
22 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/comment_on_line.rb
@@ -1,22 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-if ENV['TM_INPUT_START_LINE']
- puts "Do not select lines, just leave the cursor on a line of interest"
- exit
-end
-
-begin
- if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE'])
- `open #{url}`
- else
- puts "This line has been modified or commit has not been pushed to GitHub"
- end
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
8 ...rces/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/create_gist_from_selection.rb
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.clear
-Gist.process_selection
-Gist.send(ARGV[0] == "private")
View
6 ...s/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/send_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.send(ARGV[0] == "private")
View
15 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_in_github.rb
@@ -1,15 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-begin
- url = ShowInGitHub.url_for(ENV['TM_FILEPATH'])
- lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER']
- `open #{url}#L#{lines}`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
16 ...esources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/bin/show_network_in_github.rb
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "git_manager"
-
-begin
- git = GitManager.new(ENV['TM_FILEPATH'])
- url = git.github_url_for_project
-
- `open #{url}network`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
129 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/gist.rb
@@ -1,129 +0,0 @@
-# Copyright 2008 Chris Wanstrath
-# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master
-
-require 'open-uri'
-require 'net/http'
-
-module Gist
- extend self
-
- @@gist_url = 'http://gist.github.com/%s.txt'
- @@files = []
-
- def read(gist_id)
- open(@@gist_url % gist_id).read
- end
-
- def add_file(name, content)
- load_files
- @@files << {:name => name, :content => content}
- puts "#{name} added."
- save_files
- end
-
- def write(private_gist)
- load_files
- url = URI.parse('http://gist.github.com/gists')
- req = Net::HTTP.post_form(url, data(private_gist))
- url = copy req['Location']
- puts "Created gist at #{url}. URL copied to clipboard."
- clear
- end
-
- def clear
- @@files = []
- save_files
- end
-
- def process_selection
- selection = nil
- gistname = nil
- if ENV['TM_SELECTED_TEXT']
- selection = ENV['TM_SELECTED_TEXT']
- gistname = "snippet" << "." << get_extension
- else
- selection = STDIN.read
- gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension
- end
-
- add_file(gistname, selection)
- end
-
- # Add extension for supported modes based on TM_SCOPE
- # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el
- def get_extension
- scope = ENV["TM_SCOPE"].split[0]
- case scope
- when /source\.actionscript/ then "as"
- when /source\.c/, /source\.objc/ then "c"
- when /source\.c\+\+/, /source\.objc\+\+/ then "cpp"
- # common-lisp-mode then "el"
- when /source\.css/ then "css"
- when /source\.diff/, "meta.diff.range" then "diff"
- # emacs-lisp-mode then "el"
- when /source\.erlang/ then "erl"
- when /source\.haskell/, "text.tex.latex.haskel" then "hs"
- when /text\.html/ then "html"
- when /source\.io/ then "io"
- when /source\.java/ then "java"
- when /source\.js/ then "js"
- # jde-mode then "java"
- # js2-mode then "js"
- when /source\.lua/ then "lua"
- when /source\.ocaml/ then "ml"
- when /source\.objc/, "source.objc++" then "m"
- when /source\.perl/ then "pl"
- when /source\.php/ then "php"
- when /source\.python/ then "sc"
- when /source\.ruby/ then "rb" # Emacs bundle uses rbx
- when /text\.plain/ then "txt"
- when /source\.sql/ then "sql"
- when /source\.scheme/ then "scm"
- when /source\.smalltalk/ then "st"
- when /source\.shell/ then "sh"
- when /source\.tcl/, "text.html.tcl" then "tcl"
- when /source\.lex/ then "tex"
- when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml"
- else "txt"
- end
- end
-
-private
- def load_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- save_files unless File.exists?(path)
- @@files = Marshal.load(File.read(path))
- @@files ||= []
- end
-
- def save_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) }
- end
-
- def copy(content)
- return content if `which pbcopy`.strip == ''
- IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
- content
- end
-
- def data(private_gist)
- params = {}
- @@files.each_with_index do |file, i|
- params.merge!({
- "file_ext[gistfile#{i+1}]" => nil,
- "file_name[gistfile#{i+1}]" => file[:name],
- "file_contents[gistfile#{i+1}]" => file[:content]
- })
- end
- params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth)
- end
-
- def auth
- user = `git config --global github.user`.strip
- token = `git config --global github.token`.strip
-
- user.empty? ? {} : { :login => user, :token => token }
- end
-end
-
View
6 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git-ext/commit.rb
@@ -1,6 +0,0 @@
-class Git::Object::Commit
- # Ordered list of files within a commit
- def file_paths
- diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq
- end
-end
View
131 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/git_manager.rb
@@ -1,131 +0,0 @@
-gem 'git', '>=1.0.0'
-require 'git'
-require 'git-ext/commit'
-require 'net/http'
-
-class GitManager
- attr_reader :git, :target_file
-
- def initialize(target_file)
- @target_file = target_file || ""
- find_working_dir
- end
-
- def remotes
- config_remotes = config.keys.inject([]) do |mem, key|
- if key =~ %r{\Aremote\.(.*)\.url}
- mem << $1
- end
- mem
- end
- end
-
- def github_remotes
- remotes.inject([]) do |mem, remote|
- if repo_for_remote(remote) =~ %r{github\.com}
- mem << remote
- end
- mem
- end
- end
-
- def best_github_remote
- remotes = github_remotes
- selected_remote = 'github' if remotes.include?('github')
- selected_remote ||= 'origin' if remotes.include?('origin')
- selected_remote ||= remotes.first
- raise NotGitHubRepositoryError unless selected_remote
-
- return selected_remote
- end
-
- def user_project_from_repo(repo)
- if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git}
- return {:user => $1, :project => $2}
- end
- return
- end
-
- def github_url_for_project(github_remote=nil)
- github_remote ||= best_github_remote
- repo = repo_for_remote(github_remote)
- if user_project = user_project_from_repo(repo)
- url_head(user_project)
- end
- end
-
- def file_to_github_url(github_remote, branch='master', file=nil)
- file ||= target_file
- branch ||= @git.current_branch
- repo = repo_for_remote(github_remote)
- path = file.gsub(working_path, '').gsub(%r{\A/},'')
- if user_project = user_project_from_repo(repo)
- user, project = $1, $2
- response = nil
- url_head(user_project, branch) + "/#{path}"
- end
- end
-
- def relative_file(file=nil)
- file ||= target_file
- file = File.expand_path(file).sub(%r{\A#{working_path}/}, '')
- end
-
- # Returns the Git::Object::Commit that adds a +line+
- def find_commit_with_line(line)
- git.log.path(@file).each do |commit|
- return commit if line_in_diff?(commit.diff_parent.to_s, line)
- end
- nil
- end
-
- # Check if the exact line was added in a specific commit (via its parent_diff)
- # TODO - Ensure line is within specific +file+, else might get match within wrong file
- # parent_diff - the results of Git::Object::Commit#parent_diff
- # line - the exact string to match on one line of the diff
- def line_in_diff?(parent_diff, line)
- parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" }
- end
-
- def git?
- git
- end
-
- def working_path
- git.instance_variable_get("@working_directory").path
- end
-
- protected
- def config
- git.config
- end
-
- def find_working_dir
- path = File.dirname(File.expand_path(target_file))
- path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"]
- @git = nil
- while !@git && path_bits.length > 1
- path = path_bits.join('/')
- path_bits.pop unless (@git = Git.open(path) rescue nil)
- end
- raise NotGitRepositoryError unless @git
- end
-
- def repo_for_remote(remote)
- config["remote.#{remote}.url"]
- end
-
- def url_head(user_project, branch='')
- branch = "tree/#{branch}" if branch != ''
- project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}"
- project_private?(project_path) ?
- "https://github.com#{project_path}" : "http://github.com#{project_path}"
- end
-
- def project_private?(project_path)
- response=nil
- Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) }
- response and response.code.to_i == 302 and response['location'] =~ %r{https:}
- end
-
-end
View
30 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/show_in_github.rb
@@ -1,30 +0,0 @@
-require 'git_manager'
-
-class NotGitRepositoryError < Exception; end
-class NotGitHubRepositoryError < Exception; end
-class CommitNotFoundError < Exception; end
-# SocketError can be thrown when testing public access to repo
-
-module ShowInGitHub
- extend self
- attr_reader :git
-
- def url_for(file_path)
- @git = GitManager.new(file_path)
- git.file_to_github_url(git.best_github_remote)
- end
-
- # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead
- # -l complete hash
- # -s strips user fu
- def line_to_github_url(file_path, line_str)
- return nil unless file_url = url_for(file_path)
- project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '')
- commit = git.find_commit_with_line(line_str)
- return nil unless commit
- file_index = commit.file_paths.index(git.relative_file(file_path))
- "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}"
- end
-
-
-end
View
BIN Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/lib/tmp_gists
Binary file not shown.
View
34 ...nts/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_manager.rb
@@ -1,34 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-
-class TestGitManager < Test::Unit::TestCase
- def setup
- @git = GitManager.new(__FILE__) # pass this file just cause we need some file
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- end
-
- def test_get_remotes
- expected = %w[origin rubyforge]
- assert_equal(expected, @git.remotes)
- end
-
- def test_get_remotes_on_github
- expected = %w[origin]
- assert_equal(expected, @git.github_remotes)
- end
-
- def test_github_pages_account_remote_urls_can_be_parsed
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*"
- })
- expected = "http://github.com/railscampau/railscampau.github.com/"
- assert_equal(expected, @git.github_url_for_project)
- end
-end
View
22 ...sources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_git_object_commit.rb
@@ -1,22 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestGitObjectCommit < Test::Unit::TestCase
- attr_reader :git
- def setup
- @git = GitManager.new __FILE__
- puts "These tests require the project to be checked out of git to work" unless @git
- end
-
- def test_extract_file_paths_from_commit
- mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221"
- expected_files = [
- 'Support/lib/git_manager.rb',
- 'Support/test/test_helper.rb',
- 'Support/test/test_show_line_in_commit_in_github.rb'
- ]
- commit = Git::Object::Commit.new(git.git, mutli_file_commit)
- actual_files = commit.file_paths
- assert_equal(expected_files, actual_files)
- end
-end
View
15 Contents/Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_helper.rb
@@ -1,15 +0,0 @@
-require "test/unit"
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-
-require "pp"
-require 'rubygems'
-%w[mocha Shoulda].each do |gem_name|
- begin
- require gem_name
- rescue LoadError => e
- puts "You must install #{gem_name} rubygem before running these tests"
- exit
- end
-end
-
-require "git_manager"
View
84 .../Resources/4D3B092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_in_github.rb
@@ -1,84 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowInGithub < Test::Unit::TestCase
- def setup
- GitManager.any_instance.stubs(:git?).returns(true)
- GitManager.any_instance.stubs(:project_private?).returns(false)
- end
-
- def test_do_nothing_if_file_not_under_git_repo
- GitManager.any_instance.stubs(:git?).returns(false)
- GitManager.any_instance.stubs(:config).returns(nil)
- assert_raise(NotGitRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_do_nothing_if_no_repo_is_with_github
- GitManager.any_instance.stubs(:config).returns({
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- assert_raise(NotGitHubRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_construct_github_url_for_file
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_prioritize_github_over_other_remote_names
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git",
- "remote.github.url"=>"git@github.com:drnic/newgem-github.git",
- "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git",
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem-github/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_prioritize_origin_over_other_remote_names_except_origin
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git",
- "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git",
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem-origin/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_project_is_private_should_use_https
- GitManager.any_instance.stubs(:project_private?).returns(true)
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "https://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_anonymous_repo
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git://github.com/drnic/newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-end
View
51 ...092F-0ABC-4152-923B-99D0B94B46B9/Support Files/test/test_show_line_in_commit_in_github.rb
@@ -1,51 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowLineInCommitInGitHub < Test::Unit::TestCase
- attr_reader :git
- def setup
- @git = GitManager.new __FILE__
- @file = git.relative_file
- puts "These tests require the project to be checked out of git to work" unless @git
- end
-
- def test_find_first_commit_for_this_file
- line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
- expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03"
- actual = git.find_commit_with_line(line_in_first_commit)
- assert_equal(expected, actual.to_s)
- end
-
- def test_find_line_in_diff
- # diff_parent is a reverse diff, so added lines prefix with -; removed lines +
- diff_parent = <<-DIFF
-diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb
-deleted file mode 100644
-index 63b416f..0000000
---- a/Support/test/test_show_line_in_commit_in_github.rb
-+++ /dev/null
-@@ -1,8 +0,0 @@
--require File.dirname(__FILE__) + "/test_helper"
--require "show_in_github"
--
--class TestShowLineInCommitInGitHub < Test::Unit::TestCase
-- def test_find_first_commit_for_this_file
--
-- end
--end
-\ No newline at end of file
- DIFF
- current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
- assert git.line_in_diff?(diff_parent, current_line), "should find line in diff"
- assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff"
- end
-
- def test_github_url_for_line_in_commit
- url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit")
- expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2"
- assert_equal(expected, url)
- end
-
- should_eventually "test_file_index_within_multi_file_commit" do
- end
-end
View
6 ...Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/add_to_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.process_selection
View
22 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/comment_on_line.rb
@@ -1,22 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-if ENV['TM_INPUT_START_LINE']
- puts "Do not select lines, just leave the cursor on a line of interest"
- exit
-end
-
-begin
- if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE'])
- `open #{url}`
- else
- puts "This line has been modified or commit has not been pushed to GitHub"
- end
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
8 ...rces/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/create_gist_from_selection.rb
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.clear
-Gist.process_selection
-Gist.send(ARGV[0] == "private")
View
6 ...s/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/send_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.send(ARGV[0] == "private")
View
15 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_in_github.rb
@@ -1,15 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-begin
- url = ShowInGitHub.url_for(ENV['TM_FILEPATH'])
- lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER']
- `open #{url}#L#{lines}`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
16 ...esources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/bin/show_network_in_github.rb
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "git_manager"
-
-begin
- git = GitManager.new(ENV['TM_FILEPATH'])
- url = git.github_url_for_project
-
- `open #{url}network`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
129 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/gist.rb
@@ -1,129 +0,0 @@
-# Copyright 2008 Chris Wanstrath
-# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master
-
-require 'open-uri'
-require 'net/http'
-
-module Gist
- extend self
-
- @@gist_url = 'http://gist.github.com/%s.txt'
- @@files = []
-
- def read(gist_id)
- open(@@gist_url % gist_id).read
- end
-
- def add_file(name, content)
- load_files
- @@files << {:name => name, :content => content}
- puts "#{name} added."
- save_files
- end
-
- def write(private_gist)
- load_files
- url = URI.parse('http://gist.github.com/gists')
- req = Net::HTTP.post_form(url, data(private_gist))
- url = copy req['Location']
- puts "Created gist at #{url}. URL copied to clipboard."
- clear
- end
-
- def clear
- @@files = []
- save_files
- end
-
- def process_selection
- selection = nil
- gistname = nil
- if ENV['TM_SELECTED_TEXT']
- selection = ENV['TM_SELECTED_TEXT']
- gistname = "snippet" << "." << get_extension
- else
- selection = STDIN.read
- gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension
- end
-
- add_file(gistname, selection)
- end
-
- # Add extension for supported modes based on TM_SCOPE
- # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el
- def get_extension
- scope = ENV["TM_SCOPE"].split[0]
- case scope
- when /source\.actionscript/ then "as"
- when /source\.c/, /source\.objc/ then "c"
- when /source\.c\+\+/, /source\.objc\+\+/ then "cpp"
- # common-lisp-mode then "el"
- when /source\.css/ then "css"
- when /source\.diff/, "meta.diff.range" then "diff"
- # emacs-lisp-mode then "el"
- when /source\.erlang/ then "erl"
- when /source\.haskell/, "text.tex.latex.haskel" then "hs"
- when /text\.html/ then "html"
- when /source\.io/ then "io"
- when /source\.java/ then "java"
- when /source\.js/ then "js"
- # jde-mode then "java"
- # js2-mode then "js"
- when /source\.lua/ then "lua"
- when /source\.ocaml/ then "ml"
- when /source\.objc/, "source.objc++" then "m"
- when /source\.perl/ then "pl"
- when /source\.php/ then "php"
- when /source\.python/ then "sc"
- when /source\.ruby/ then "rb" # Emacs bundle uses rbx
- when /text\.plain/ then "txt"
- when /source\.sql/ then "sql"
- when /source\.scheme/ then "scm"
- when /source\.smalltalk/ then "st"
- when /source\.shell/ then "sh"
- when /source\.tcl/, "text.html.tcl" then "tcl"
- when /source\.lex/ then "tex"
- when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml"
- else "txt"
- end
- end
-
-private
- def load_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- save_files unless File.exists?(path)
- @@files = Marshal.load(File.read(path))
- @@files ||= []
- end
-
- def save_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) }
- end
-
- def copy(content)
- return content if `which pbcopy`.strip == ''
- IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
- content
- end
-
- def data(private_gist)
- params = {}
- @@files.each_with_index do |file, i|
- params.merge!({
- "file_ext[gistfile#{i+1}]" => nil,
- "file_name[gistfile#{i+1}]" => file[:name],
- "file_contents[gistfile#{i+1}]" => file[:content]
- })
- end
- params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth)
- end
-
- def auth
- user = `git config --global github.user`.strip
- token = `git config --global github.token`.strip
-
- user.empty? ? {} : { :login => user, :token => token }
- end
-end
-
View
6 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git-ext/commit.rb
@@ -1,6 +0,0 @@
-class Git::Object::Commit
- # Ordered list of files within a commit
- def file_paths
- diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq
- end
-end
View
131 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/git_manager.rb
@@ -1,131 +0,0 @@
-gem 'git', '>=1.0.0'
-require 'git'
-require 'git-ext/commit'
-require 'net/http'
-
-class GitManager
- attr_reader :git, :target_file
-
- def initialize(target_file)
- @target_file = target_file || ""
- find_working_dir
- end
-
- def remotes
- config_remotes = config.keys.inject([]) do |mem, key|
- if key =~ %r{\Aremote\.(.*)\.url}
- mem << $1
- end
- mem
- end
- end
-
- def github_remotes
- remotes.inject([]) do |mem, remote|
- if repo_for_remote(remote) =~ %r{github\.com}
- mem << remote
- end
- mem
- end
- end
-
- def best_github_remote
- remotes = github_remotes
- selected_remote = 'github' if remotes.include?('github')
- selected_remote ||= 'origin' if remotes.include?('origin')
- selected_remote ||= remotes.first
- raise NotGitHubRepositoryError unless selected_remote
-
- return selected_remote
- end
-
- def user_project_from_repo(repo)
- if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git}
- return {:user => $1, :project => $2}
- end
- return
- end
-
- def github_url_for_project(github_remote=nil)
- github_remote ||= best_github_remote
- repo = repo_for_remote(github_remote)
- if user_project = user_project_from_repo(repo)
- url_head(user_project)
- end
- end
-
- def file_to_github_url(github_remote, branch='master', file=nil)
- file ||= target_file
- branch ||= @git.current_branch
- repo = repo_for_remote(github_remote)
- path = file.gsub(working_path, '').gsub(%r{\A/},'')
- if user_project = user_project_from_repo(repo)
- user, project = $1, $2
- response = nil
- url_head(user_project, branch) + "/#{path}"
- end
- end
-
- def relative_file(file=nil)
- file ||= target_file
- file = File.expand_path(file).sub(%r{\A#{working_path}/}, '')
- end
-
- # Returns the Git::Object::Commit that adds a +line+
- def find_commit_with_line(line)
- git.log.path(@file).each do |commit|
- return commit if line_in_diff?(commit.diff_parent.to_s, line)
- end
- nil
- end
-
- # Check if the exact line was added in a specific commit (via its parent_diff)
- # TODO - Ensure line is within specific +file+, else might get match within wrong file
- # parent_diff - the results of Git::Object::Commit#parent_diff
- # line - the exact string to match on one line of the diff
- def line_in_diff?(parent_diff, line)
- parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" }
- end
-
- def git?
- git
- end
-
- def working_path
- git.instance_variable_get("@working_directory").path
- end
-
- protected
- def config
- git.config
- end
-
- def find_working_dir
- path = File.dirname(File.expand_path(target_file))
- path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"]
- @git = nil
- while !@git && path_bits.length > 1
- path = path_bits.join('/')
- path_bits.pop unless (@git = Git.open(path) rescue nil)
- end
- raise NotGitRepositoryError unless @git
- end
-
- def repo_for_remote(remote)
- config["remote.#{remote}.url"]
- end
-
- def url_head(user_project, branch='')
- branch = "tree/#{branch}" if branch != ''
- project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}"
- project_private?(project_path) ?
- "https://github.com#{project_path}" : "http://github.com#{project_path}"
- end
-
- def project_private?(project_path)
- response=nil
- Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) }
- response and response.code.to_i == 302 and response['location'] =~ %r{https:}
- end
-
-end
View
30 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/show_in_github.rb
@@ -1,30 +0,0 @@
-require 'git_manager'
-
-class NotGitRepositoryError < Exception; end
-class NotGitHubRepositoryError < Exception; end
-class CommitNotFoundError < Exception; end
-# SocketError can be thrown when testing public access to repo
-
-module ShowInGitHub
- extend self
- attr_reader :git
-
- def url_for(file_path)
- @git = GitManager.new(file_path)
- git.file_to_github_url(git.best_github_remote)
- end
-
- # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead
- # -l complete hash
- # -s strips user fu
- def line_to_github_url(file_path, line_str)
- return nil unless file_url = url_for(file_path)
- project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '')
- commit = git.find_commit_with_line(line_str)
- return nil unless commit
- file_index = commit.file_paths.index(git.relative_file(file_path))
- "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}"
- end
-
-
-end
View
BIN Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/lib/tmp_gists
Binary file not shown.
View
34 ...nts/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_manager.rb
@@ -1,34 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-
-class TestGitManager < Test::Unit::TestCase
- def setup
- @git = GitManager.new(__FILE__) # pass this file just cause we need some file
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- end
-
- def test_get_remotes
- expected = %w[origin rubyforge]
- assert_equal(expected, @git.remotes)
- end
-
- def test_get_remotes_on_github
- expected = %w[origin]
- assert_equal(expected, @git.github_remotes)
- end
-
- def test_github_pages_account_remote_urls_can_be_parsed
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*"
- })
- expected = "http://github.com/railscampau/railscampau.github.com/"
- assert_equal(expected, @git.github_url_for_project)
- end
-end
View
22 ...sources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_git_object_commit.rb
@@ -1,22 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestGitObjectCommit < Test::Unit::TestCase
- attr_reader :git
- def setup
- @git = GitManager.new __FILE__
- puts "These tests require the project to be checked out of git to work" unless @git
- end
-
- def test_extract_file_paths_from_commit
- mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221"
- expected_files = [
- 'Support/lib/git_manager.rb',
- 'Support/test/test_helper.rb',
- 'Support/test/test_show_line_in_commit_in_github.rb'
- ]
- commit = Git::Object::Commit.new(git.git, mutli_file_commit)
- actual_files = commit.file_paths
- assert_equal(expected_files, actual_files)
- end
-end
View
15 Contents/Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_helper.rb
@@ -1,15 +0,0 @@
-require "test/unit"
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-
-require "pp"
-require 'rubygems'
-%w[mocha Shoulda].each do |gem_name|
- begin
- require gem_name
- rescue LoadError => e
- puts "You must install #{gem_name} rubygem before running these tests"
- exit
- end
-end
-
-require "git_manager"
View
84 .../Resources/4F4468C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_in_github.rb
@@ -1,84 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowInGithub < Test::Unit::TestCase
- def setup
- GitManager.any_instance.stubs(:git?).returns(true)
- GitManager.any_instance.stubs(:project_private?).returns(false)
- end
-
- def test_do_nothing_if_file_not_under_git_repo
- GitManager.any_instance.stubs(:git?).returns(false)
- GitManager.any_instance.stubs(:config).returns(nil)
- assert_raise(NotGitRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_do_nothing_if_no_repo_is_with_github
- GitManager.any_instance.stubs(:config).returns({
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- assert_raise(NotGitHubRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_construct_github_url_for_file
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_prioritize_github_over_other_remote_names
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git",
- "remote.github.url"=>"git@github.com:drnic/newgem-github.git",
- "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git",
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem-github/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_prioritize_origin_over_other_remote_names_except_origin
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem-origin.git",
- "remote.somethingelse.url"=>"git@github.com:drnic/newgem-somethingelse.git",
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem-origin/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_project_is_private_should_use_https
- GitManager.any_instance.stubs(:project_private?).returns(true)
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "https://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-
- def test_anonymous_repo
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git://github.com/drnic/newgem.git"
- })
- GitManager.any_instance.stubs(:working_path).returns("/some/path")
- url = ShowInGitHub.url_for("/some/path/to/file")
- expected = "http://github.com/drnic/newgem/tree/master/to/file"
- assert_equal(expected, url)
- end
-end
View
51 ...68C5-5CF8-4272-B87C-7CF1A56B1710/Support Files/test/test_show_line_in_commit_in_github.rb
@@ -1,51 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowLineInCommitInGitHub < Test::Unit::TestCase
- attr_reader :git
- def setup
- @git = GitManager.new __FILE__
- @file = git.relative_file
- puts "These tests require the project to be checked out of git to work" unless @git
- end
-
- def test_find_first_commit_for_this_file
- line_in_first_commit = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
- expected = "3becfbcb01574cb4efbcc553ad4be37f6e428e03"
- actual = git.find_commit_with_line(line_in_first_commit)
- assert_equal(expected, actual.to_s)
- end
-
- def test_find_line_in_diff
- # diff_parent is a reverse diff, so added lines prefix with -; removed lines +
- diff_parent = <<-DIFF
-diff --git a/Support/test/test_show_line_in_commit_in_github.rb b/Support/test/test_show_line_in_commit_in_github.rb
-deleted file mode 100644
-index 63b416f..0000000
---- a/Support/test/test_show_line_in_commit_in_github.rb
-+++ /dev/null
-@@ -1,8 +0,0 @@
--require File.dirname(__FILE__) + "/test_helper"
--require "show_in_github"
--
--class TestShowLineInCommitInGitHub < Test::Unit::TestCase
-- def test_find_first_commit_for_this_file
--
-- end
--end
-\ No newline at end of file
- DIFF
- current_line = "class TestShowLineInCommitInGitHub < Test::Unit::TestCase"
- assert git.line_in_diff?(diff_parent, current_line), "should find line in diff"
- assert !git.line_in_diff?(diff_parent, "-" + current_line), "should not find modded line in diff"
- end
-
- def test_github_url_for_line_in_commit
- url = ShowInGitHub.line_to_github_url(File.expand_path(__FILE__), " def test_file_index_within_multi_file_commit")
- expected = "http://github.com/drnic/github-tmbundle/commit/c9e07eb199092fef6a0b744915d49b0aeb646221#diff-2"
- assert_equal(expected, url)
- end
-
- should_eventually "test_file_index_within_multi_file_commit" do
- end
-end
View
6 ...Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/add_to_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.process_selection
View
22 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/comment_on_line.rb
@@ -1,22 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-if ENV['TM_INPUT_START_LINE']
- puts "Do not select lines, just leave the cursor on a line of interest"
- exit
-end
-
-begin
- if url = ShowInGitHub.line_to_github_url(ENV['TM_FILEPATH'], ENV['TM_CURRENT_LINE'])
- `open #{url}`
- else
- puts "This line has been modified or commit has not been pushed to GitHub"
- end
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
8 ...rces/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/create_gist_from_selection.rb
@@ -1,8 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.clear
-Gist.process_selection
-Gist.send(ARGV[0] == "private")
View
6 ...s/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/send_multifile_gist.rb
@@ -1,6 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "gist"
-
-Gist.send(ARGV[0] == "private")
View
15 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_in_github.rb
@@ -1,15 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "show_in_github"
-
-begin
- url = ShowInGitHub.url_for(ENV['TM_FILEPATH'])
- lines = ENV['TM_INPUT_START_LINE'] ? "#{ENV['TM_INPUT_START_LINE']}-#{ENV['TM_LINE_NUMBER']}" : ENV['TM_LINE_NUMBER']
- `open #{url}#L#{lines}`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
16 ...esources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/bin/show_network_in_github.rb
@@ -1,16 +0,0 @@
-#!/usr/bin/env ruby
-
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-require "rubygems"
-require "git_manager"
-
-begin
- git = GitManager.new(ENV['TM_FILEPATH'])
- url = git.github_url_for_project
-
- `open #{url}network`
-rescue NotGitRepositoryError
- puts "File/project not a git repository"
-rescue NotGitHubRepositoryError
- puts "File/project has not been pushed to a github repository"
-end
View
129 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/gist.rb
@@ -1,129 +0,0 @@
-# Copyright 2008 Chris Wanstrath
-# Taken from defunkt's gist repository: http://github.com/defunkt/gist/tree/master
-
-require 'open-uri'
-require 'net/http'
-
-module Gist
- extend self
-
- @@gist_url = 'http://gist.github.com/%s.txt'
- @@files = []
-
- def read(gist_id)
- open(@@gist_url % gist_id).read
- end
-
- def add_file(name, content)
- load_files
- @@files << {:name => name, :content => content}
- puts "#{name} added."
- save_files
- end
-
- def write(private_gist)
- load_files
- url = URI.parse('http://gist.github.com/gists')
- req = Net::HTTP.post_form(url, data(private_gist))
- url = copy req['Location']
- puts "Created gist at #{url}. URL copied to clipboard."
- clear
- end
-
- def clear
- @@files = []
- save_files
- end
-
- def process_selection
- selection = nil
- gistname = nil
- if ENV['TM_SELECTED_TEXT']
- selection = ENV['TM_SELECTED_TEXT']
- gistname = "snippet" << "." << get_extension
- else
- selection = STDIN.read
- gistname = ENV['TM_FILEPATH'] ? ENV['TM_FILEPATH'].sub(ENV['TM_PROJECT_DIRECTORY'], '') : "file" << "." << get_extension
- end
-
- add_file(gistname, selection)
- end
-
- # Add extension for supported modes based on TM_SCOPE
- # Cribbed from http://github.com/defunkt/gist.el/tree/master/gist.el
- def get_extension
- scope = ENV["TM_SCOPE"].split[0]
- case scope
- when /source\.actionscript/ then "as"
- when /source\.c/, /source\.objc/ then "c"
- when /source\.c\+\+/, /source\.objc\+\+/ then "cpp"
- # common-lisp-mode then "el"
- when /source\.css/ then "css"
- when /source\.diff/, "meta.diff.range" then "diff"
- # emacs-lisp-mode then "el"
- when /source\.erlang/ then "erl"
- when /source\.haskell/, "text.tex.latex.haskel" then "hs"
- when /text\.html/ then "html"
- when /source\.io/ then "io"
- when /source\.java/ then "java"
- when /source\.js/ then "js"
- # jde-mode then "java"
- # js2-mode then "js"
- when /source\.lua/ then "lua"
- when /source\.ocaml/ then "ml"
- when /source\.objc/, "source.objc++" then "m"
- when /source\.perl/ then "pl"
- when /source\.php/ then "php"
- when /source\.python/ then "sc"
- when /source\.ruby/ then "rb" # Emacs bundle uses rbx
- when /text\.plain/ then "txt"
- when /source\.sql/ then "sql"
- when /source\.scheme/ then "scm"
- when /source\.smalltalk/ then "st"
- when /source\.shell/ then "sh"
- when /source\.tcl/, "text.html.tcl" then "tcl"
- when /source\.lex/ then "tex"
- when /text\.xml/, /text\.xml\.xsl/, /source\.plist/, /text\.xml\.plist/ then "xml"
- else "txt"
- end
- end
-
-private
- def load_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- save_files unless File.exists?(path)
- @@files = Marshal.load(File.read(path))
- @@files ||= []
- end
-
- def save_files
- path = File.join(File.dirname(__FILE__), 'tmp_gists')
- File.open(path, 'w') {|f| f.puts Marshal.dump(@@files) }
- end
-
- def copy(content)
- return content if `which pbcopy`.strip == ''
- IO.popen('pbcopy', 'r+') { |clip| clip.puts content }
- content
- end
-
- def data(private_gist)
- params = {}
- @@files.each_with_index do |file, i|
- params.merge!({
- "file_ext[gistfile#{i+1}]" => nil,
- "file_name[gistfile#{i+1}]" => file[:name],
- "file_contents[gistfile#{i+1}]" => file[:content]
- })
- end
- params.merge(private_gist ? { 'private' => 'on' } : {}).merge(auth)
- end
-
- def auth
- user = `git config --global github.user`.strip
- token = `git config --global github.token`.strip
-
- user.empty? ? {} : { :login => user, :token => token }
- end
-end
-
View
6 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git-ext/commit.rb
@@ -1,6 +0,0 @@
-class Git::Object::Commit
- # Ordered list of files within a commit
- def file_paths
- diff_parent.to_s.scan(%r{^-{3,4}\sa/(.*)$})[0..-1].flatten.uniq
- end
-end
View
131 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/git_manager.rb
@@ -1,131 +0,0 @@
-gem 'git', '>=1.0.0'
-require 'git'
-require 'git-ext/commit'
-require 'net/http'
-
-class GitManager
- attr_reader :git, :target_file
-
- def initialize(target_file)
- @target_file = target_file || ""
- find_working_dir
- end
-
- def remotes
- config_remotes = config.keys.inject([]) do |mem, key|
- if key =~ %r{\Aremote\.(.*)\.url}
- mem << $1
- end
- mem
- end
- end
-
- def github_remotes
- remotes.inject([]) do |mem, remote|
- if repo_for_remote(remote) =~ %r{github\.com}
- mem << remote
- end
- mem
- end
- end
-
- def best_github_remote
- remotes = github_remotes
- selected_remote = 'github' if remotes.include?('github')
- selected_remote ||= 'origin' if remotes.include?('origin')
- selected_remote ||= remotes.first
- raise NotGitHubRepositoryError unless selected_remote
-
- return selected_remote
- end
-
- def user_project_from_repo(repo)
- if repo =~ %r{github\.com[:/]([^/]+)/(.+)\.git}
- return {:user => $1, :project => $2}
- end
- return
- end
-
- def github_url_for_project(github_remote=nil)
- github_remote ||= best_github_remote
- repo = repo_for_remote(github_remote)
- if user_project = user_project_from_repo(repo)
- url_head(user_project)
- end
- end
-
- def file_to_github_url(github_remote, branch='master', file=nil)
- file ||= target_file
- branch ||= @git.current_branch
- repo = repo_for_remote(github_remote)
- path = file.gsub(working_path, '').gsub(%r{\A/},'')
- if user_project = user_project_from_repo(repo)
- user, project = $1, $2
- response = nil
- url_head(user_project, branch) + "/#{path}"
- end
- end
-
- def relative_file(file=nil)
- file ||= target_file
- file = File.expand_path(file).sub(%r{\A#{working_path}/}, '')
- end
-
- # Returns the Git::Object::Commit that adds a +line+
- def find_commit_with_line(line)
- git.log.path(@file).each do |commit|
- return commit if line_in_diff?(commit.diff_parent.to_s, line)
- end
- nil
- end
-
- # Check if the exact line was added in a specific commit (via its parent_diff)
- # TODO - Ensure line is within specific +file+, else might get match within wrong file
- # parent_diff - the results of Git::Object::Commit#parent_diff
- # line - the exact string to match on one line of the diff
- def line_in_diff?(parent_diff, line)
- parent_diff.to_s.split("\n").find { |diff_line| diff_line == "-#{line}" }
- end
-
- def git?
- git
- end
-
- def working_path
- git.instance_variable_get("@working_directory").path
- end
-
- protected
- def config
- git.config
- end
-
- def find_working_dir
- path = File.dirname(File.expand_path(target_file))
- path_bits = path.split('/') # => ["", "Users", "drnic", "Documents", "ruby", "gems", "newgem", "bin"]
- @git = nil
- while !@git && path_bits.length > 1
- path = path_bits.join('/')
- path_bits.pop unless (@git = Git.open(path) rescue nil)
- end
- raise NotGitRepositoryError unless @git
- end
-
- def repo_for_remote(remote)
- config["remote.#{remote}.url"]
- end
-
- def url_head(user_project, branch='')
- branch = "tree/#{branch}" if branch != ''
- project_path = "/#{user_project[:user]}/#{user_project[:project]}/#{branch}"
- project_private?(project_path) ?
- "https://github.com#{project_path}" : "http://github.com#{project_path}"
- end
-
- def project_private?(project_path)
- response=nil
- Net::HTTP.start('github.com', 80) { |http| response = http.head(project_path) }
- response and response.code.to_i == 302 and response['location'] =~ %r{https:}
- end
-
-end
View
30 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/show_in_github.rb
@@ -1,30 +0,0 @@
-require 'git_manager'
-
-class NotGitRepositoryError < Exception; end
-class NotGitHubRepositoryError < Exception; end
-class CommitNotFoundError < Exception; end
-# SocketError can be thrown when testing public access to repo
-
-module ShowInGitHub
- extend self
- attr_reader :git
-
- def url_for(file_path)
- @git = GitManager.new(file_path)
- git.file_to_github_url(git.best_github_remote)
- end
-
- # TODO - investigate using "git blame -l -s -L 3,3 app/models/user.rb" instead
- # -l complete hash
- # -s strips user fu
- def line_to_github_url(file_path, line_str)
- return nil unless file_url = url_for(file_path)
- project_url = file_url.sub(%r{/tree/.*/#{File.basename(file_path)}$}, '')
- commit = git.find_commit_with_line(line_str)
- return nil unless commit
- file_index = commit.file_paths.index(git.relative_file(file_path))
- "#{project_url}/commit/#{commit.to_s}#diff-#{file_index}"
- end
-
-
-end
View
BIN Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/lib/tmp_gists
Binary file not shown.
View
34 ...nts/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_manager.rb
@@ -1,34 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-
-class TestGitManager < Test::Unit::TestCase
- def setup
- @git = GitManager.new(__FILE__) # pass this file just cause we need some file
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- end
-
- def test_get_remotes
- expected = %w[origin rubyforge]
- assert_equal(expected, @git.remotes)
- end
-
- def test_get_remotes_on_github
- expected = %w[origin]
- assert_equal(expected, @git.github_remotes)
- end
-
- def test_github_pages_account_remote_urls_can_be_parsed
- @git.stubs(:config).returns({
- "user.name"=>"Dr Nic Williams", "user.email"=>"drnicwilliams@gmail.com",
- "remote.origin.url"=>"git@github.com:railscampau/railscampau.github.com.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*"
- })
- expected = "http://github.com/railscampau/railscampau.github.com/"
- assert_equal(expected, @git.github_url_for_project)
- end
-end
View
22 ...sources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_git_object_commit.rb
@@ -1,22 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestGitObjectCommit < Test::Unit::TestCase
- attr_reader :git
- def setup
- @git = GitManager.new __FILE__
- puts "These tests require the project to be checked out of git to work" unless @git
- end
-
- def test_extract_file_paths_from_commit
- mutli_file_commit = "c9e07eb199092fef6a0b744915d49b0aeb646221"
- expected_files = [
- 'Support/lib/git_manager.rb',
- 'Support/test/test_helper.rb',
- 'Support/test/test_show_line_in_commit_in_github.rb'
- ]
- commit = Git::Object::Commit.new(git.git, mutli_file_commit)
- actual_files = commit.file_paths
- assert_equal(expected_files, actual_files)
- end
-end
View
15 Contents/Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_helper.rb
@@ -1,15 +0,0 @@
-require "test/unit"
-$:.unshift(File.dirname(__FILE__) + "/../lib")
-
-require "pp"
-require 'rubygems'
-%w[mocha Shoulda].each do |gem_name|
- begin
- require gem_name
- rescue LoadError => e
- puts "You must install #{gem_name} rubygem before running these tests"
- exit
- end
-end
-
-require "git_manager"
View
84 .../Resources/51A5A6E5-7A54-4C4E-A315-02247461D9D4/Support Files/test/test_show_in_github.rb
@@ -1,84 +0,0 @@
-require File.dirname(__FILE__) + "/test_helper"
-require "show_in_github"
-
-class TestShowInGithub < Test::Unit::TestCase
- def setup
- GitManager.any_instance.stubs(:git?).returns(true)
- GitManager.any_instance.stubs(:project_private?).returns(false)
- end
-
- def test_do_nothing_if_file_not_under_git_repo
- GitManager.any_instance.stubs(:git?).returns(false)
- GitManager.any_instance.stubs(:config).returns(nil)
- assert_raise(NotGitRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_do_nothing_if_no_repo_is_with_github
- GitManager.any_instance.stubs(:config).returns({
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"=>"gitosis@rubyforge.org:newgem.git"
- })
- assert_raise(NotGitHubRepositoryError) do
- ShowInGitHub.url_for("/some/path/to/file")
- end
- end
-
- def test_construct_github_url_for_file
- GitManager.any_instance.stubs(:config).returns({
- "remote.origin.url"=>"git@github.com:drnic/newgem.git",
- "remote.origin.fetch"=>"refs/heads/*:refs/remotes/origin/*",
- "remote.rubyforge.fetch"=>"refs/heads/*:refs/remotes/rubyforge/*",
- "remote.rubyforge.url"