agio 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,52 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe Agio::HTMLElementDescription do
6
+ context "HTML block elements like 'p'" do
7
+ subject { Agio::HTMLElementDescription['p'] }
8
+
9
+ its(:name) { should == 'p' }
10
+ its(:to_s) { should =~ /p:\s+paragraph/ }
11
+ its(:inspect) { should =~ %r{#<.*ElementDescription:\s+p\s+paragraph\s*>} }
12
+ its(:block?) { should == true }
13
+ its(:inline?) { should == false }
14
+ its(:sub_elements) { should include('em', 'small') }
15
+ its(:sub_elements) { should_not include('p') }
16
+ its(:empty?) { should == false }
17
+ its(:implied_start_tag?) { should == false }
18
+ its(:implied_end_tag?) { should == true }
19
+ its(:save_end_tag?) { should == false }
20
+ its(:deprecated?) { should == false }
21
+ its(:description) { should =~ /paragraph/ }
22
+ its(:default_sub_element) { should be_nil }
23
+ its(:optional_attributes) { should include("id", "class", "style") }
24
+ its(:deprecated_attributes) { should include("align") }
25
+ its(:required_attributes) { should be_empty }
26
+ end
27
+
28
+ context "HTML inline elements like 'em'" do
29
+ subject { Agio::HTMLElementDescription['em'] }
30
+
31
+ its(:name) { should == 'em' }
32
+ its(:to_s) { should =~ /em:\s+emphasis/ }
33
+ its(:inspect) { should =~ %r{#<.*ElementDescription:\s+em\s+emphasis\s*>} }
34
+ its(:block?) { should == false }
35
+ its(:inline?) { should == true }
36
+ its(:sub_elements) { should include('em', 'small') }
37
+ its(:sub_elements) { should_not include('p') }
38
+ its(:empty?) { should == false }
39
+ its(:implied_start_tag?) { should == false }
40
+ its(:implied_end_tag?) { should == true }
41
+ its(:save_end_tag?) { should == false }
42
+ its(:deprecated?) { should == false }
43
+ its(:description) { should =~ /emphasis/ }
44
+ its(:default_sub_element) { should be_nil }
45
+ its(:optional_attributes) { should include("id", "class", "style") }
46
+ its(:deprecated_attributes) { should be_empty }
47
+ its(:required_attributes) { should be_empty }
48
+ end
49
+ end
50
+
51
+ # vim: ft=ruby
52
+
@@ -0,0 +1,31 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'spec_helper'
4
+
5
+ describe PrivateMethodHandler do
6
+ subject do
7
+ klass = Class.new
8
+ klass.class_eval {
9
+ def foo; end
10
+ private :foo
11
+ }
12
+ klass
13
+ end
14
+
15
+ it "should remove private methods properly" do
16
+ subject.private_instance_methods(false).should == [ "foo" ]
17
+ PrivateMethodHandler.remove(subject)
18
+ subject.private_instance_methods(false).should == [ ]
19
+ end
20
+
21
+ it "should restore private methods when finished" do
22
+ subject.private_instance_methods(false).should == [ "foo" ]
23
+ PrivateMethodHandler.remove(subject)
24
+ subject.private_instance_methods(false).should == [ ]
25
+ PrivateMethodHandler.restore(subject)
26
+ subject.private_instance_methods(false).should == [ "foo" ]
27
+ end
28
+ end
29
+
30
+ # vim: ft=ruby
31
+
@@ -0,0 +1,308 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+
3
+ require 'rubygems'
4
+ require 'rspec'
5
+
6
+ $:.unshift File.expand_path('../../lib', __FILE__)
7
+
8
+ require 'agio'
9
+
10
+ class PrivateMethodHandler
11
+ def initialize(klass)
12
+ @methods = []
13
+ end
14
+
15
+ class << self
16
+ def classes
17
+ unless @classes
18
+ @classes = Hash.new { |h, k| h[k] = [] }
19
+ end
20
+ @classes
21
+ end
22
+
23
+ def remove(klass)
24
+ classes[klass] += klass.private_instance_methods(false)
25
+ classes[klass].each { |m|
26
+ klass.class_eval { public m }
27
+ }
28
+ end
29
+
30
+ def restore(klass)
31
+ classes[klass].each { |m|
32
+ klass.class_eval { private m }
33
+ }
34
+ end
35
+ end
36
+ end
37
+
38
+ # module Diff::LCS::SpecHelper
39
+ # def seq1
40
+ # %w(a b c e h j l m n p)
41
+ # end
42
+
43
+ # def skipped_seq1
44
+ # %w(a h n p)
45
+ # end
46
+
47
+ # def seq2
48
+ # %w(b c d e f j k l m r s t)
49
+ # end
50
+
51
+ # def skipped_seq2
52
+ # %w(d f k r s t)
53
+ # end
54
+
55
+ # def word_sequence
56
+ # %w(abcd efgh ijkl mnopqrstuvwxyz)
57
+ # end
58
+
59
+ # def correct_lcs
60
+ # %w(b c e j l m)
61
+ # end
62
+
63
+ # def correct_forward_diff
64
+ # [
65
+ # [ [ '-', 0, 'a' ] ],
66
+ # [ [ '+', 2, 'd' ] ],
67
+ # [ [ '-', 4, 'h' ],
68
+ # [ '+', 4, 'f' ] ],
69
+ # [ [ '+', 6, 'k' ] ],
70
+ # [ [ '-', 8, 'n' ],
71
+ # [ '-', 9, 'p' ],
72
+ # [ '+', 9, 'r' ],
73
+ # [ '+', 10, 's' ],
74
+ # [ '+', 11, 't' ] ]
75
+ # ]
76
+ # end
77
+
78
+ # def correct_backward_diff
79
+ # [
80
+ # [ [ '+', 0, 'a' ] ],
81
+ # [ [ '-', 2, 'd' ] ],
82
+ # [ [ '-', 4, 'f' ],
83
+ # [ '+', 4, 'h' ] ],
84
+ # [ [ '-', 6, 'k' ] ],
85
+ # [
86
+ # [ '-', 9, 'r' ],
87
+ # [ '-', 10, 's' ],
88
+ # [ '+', 8, 'n' ],
89
+ # [ '-', 11, 't' ],
90
+ # [ '+', 9, 'p' ] ]
91
+ # ]
92
+ # end
93
+
94
+ # def correct_forward_sdiff
95
+ # [
96
+ # [ '-', [ 0, 'a' ], [ 0, nil ] ],
97
+ # [ '=', [ 1, 'b' ], [ 0, 'b' ] ],
98
+ # [ '=', [ 2, 'c' ], [ 1, 'c' ] ],
99
+ # [ '+', [ 3, nil ], [ 2, 'd' ] ],
100
+ # [ '=', [ 3, 'e' ], [ 3, 'e' ] ],
101
+ # [ '!', [ 4, 'h' ], [ 4, 'f' ] ],
102
+ # [ '=', [ 5, 'j' ], [ 5, 'j' ] ],
103
+ # [ '+', [ 6, nil ], [ 6, 'k' ] ],
104
+ # [ '=', [ 6, 'l' ], [ 7, 'l' ] ],
105
+ # [ '=', [ 7, 'm' ], [ 8, 'm' ] ],
106
+ # [ '!', [ 8, 'n' ], [ 9, 'r' ] ],
107
+ # [ '!', [ 9, 'p' ], [ 10, 's' ] ],
108
+ # [ '+', [ 10, nil ], [ 11, 't' ] ]
109
+ # ]
110
+ # end
111
+
112
+ # def reverse_sdiff(forward_sdiff)
113
+ # forward_sdiff.map { |line|
114
+ # line[1], line[2] = line[2], line[1]
115
+ # case line[0]
116
+ # when '-' then line[0] = '+'
117
+ # when '+' then line[0] = '-'
118
+ # end
119
+ # line
120
+ # }
121
+ # end
122
+
123
+ # def change_diff(diff)
124
+ # map_diffs(diff, Diff::LCS::Change)
125
+ # end
126
+
127
+ # def context_diff(diff)
128
+ # map_diffs(diff, Diff::LCS::ContextChange)
129
+ # end
130
+
131
+ # def format_diffs(diffs)
132
+ # diffs.map do |e|
133
+ # if e.kind_of?(Array)
134
+ # e.map { |f| f.to_a.join }.join(", ")
135
+ # else
136
+ # e.to_a.join
137
+ # end
138
+ # end.join("\n")
139
+ # end
140
+
141
+ # def map_diffs(diffs, klass = Diff::LCS::ContextChange)
142
+ # diffs.map do |chunks|
143
+ # if klass == Diff::LCS::ContextChange
144
+ # klass.from_a(chunks)
145
+ # else
146
+ # chunks.map { |changes| klass.from_a(changes) }
147
+ # end
148
+ # end
149
+ # end
150
+
151
+ # def balanced_traversal(s1, s2, callback_type)
152
+ # callback = __send__(callback_type)
153
+ # Diff::LCS.traverse_balanced(s1, s2, callback)
154
+ # callback
155
+ # end
156
+
157
+ # def balanced_reverse(change_result)
158
+ # new_result = []
159
+ # change_result.each { |line|
160
+ # line = [ line[0], line[2], line[1] ]
161
+ # case line[0]
162
+ # when '<'
163
+ # line[0] = '>'
164
+ # when '>'
165
+ # line[0] = '<'
166
+ # end
167
+ # new_result << line
168
+ # }
169
+ # new_result.sort_by { |line| [ line[1], line[2] ] }
170
+ # end
171
+
172
+ # def map_to_no_change(change_result)
173
+ # new_result = []
174
+ # change_result.each { |line|
175
+ # case line[0]
176
+ # when '!'
177
+ # new_result << [ '<', line[1], line[2] ]
178
+ # new_result << [ '>', line[1] + 1, line[2] ]
179
+ # else
180
+ # new_result << line
181
+ # end
182
+ # }
183
+ # new_result
184
+ # end
185
+
186
+
187
+ # def simple_callback
188
+ # callbacks = Object.new
189
+ # class << callbacks
190
+ # attr_reader :matched_a
191
+ # attr_reader :matched_b
192
+ # attr_reader :discards_a
193
+ # attr_reader :discards_b
194
+ # attr_reader :done_a
195
+ # attr_reader :done_b
196
+
197
+ # def reset
198
+ # @matched_a = []
199
+ # @matched_b = []
200
+ # @discards_a = []
201
+ # @discards_b = []
202
+ # @done_a = []
203
+ # @done_b = []
204
+ # end
205
+
206
+ # def match(event)
207
+ # @matched_a << event.old_element
208
+ # @matched_b << event.new_element
209
+ # end
210
+
211
+ # def discard_b(event)
212
+ # @discards_b << event.new_element
213
+ # end
214
+
215
+ # def discard_a(event)
216
+ # @discards_a << event.old_element
217
+ # end
218
+
219
+ # def finished_a(event)
220
+ # @done_a << [event.old_element, event.old_position,
221
+ # event.new_element, event.new_position]
222
+ # end
223
+
224
+ # def finished_b(event)
225
+ # p "called #finished_b"
226
+ # @done_b << [event.old_element, event.old_position,
227
+ # event.new_element, event.new_position]
228
+ # end
229
+ # end
230
+ # callbacks.reset
231
+ # callbacks
232
+ # end
233
+
234
+ # def simple_callback_no_finishers
235
+ # simple = simple_callback
236
+ # class << simple
237
+ # undef :finished_a
238
+ # undef :finished_b
239
+ # end
240
+ # simple
241
+ # end
242
+
243
+ # def balanced_callback
244
+ # cb = Object.new
245
+ # class << cb
246
+ # attr_reader :result
247
+
248
+ # def reset
249
+ # @result = []
250
+ # end
251
+
252
+ # def match(event)
253
+ # @result << [ "=", event.old_position, event.new_position ]
254
+ # end
255
+
256
+ # def discard_a(event)
257
+ # @result << [ "<", event.old_position, event.new_position ]
258
+ # end
259
+
260
+ # def discard_b(event)
261
+ # @result << [ ">", event.old_position, event.new_position ]
262
+ # end
263
+
264
+ # def change(event)
265
+ # @result << [ "!", event.old_position, event.new_position ]
266
+ # end
267
+ # end
268
+ # cb.reset
269
+ # cb
270
+ # end
271
+
272
+ # def balanced_callback_no_change
273
+ # balanced = balanced_callback
274
+ # class << balanced
275
+ # undef :change
276
+ # end
277
+ # balanced
278
+ # end
279
+
280
+ # module Matchers
281
+ # extend RSpec::Matchers::DSL
282
+
283
+ # matcher :be_nil_or_match_values do |ii, s1, s2|
284
+ # match do |ee|
285
+ # ee.should satisfy { |vee| vee.nil? || s1[ii] == s2[ee] }
286
+ # end
287
+ # end
288
+
289
+ # matcher :correctly_map_sequence do |s1|
290
+ # match do |actual|
291
+ # actual.each_with_index { |ee, ii|
292
+ # ee.should be_nil_or_match_values(ii, s1, @s2)
293
+ # }
294
+ # end
295
+
296
+ # chain :to_other_sequence do |s2|
297
+ # @s2 = s2
298
+ # end
299
+ # end
300
+ # end
301
+ # end
302
+
303
+ # RSpec.configure do |conf|
304
+ # conf.include Diff::LCS::SpecHelper
305
+ # conf.alias_it_should_behave_like_to :it_has_behavior, 'has behavior:'
306
+ # end
307
+
308
+ # vim: ft=ruby
metadata ADDED
@@ -0,0 +1,216 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: agio
3
+ version: !ruby/object:Gem::Version
4
+ hash: 11
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 5
9
+ - 0
10
+ version: 0.5.0
11
+ platform: ruby
12
+ authors:
13
+ - Austin Ziegler
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-20 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: nokogiri
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 1
31
+ - 5
32
+ - 0
33
+ version: 1.5.0
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: main
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 37
45
+ segments:
46
+ - 4
47
+ - 7
48
+ - 3
49
+ version: 4.7.3
50
+ type: :runtime
51
+ version_requirements: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ name: rspec
54
+ prerelease: false
55
+ requirement: &id003 !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ~>
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 2
63
+ - 0
64
+ version: "2.0"
65
+ type: :development
66
+ version_requirements: *id003
67
+ - !ruby/object:Gem::Dependency
68
+ name: hoe-doofus
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ hash: 15
76
+ segments:
77
+ - 1
78
+ - 0
79
+ version: "1.0"
80
+ type: :development
81
+ version_requirements: *id004
82
+ - !ruby/object:Gem::Dependency
83
+ name: hoe-gemspec
84
+ prerelease: false
85
+ requirement: &id005 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ hash: 15
91
+ segments:
92
+ - 1
93
+ - 0
94
+ version: "1.0"
95
+ type: :development
96
+ version_requirements: *id005
97
+ - !ruby/object:Gem::Dependency
98
+ name: hoe-git
99
+ prerelease: false
100
+ requirement: &id006 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ hash: 15
106
+ segments:
107
+ - 1
108
+ - 0
109
+ version: "1.0"
110
+ type: :development
111
+ version_requirements: *id006
112
+ - !ruby/object:Gem::Dependency
113
+ name: hoe-seattlerb
114
+ prerelease: false
115
+ requirement: &id007 !ruby/object:Gem::Requirement
116
+ none: false
117
+ requirements:
118
+ - - ~>
119
+ - !ruby/object:Gem::Version
120
+ hash: 15
121
+ segments:
122
+ - 1
123
+ - 0
124
+ version: "1.0"
125
+ type: :development
126
+ version_requirements: *id007
127
+ - !ruby/object:Gem::Dependency
128
+ name: hoe
129
+ prerelease: false
130
+ requirement: &id008 !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ~>
134
+ - !ruby/object:Gem::Version
135
+ hash: 27
136
+ segments:
137
+ - 2
138
+ - 12
139
+ version: "2.12"
140
+ type: :development
141
+ version_requirements: *id008
142
+ description: |-
143
+ Agio is a library and a tool for converting HTML to
144
+ {Markdown}[http://daringfireball.net/projects/markdown/].
145
+ email:
146
+ - austin@rubyforge.org
147
+ executables:
148
+ - agio
149
+ extensions: []
150
+
151
+ extra_rdoc_files:
152
+ - Manifest.txt
153
+ - History.rdoc
154
+ - License.rdoc
155
+ - README.rdoc
156
+ files:
157
+ - .rspec
158
+ - History.rdoc
159
+ - License.rdoc
160
+ - Manifest.txt
161
+ - README.rdoc
162
+ - Rakefile
163
+ - agio.gemspec
164
+ - bin/agio
165
+ - lib/agio.rb
166
+ - lib/agio/block.rb
167
+ - lib/agio/bourse.rb
168
+ - lib/agio/broker.rb
169
+ - lib/agio/data.rb
170
+ - lib/agio/flags.rb
171
+ - lib/agio/html_element_description.rb
172
+ - spec/block_spec.rb
173
+ - spec/bourse_spec.rb
174
+ - spec/broker_spec.rb
175
+ - spec/data_spec.rb
176
+ - spec/flags_spec.rb
177
+ - spec/html_element_description_spec.rb
178
+ - spec/pmh_spec.rb
179
+ - spec/spec_helper.rb
180
+ - .gemtest
181
+ homepage:
182
+ licenses: []
183
+
184
+ post_install_message:
185
+ rdoc_options:
186
+ - --main
187
+ - README.rdoc
188
+ require_paths:
189
+ - lib
190
+ required_ruby_version: !ruby/object:Gem::Requirement
191
+ none: false
192
+ requirements:
193
+ - - ">="
194
+ - !ruby/object:Gem::Version
195
+ hash: 3
196
+ segments:
197
+ - 0
198
+ version: "0"
199
+ required_rubygems_version: !ruby/object:Gem::Requirement
200
+ none: false
201
+ requirements:
202
+ - - ">="
203
+ - !ruby/object:Gem::Version
204
+ hash: 3
205
+ segments:
206
+ - 0
207
+ version: "0"
208
+ requirements: []
209
+
210
+ rubyforge_project: agio
211
+ rubygems_version: 1.8.10
212
+ signing_key:
213
+ specification_version: 3
214
+ summary: Agio is a library and a tool for converting HTML to {Markdown}[http://daringfireball.net/projects/markdown/].
215
+ test_files: []
216
+