amp 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (232) hide show
  1. data/.gitignore +12 -0
  2. data/.hgignore +3 -0
  3. data/AUTHORS +1 -1
  4. data/Manifest.txt +99 -38
  5. data/README.md +3 -3
  6. data/Rakefile +53 -18
  7. data/SCHEDULE.markdown +5 -1
  8. data/TODO.markdown +120 -149
  9. data/ampfile.rb +3 -1
  10. data/bin/amp +4 -1
  11. data/ext/amp/bz2/extconf.rb +1 -1
  12. data/ext/amp/mercurial_patch/extconf.rb +1 -1
  13. data/ext/amp/mercurial_patch/mpatch.c +4 -3
  14. data/ext/amp/priority_queue/extconf.rb +1 -1
  15. data/ext/amp/support/extconf.rb +1 -1
  16. data/ext/amp/support/support.c +1 -1
  17. data/lib/amp.rb +125 -67
  18. data/lib/amp/commands/command.rb +12 -10
  19. data/lib/amp/commands/command_support.rb +8 -1
  20. data/lib/amp/commands/commands/help.rb +2 -20
  21. data/lib/amp/commands/commands/init.rb +14 -2
  22. data/lib/amp/commands/commands/templates.rb +6 -4
  23. data/lib/amp/commands/commands/version.rb +15 -1
  24. data/lib/amp/commands/commands/workflow.rb +3 -3
  25. data/lib/amp/commands/commands/workflows/git/add.rb +3 -3
  26. data/lib/amp/commands/commands/workflows/git/copy.rb +1 -1
  27. data/lib/amp/commands/commands/workflows/git/rm.rb +4 -2
  28. data/lib/amp/commands/commands/workflows/hg/add.rb +1 -1
  29. data/lib/amp/commands/commands/workflows/hg/addremove.rb +2 -2
  30. data/lib/amp/commands/commands/workflows/hg/annotate.rb +8 -2
  31. data/lib/amp/commands/commands/workflows/hg/bisect.rb +253 -0
  32. data/lib/amp/commands/commands/workflows/hg/branch.rb +1 -1
  33. data/lib/amp/commands/commands/workflows/hg/branches.rb +3 -3
  34. data/lib/amp/commands/commands/workflows/hg/bundle.rb +3 -3
  35. data/lib/amp/commands/commands/workflows/hg/clone.rb +4 -5
  36. data/lib/amp/commands/commands/workflows/hg/commit.rb +37 -1
  37. data/lib/amp/commands/commands/workflows/hg/copy.rb +2 -1
  38. data/lib/amp/commands/commands/workflows/hg/debug/index.rb +1 -1
  39. data/lib/amp/commands/commands/workflows/hg/diff.rb +3 -8
  40. data/lib/amp/commands/commands/workflows/hg/forget.rb +5 -4
  41. data/lib/amp/commands/commands/workflows/hg/identify.rb +6 -6
  42. data/lib/amp/commands/commands/workflows/hg/import.rb +1 -1
  43. data/lib/amp/commands/commands/workflows/hg/incoming.rb +2 -2
  44. data/lib/amp/commands/commands/workflows/hg/log.rb +5 -4
  45. data/lib/amp/commands/commands/workflows/hg/merge.rb +1 -1
  46. data/lib/amp/commands/commands/workflows/hg/move.rb +5 -3
  47. data/lib/amp/commands/commands/workflows/hg/outgoing.rb +1 -1
  48. data/lib/amp/commands/commands/workflows/hg/push.rb +6 -7
  49. data/lib/amp/commands/commands/workflows/hg/remove.rb +2 -2
  50. data/lib/amp/commands/commands/workflows/hg/resolve.rb +6 -23
  51. data/lib/amp/commands/commands/workflows/hg/root.rb +1 -2
  52. data/lib/amp/commands/commands/workflows/hg/status.rb +21 -12
  53. data/lib/amp/commands/commands/workflows/hg/tag.rb +2 -2
  54. data/lib/amp/commands/commands/workflows/hg/untrack.rb +12 -0
  55. data/lib/amp/commands/commands/workflows/hg/verify.rb +13 -3
  56. data/lib/amp/commands/commands/workflows/hg/what_changed.rb +18 -0
  57. data/lib/amp/commands/dispatch.rb +12 -13
  58. data/lib/amp/dependencies/amp_support.rb +1 -1
  59. data/lib/amp/dependencies/amp_support/ruby_amp_support.rb +1 -0
  60. data/lib/amp/dependencies/maruku.rb +136 -0
  61. data/lib/amp/dependencies/maruku/attributes.rb +227 -0
  62. data/lib/amp/dependencies/maruku/defaults.rb +71 -0
  63. data/lib/amp/dependencies/maruku/errors_management.rb +92 -0
  64. data/lib/amp/dependencies/maruku/helpers.rb +260 -0
  65. data/lib/amp/dependencies/maruku/input/charsource.rb +326 -0
  66. data/lib/amp/dependencies/maruku/input/extensions.rb +69 -0
  67. data/lib/amp/dependencies/maruku/input/html_helper.rb +189 -0
  68. data/lib/amp/dependencies/maruku/input/linesource.rb +111 -0
  69. data/lib/amp/dependencies/maruku/input/parse_block.rb +615 -0
  70. data/lib/amp/dependencies/maruku/input/parse_doc.rb +234 -0
  71. data/lib/amp/dependencies/maruku/input/parse_span_better.rb +746 -0
  72. data/lib/amp/dependencies/maruku/input/rubypants.rb +225 -0
  73. data/lib/amp/dependencies/maruku/input/type_detection.rb +147 -0
  74. data/lib/amp/dependencies/maruku/input_textile2/t2_parser.rb +163 -0
  75. data/lib/amp/dependencies/maruku/maruku.rb +33 -0
  76. data/lib/amp/dependencies/maruku/output/to_ansi.rb +223 -0
  77. data/lib/amp/dependencies/maruku/output/to_html.rb +991 -0
  78. data/lib/amp/dependencies/maruku/output/to_markdown.rb +164 -0
  79. data/lib/amp/dependencies/maruku/output/to_s.rb +56 -0
  80. data/lib/amp/dependencies/maruku/string_utils.rb +191 -0
  81. data/lib/amp/dependencies/maruku/structures.rb +167 -0
  82. data/lib/amp/dependencies/maruku/structures_inspect.rb +87 -0
  83. data/lib/amp/dependencies/maruku/structures_iterators.rb +61 -0
  84. data/lib/amp/dependencies/maruku/textile2.rb +1 -0
  85. data/lib/amp/dependencies/maruku/toc.rb +199 -0
  86. data/lib/amp/dependencies/maruku/usage/example1.rb +33 -0
  87. data/lib/amp/dependencies/maruku/version.rb +40 -0
  88. data/lib/amp/dependencies/priority_queue.rb +2 -1
  89. data/lib/amp/dependencies/python_config.rb +2 -1
  90. data/lib/amp/graphs/ancestor.rb +2 -1
  91. data/lib/amp/graphs/copies.rb +236 -233
  92. data/lib/amp/help/entries/__default__.erb +31 -0
  93. data/lib/amp/help/entries/commands.erb +6 -0
  94. data/lib/amp/help/entries/mdtest.md +35 -0
  95. data/lib/amp/help/entries/silly +3 -0
  96. data/lib/amp/help/help.rb +288 -0
  97. data/lib/amp/profiling_hacks.rb +5 -3
  98. data/lib/amp/repository/abstract/abstract_changeset.rb +97 -0
  99. data/lib/amp/repository/abstract/abstract_local_repo.rb +181 -0
  100. data/lib/amp/repository/abstract/abstract_staging_area.rb +180 -0
  101. data/lib/amp/repository/abstract/abstract_versioned_file.rb +100 -0
  102. data/lib/amp/repository/abstract/common_methods/changeset.rb +75 -0
  103. data/lib/amp/repository/abstract/common_methods/local_repo.rb +277 -0
  104. data/lib/amp/repository/abstract/common_methods/staging_area.rb +233 -0
  105. data/lib/amp/repository/abstract/common_methods/versioned_file.rb +71 -0
  106. data/lib/amp/repository/generic_repo_picker.rb +78 -0
  107. data/lib/amp/repository/git/repo_format/changeset.rb +336 -0
  108. data/lib/amp/repository/git/repo_format/staging_area.rb +192 -0
  109. data/lib/amp/repository/git/repo_format/versioned_file.rb +119 -0
  110. data/lib/amp/repository/git/repositories/local_repository.rb +164 -0
  111. data/lib/amp/repository/git/repository.rb +41 -0
  112. data/lib/amp/repository/mercurial/encoding/mercurial_diff.rb +382 -0
  113. data/lib/amp/repository/mercurial/encoding/mercurial_patch.rb +1 -0
  114. data/lib/amp/repository/mercurial/encoding/patch.rb +294 -0
  115. data/lib/amp/repository/mercurial/encoding/pure_ruby/ruby_mercurial_patch.rb +124 -0
  116. data/lib/amp/repository/mercurial/merging/merge_ui.rb +327 -0
  117. data/lib/amp/repository/mercurial/merging/simple_merge.rb +452 -0
  118. data/lib/amp/repository/mercurial/repo_format/branch_manager.rb +266 -0
  119. data/lib/amp/repository/mercurial/repo_format/changeset.rb +768 -0
  120. data/lib/amp/repository/mercurial/repo_format/dir_state.rb +716 -0
  121. data/lib/amp/repository/mercurial/repo_format/journal.rb +218 -0
  122. data/lib/amp/repository/mercurial/repo_format/lock.rb +210 -0
  123. data/lib/amp/repository/mercurial/repo_format/merge_state.rb +228 -0
  124. data/lib/amp/repository/mercurial/repo_format/staging_area.rb +367 -0
  125. data/lib/amp/repository/mercurial/repo_format/store.rb +487 -0
  126. data/lib/amp/repository/mercurial/repo_format/tag_manager.rb +322 -0
  127. data/lib/amp/repository/mercurial/repo_format/updatable.rb +543 -0
  128. data/lib/amp/repository/mercurial/repo_format/updater.rb +848 -0
  129. data/lib/amp/repository/mercurial/repo_format/verification.rb +433 -0
  130. data/lib/amp/repository/mercurial/repositories/bundle_repository.rb +216 -0
  131. data/lib/amp/repository/mercurial/repositories/http_repository.rb +386 -0
  132. data/lib/amp/repository/mercurial/repositories/local_repository.rb +2034 -0
  133. data/lib/amp/repository/mercurial/repository.rb +119 -0
  134. data/lib/amp/repository/mercurial/revlogs/bundle_revlogs.rb +249 -0
  135. data/lib/amp/repository/mercurial/revlogs/changegroup.rb +217 -0
  136. data/lib/amp/repository/mercurial/revlogs/changelog.rb +339 -0
  137. data/lib/amp/repository/mercurial/revlogs/file_log.rb +152 -0
  138. data/lib/amp/repository/mercurial/revlogs/index.rb +500 -0
  139. data/lib/amp/repository/mercurial/revlogs/manifest.rb +201 -0
  140. data/lib/amp/repository/mercurial/revlogs/node.rb +20 -0
  141. data/lib/amp/repository/mercurial/revlogs/revlog.rb +1026 -0
  142. data/lib/amp/repository/mercurial/revlogs/revlog_support.rb +129 -0
  143. data/lib/amp/repository/mercurial/revlogs/versioned_file.rb +597 -0
  144. data/lib/amp/repository/repository.rb +11 -88
  145. data/lib/amp/server/extension/amp_extension.rb +3 -3
  146. data/lib/amp/server/fancy_http_server.rb +1 -1
  147. data/lib/amp/server/fancy_views/_browser.haml +1 -1
  148. data/lib/amp/server/fancy_views/_diff_file.haml +1 -8
  149. data/lib/amp/server/fancy_views/changeset.haml +2 -2
  150. data/lib/amp/server/fancy_views/file.haml +1 -1
  151. data/lib/amp/server/fancy_views/file_diff.haml +1 -1
  152. data/lib/amp/support/amp_ui.rb +13 -29
  153. data/lib/amp/support/generator.rb +1 -1
  154. data/lib/amp/support/loaders.rb +1 -2
  155. data/lib/amp/support/logger.rb +10 -16
  156. data/lib/amp/support/match.rb +18 -4
  157. data/lib/amp/support/mercurial/ignore.rb +151 -0
  158. data/lib/amp/support/openers.rb +8 -3
  159. data/lib/amp/support/support.rb +91 -46
  160. data/lib/amp/templates/{blank.commit.erb → mercurial/blank.commit.erb} +0 -0
  161. data/lib/amp/templates/{blank.log.erb → mercurial/blank.log.erb} +0 -0
  162. data/lib/amp/templates/{default.commit.erb → mercurial/default.commit.erb} +0 -0
  163. data/lib/amp/templates/{default.log.erb → mercurial/default.log.erb} +0 -0
  164. data/lib/amp/templates/template.rb +18 -18
  165. data/man/amp.1 +51 -0
  166. data/site/src/about/commands.haml +1 -1
  167. data/site/src/css/amp.css +1 -1
  168. data/site/src/index.haml +3 -3
  169. data/tasks/man.rake +39 -0
  170. data/tasks/stats.rake +1 -10
  171. data/tasks/yard.rake +1 -50
  172. data/test/dirstate_tests/test_dir_state.rb +10 -8
  173. data/test/functional_tests/annotate.out +31 -0
  174. data/test/functional_tests/test_functional.rb +155 -63
  175. data/test/localrepo_tests/ampfile.rb +12 -0
  176. data/test/localrepo_tests/test_local_repo.rb +56 -57
  177. data/test/manifest_tests/test_manifest.rb +3 -5
  178. data/test/merge_tests/test_merge.rb +3 -3
  179. data/test/revlog_tests/test_revlog.rb +14 -6
  180. data/test/store_tests/test_fncache_store.rb +19 -19
  181. data/test/test_19_compatibility.rb +46 -0
  182. data/test/test_base85.rb +2 -2
  183. data/test/test_bdiff.rb +2 -2
  184. data/test/test_changegroup.rb +59 -0
  185. data/test/test_commands.rb +2 -2
  186. data/test/test_difflib.rb +2 -2
  187. data/test/test_generator.rb +34 -0
  188. data/test/test_ignore.rb +203 -0
  189. data/test/test_journal.rb +18 -13
  190. data/test/test_match.rb +2 -2
  191. data/test/test_mdiff.rb +3 -3
  192. data/test/test_mpatch.rb +3 -3
  193. data/test/test_multi_io.rb +40 -0
  194. data/test/test_support.rb +18 -2
  195. data/test/test_templates.rb +38 -0
  196. data/test/test_ui.rb +79 -0
  197. data/test/testutilities.rb +56 -0
  198. metadata +168 -49
  199. data/ext/amp/bz2/mkmf.log +0 -38
  200. data/lib/amp/encoding/mercurial_diff.rb +0 -378
  201. data/lib/amp/encoding/mercurial_patch.rb +0 -1
  202. data/lib/amp/encoding/patch.rb +0 -292
  203. data/lib/amp/encoding/pure_ruby/ruby_mercurial_patch.rb +0 -123
  204. data/lib/amp/merges/merge_state.rb +0 -164
  205. data/lib/amp/merges/merge_ui.rb +0 -322
  206. data/lib/amp/merges/simple_merge.rb +0 -450
  207. data/lib/amp/repository/branch_manager.rb +0 -234
  208. data/lib/amp/repository/dir_state.rb +0 -950
  209. data/lib/amp/repository/journal.rb +0 -203
  210. data/lib/amp/repository/lock.rb +0 -207
  211. data/lib/amp/repository/repositories/bundle_repository.rb +0 -214
  212. data/lib/amp/repository/repositories/http_repository.rb +0 -377
  213. data/lib/amp/repository/repositories/local_repository.rb +0 -2661
  214. data/lib/amp/repository/store.rb +0 -485
  215. data/lib/amp/repository/tag_manager.rb +0 -319
  216. data/lib/amp/repository/updatable.rb +0 -532
  217. data/lib/amp/repository/verification.rb +0 -431
  218. data/lib/amp/repository/versioned_file.rb +0 -475
  219. data/lib/amp/revlogs/bundle_revlogs.rb +0 -246
  220. data/lib/amp/revlogs/changegroup.rb +0 -217
  221. data/lib/amp/revlogs/changelog.rb +0 -338
  222. data/lib/amp/revlogs/changeset.rb +0 -521
  223. data/lib/amp/revlogs/file_log.rb +0 -165
  224. data/lib/amp/revlogs/index.rb +0 -493
  225. data/lib/amp/revlogs/manifest.rb +0 -195
  226. data/lib/amp/revlogs/node.rb +0 -18
  227. data/lib/amp/revlogs/revlog.rb +0 -1045
  228. data/lib/amp/revlogs/revlog_support.rb +0 -126
  229. data/lib/amp/support/ignore.rb +0 -144
  230. data/site/Rakefile +0 -38
  231. data/test/test_amp.rb +0 -9
  232. data/test/test_helper.rb +0 -15
@@ -1,126 +0,0 @@
1
- autoload :Zlib, 'zlib'
2
- module Amp
3
- module RevlogSupport
4
-
5
- class RevlogError < StandardError; end
6
- class LookupError < StandardError; end
7
-
8
- module Support
9
- extend self
10
-
11
- # Old version of the revlog file format
12
- REVLOG_VERSION_0 = 0
13
- # Current version of the revlog file format
14
- REVLOG_VERSION_NG = 1
15
- # A flag marking that the data is stored with the index
16
- REVLOG_NG_INLINE_DATA = (1 << 16)
17
- # Default flags - always start inline (turn off inline if file is huge)
18
- REVLOG_DEFAULT_FLAGS = REVLOG_NG_INLINE_DATA
19
- # Default format - the most recent
20
- REVLOG_DEFAULT_FORMAT = REVLOG_VERSION_NG
21
- # Default version in general
22
- REVLOG_DEFAULT_VERSION = REVLOG_DEFAULT_FORMAT | REVLOG_DEFAULT_FLAGS
23
-
24
- ##
25
- # This bears some explanation.
26
- #
27
- # Rather than simply having a 4-byte header for the index file format, the
28
- # Mercurial format takes the first entry in the index, and stores the header
29
- # in its offset field. (The offset field is a 64-bit unsigned integer which
30
- # stores the offset into the data or index of the associated record's data)
31
- # They take advantage of the fact that the first entry's offset will always
32
- # be 0. As such, its offset field is always going to be zero, so it's safe
33
- # to store data there.
34
- #
35
- # The format is ((flags << 16) | (version)), where +flags+ is a bitmask (up to 48
36
- # bits) and +version+ is a 16-bit unsigned short.
37
- #
38
- # The worst part is, EVERY SINGLE ENTRY has its offset shifted 16 bits to the left,
39
- # apparently all because of this. It fucking baffles my mind.
40
- #
41
- # So yeah. offset = value >> 16.
42
- def get_offset(o); o >> 16; end
43
- # And yeah. version = value && 0xFFFF (last 16 bits)
44
- def get_version(t); t & 0xFFFF; end
45
-
46
- # Combine an offset and a version to spit this baby out
47
- def offset_version(offset,type)
48
- (offset << 16) | type
49
- end
50
-
51
- ##
52
- # generate a hash from the given text and its parent hashes
53
- #
54
- # This hash combines both the current file contents and its history
55
- # in a manner that makes it easy to distinguish nodes with the same
56
- # content in the revision graph.
57
- #
58
- # since an entry in a revlog is pretty
59
- # much [parent1, parent2, text], we use a hash of the previous entry
60
- # as a reference to that previous entry. To create a reference to this
61
- # entry, we make a hash of the first parent (which is just its ID), the
62
- # second parent, and the text.
63
- #
64
- # @return [String] the digest of the two parents and the extra text
65
- def history_hash(text, p1, p2)
66
- list = [p1, p2].sort
67
- s = list[0].sha1
68
- s.update list[1]
69
- s.update text
70
- s.digest
71
- end
72
-
73
- ##
74
- # returns the possibly-compressed version of the text, in a hash:
75
- #
76
- # @return [Hash] :compression => 'u' or ''
77
- def compress(text)
78
- return {:compression => "", :text => text} if text.empty?
79
- size = text.size
80
- binary = nil
81
- if size < 44
82
- elsif size > 1000000 #big ole file
83
- deflater = Zlib::Deflate.new
84
- parts = []
85
- position = 0
86
- while position < size
87
- newposition = position + 2**20
88
- parts << deflater.deflate(text[position..(newposition-1)], Zlib::NO_FLUSH)
89
- position = newposition
90
- end
91
- parts << deflater.flush
92
- binary = parts.join if parts.map {|e| e.size}.sum < size # only add it if
93
- # compression made it smaller
94
- else #tiny, just compress it
95
- binary = Zlib::Deflate.deflate text
96
- end
97
-
98
- if binary.nil? || binary.size > size
99
- return {:compression => "", :text => text} if text[0,1] == "\0"
100
- return {:compression => 'u', :text => text}
101
- end
102
- {:compression => "", :text => binary}
103
- end
104
-
105
- ##
106
- # Decompresses the given binary text. The binary text could be
107
- # uncompressed, in which case, we'll figure that out. Don't worry.
108
- #
109
- # @param [String] binary the text to (possibly) decompress
110
- # @return [String] the text decompressed
111
- def decompress(binary)
112
- return binary if binary.empty?
113
- case binary[0,1]
114
- when "\0"
115
- binary #we're just stored as binary
116
- when "x"
117
- Zlib::Inflate.inflate(binary) #we're zlibbed
118
- when "u"
119
- binary[1..-1] #we're uncompressed text
120
- else
121
- raise LookupError.new("Unknown compression type #{binary[0,1]}")
122
- end
123
- end
124
- end
125
- end
126
- end
@@ -1,144 +0,0 @@
1
- module Amp
2
- module Ignore
3
- extend self
4
-
5
- COMMENT = /((^|[^\\])(\\\\)*)#.*/
6
- SYNTAXES = {'re' => :regexp, 'regexp' => :regexp, 'glob' => :glob,
7
- 'relglob' => :relglob, 'relre' => :regexp, 'path' => :glob,
8
- 'relpath' => :relglob}
9
- ##
10
- # Parses the ignore file, +file+ (or ".hgignore")
11
- #
12
- # @param [String] root the root of the repo
13
- # @param [Array<String>] files absolute paths to files
14
- def parse_ignore(root, files=[])
15
- patterns = {} # not sure what this is
16
-
17
- files.each do |file|
18
- syntax = 're' # default syntax
19
- text = File.read File.join(root,file) rescue next
20
- pattern = matcher_for_text text
21
- patterns[file] = pattern if pattern
22
- end # files.each
23
-
24
- all_patterns = patterns.values.flatten
25
- # let the system know that nothing is ignored
26
- return proc { false } if all_patterns.empty?
27
- # here's the proc to do the tests
28
- regexps_to_proc all_patterns
29
- end
30
-
31
- ##
32
- # Parse the lines into valid syntax
33
- #
34
- # @param [String] file and open file
35
- def parse_lines(text)
36
- lines = text.split("\n").map do |line|
37
- if line =~ /#/
38
- line.sub! COMMENT, "\\1"
39
- line.gsub! "\\#", "#"
40
- end
41
-
42
- line.rstrip!
43
- line.empty? ? nil : line
44
- end
45
- lines.compact
46
- end
47
-
48
- ##
49
- # Produces an array of regexps which can be used
50
- # for matching files
51
- #
52
- # @param [String] text the text to parse
53
- # @return [[Regexp]] the regexps generated from the strings and syntaxes
54
- def matcher_for_text(text)
55
- return [] unless text
56
- syntax = nil
57
- patterns = parse_lines(text).map do |line|
58
- next if line.empty?
59
- # check for syntax changes
60
- if line =~ /^syntax:/
61
- syntax = SYNTAXES[line[7..-1].strip] || :regexp
62
- next # move on
63
- end
64
- parse_line syntax, line # could be nil, so we need to compact it
65
- end # parsed_lines(text)
66
- patterns.compact # kill the nils
67
- end
68
-
69
- ##
70
- # Much like matcher_for_text, except tailored to single line strings
71
- #
72
- # @see matcher_for_text
73
- # @param [String] string the string to parse
74
- # @return [Regexp] the regexps generated from the strings and syntaxes
75
- def matcher_for_string(string)
76
- scanpt = string =~ /(\w+):(.+)/
77
- if scanpt.nil?
78
- # just a line, no specified syntax
79
- syntax = 'regexp'
80
- # no syntax, the whole thing is a pattern
81
- include_regexp = string
82
- else
83
- syntax = $1 # the syntax is the first match
84
- include_regexp = $2.strip # the rest of the string is the pattern
85
- end
86
- include_syntax = syntax.to_sym
87
- parse_line include_syntax, include_regexp
88
- end
89
-
90
- ##
91
- # Turns a single line, given a syntax, into either
92
- # a valid regexp or nil. If it is nil, it means the
93
- # syntax was incorrect.
94
- #
95
- # @param [Symbol] syntax the syntax to parse with (:regexp, :glob, :relglob)
96
- # @param [String] line the line to parse
97
- # @return [NilClass, Regexp] nil means the syntax was a bad choice
98
- def parse_line(syntax, line)
99
- return nil unless syntax
100
-
101
- # find more valid syntax stuff
102
- # we need to make everything here valid regexps
103
- case syntax.to_sym
104
- when :regexp
105
- # basic regex
106
- pattern = /#{line}/
107
- when :glob, :relglob
108
- # glob: glob (shell style), relative to the root of the repository
109
- # relglob: glob, except we just match somewhere in the string, not from the root of
110
- # the repository
111
- ps = line.split '/**/'
112
- ps.map! do |l|
113
- parts = l.split '*' # split it up and we'll escape all the parts
114
- parts.map! {|p| Regexp.escape p }
115
- /#{parts.join '[^/]*'}/ # anything but a slash, ie, no change in directories
116
- end
117
- joined = ps.join '/(?:.*/)*'
118
- pattern = (syntax.to_sym == :glob) ? /^#{joined}/ : /#{joined}/
119
- else
120
- pattern = nil
121
- end
122
-
123
- pattern
124
- end
125
-
126
- ##
127
- # Converts all the ignored regexps into a proc that matches against all of these
128
- # regexps. That way we can pass around a single proc that checks if a file is ignored.
129
- #
130
- # @param [Array<Regexp>] regexps all of the regexes that we need to match against
131
- # @return [Proc] a proc that, when called with a file's path, will return whether
132
- # it matches any of the regexps.
133
- def regexps_to_proc(*regexps)
134
- regexps = regexps.flatten.compact # needed because of possible nils
135
- if regexps.empty?
136
- proc { false }
137
- else
138
- proc { |file| regexps.any? {|p| file =~ p } }
139
- end
140
- end
141
- alias_method :regexp_to_proc, :regexps_to_proc
142
-
143
- end
144
- end
@@ -1,38 +0,0 @@
1
- # -*- ruby -*-
2
-
3
- require 'rubygems'
4
- require 'rake'
5
- require 'rake/tasklib'
6
-
7
- require 'src/helpers.rb'
8
- require 'ftools'
9
-
10
- desc "Compile Site"
11
- task :"build-website" do
12
- missing_gems = []
13
- requirements = ['haml', 'uv']
14
- requirements.each do |requirement|
15
- begin
16
- require requirement
17
- rescue LoadError => e
18
- puts "The following gems are required to build the amp website: #{requirements.join(", ")}"
19
- puts "Install them as follows: gem install #{requirements.join(" ")}"
20
- exit
21
- end
22
- end
23
- Dir["src/**/*.haml"].reject {|item| item.split("/").last =~ /^_/}.each do |haml|
24
- FileUtils.makedirs(File.dirname("build" + haml[3..-6] + ".html"))
25
- File.open("build" + haml[3..-6] + ".html","w") do |out|
26
- puts "Building #{haml[3..-6]}"
27
- out.write render(haml)
28
- end
29
- end
30
- %w(css images scripts docs).each do |dir|
31
- if File.exist? "src/#{dir}/"
32
- sh "cp -r src/#{dir}/ build/#{dir}/"
33
- end
34
- end
35
- end
36
-
37
- task :default => :"build-website" do
38
- end
@@ -1,9 +0,0 @@
1
- require "test/unit"
2
- require File.expand_path(File.join(File.dirname(__FILE__), "../lib/amp"))
3
-
4
- class TestAmp < Test::Unit::TestCase
5
-
6
- def test_truth
7
- assert true
8
- end
9
- end
@@ -1,15 +0,0 @@
1
- require 'test/unit'
2
-
3
- def assert_false(val)
4
- assert_equal(false, !!val)
5
- end
6
-
7
- def assert_not_nil(val)
8
- assert_not_equal(nil, val)
9
- end
10
-
11
- def assert_file_contents(file, contents)
12
- File.open(file,"r") do |f|
13
- assert_equal f.read, contents
14
- end
15
- end