qed 2.4.0 → 2.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.
data/lib/qed/session.rb CHANGED
@@ -1,11 +1,8 @@
1
1
  module QED
2
2
 
3
3
  #require 'qed/config'
4
- require 'qed/applique'
5
4
  require 'qed/demo'
6
5
 
7
- # = Runtime Session
8
- #
9
6
  # The Session class encapsulates a set of demonstrations
10
7
  # and the procedure for looping through them and running
11
8
  # each in turn.
@@ -33,17 +30,6 @@ module QED
33
30
  @mode = options[:mode]
34
31
  @trace = options[:trace] || false
35
32
  @format = options[:format] || :dotprogress
36
-
37
- #options.each do |k,v|
38
- # __send__("#{k}=", v) if v
39
- #end
40
-
41
- @applique = create_applique
42
- end
43
-
44
- #
45
- def applique
46
- @applique
47
33
  end
48
34
 
49
35
  # Top-level configuration.
@@ -66,14 +52,9 @@ module QED
66
52
  )
67
53
  end
68
54
 
69
- #
70
- #def scope
71
- # @scope ||= Scope.new
72
- #end
73
-
74
- # TODO: switch order of applique and file.
55
+ # Returns an Array of Demo instances.
75
56
  def demos
76
- @demos ||= files.map{ |file| Demo.new(file, applique, :mode=>mode) }
57
+ @demos ||= files.map{ |file| Demo.new(file, :mode=>mode) }
77
58
  end
78
59
 
79
60
  #
@@ -85,13 +66,11 @@ module QED
85
66
  def run
86
67
  #profile.before_session(self)
87
68
  reporter.before_session(self)
88
- #demos.each do |demo|
89
- # script = Demo.new(demo, report)
90
69
  demos.each do |demo|
91
70
  demo.run(*observers)
92
- #pid = fork { script.run(*observers) }
71
+ #pid = fork { demo.run(*observers) }
93
72
  #Process.detach(pid)
94
- end
73
+ end
95
74
  reporter.after_session(self)
96
75
  #profile.after_session(self)
97
76
  end
@@ -103,43 +82,6 @@ module QED
103
82
  # end
104
83
  #end
105
84
 
106
- # TODO: associate scripts to there applique ?
107
- def create_applique
108
- applique = Applique.new
109
- #eval "include QED::DomainLanguage", TOPLEVEL_BINDING
110
- applique_scripts.each do |file|
111
- #next if @loadlist.include?(file)
112
- #case File.extname(file)
113
- #when '.rb'
114
- # since scope is just TOPLEVEL now
115
- #require(file)
116
- applique.module_eval(File.read(file), file)
117
- #eval(File.read(file), scope.__binding__, file) # TODO: for each script!? Nay.
118
- #else
119
- # Script.new(file, scope).run
120
- #end
121
- #@loadlist << file
122
- end
123
- applique
124
- end
125
-
126
- # SCM: reverse order of applique so topmost directory comes first
127
- def applique_scripts
128
- locs = []
129
- files.each do |file|
130
- Dir.ascend(File.dirname(file)) do |path|
131
- break if path == Dir.pwd
132
- dir = File.join(path, 'applique')
133
- if File.directory?(dir)
134
- locs << dir
135
- end
136
- end
137
- end
138
- envs = locs.reverse.map{ |loc| Dir[File.join(loc,'**/*.rb')] }
139
- envs.flatten.compact.uniq
140
- end
141
-
142
85
  end#class Session
143
86
 
144
87
  end#module QED
145
-
@@ -1,7 +1,6 @@
1
1
  require 'erb'
2
2
  require 'fileutils'
3
- require 'tilt'
4
- require 'nokogiri'
3
+ #require 'nokogiri'
5
4
 
6
5
  module QED
7
6
 
@@ -46,8 +45,10 @@ module QED
46
45
  # Demo files.
47
46
  def demo_files
48
47
  @demo_files ||= (
49
- glob = paths.map{ |f| File.directory?(f) ? Dir["#{f}/**/*"] : Dir[f] }.flatten
50
- glob = glob.select do |f|
48
+ glob = paths.map do |f|
49
+ File.directory?(f) ? Dir[File.join(f,'**/*')] : Dir[f]
50
+ end
51
+ glob = glob.flatten.select do |f|
51
52
  File.file?(f) && f !~ /fixtures\/|helpers\// && f !~ /\.rb$/
52
53
  end
53
54
  glob.sort
@@ -81,18 +82,18 @@ module QED
81
82
  #iotext = strio.string
82
83
  #strio.close
83
84
 
84
- #ext = File.extname(file)
85
- #txt = File.read(file)
85
+ ext = File.extname(file)
86
+ txt = File.read(file)
86
87
 
87
- #if ext == '.qed'
88
- # ext = file_type(txt)
89
- #end
88
+ if ext == '.qed'
89
+ ext = file_type(txt)
90
+ end
90
91
 
91
- text = Tilt.new(file).render
92
- html = Nokogiri::HTML(text)
93
- body = html.css("body")
92
+ #text = Tilt.new(file).render
93
+ #html = Nokogiri::HTML(text)
94
+ #body = html.css("body")
94
95
 
95
- =begin
96
+ text = ""
96
97
  case ext
97
98
  #when '.qed'
98
99
  # require_qedoc
@@ -100,17 +101,17 @@ module QED
100
101
  # text << markup.to_html
101
102
  when '.rd', '.rdoc'
102
103
  require_rdoc
103
- markup = RDoc::Markup::ToHtml.new
104
- text << markup.convert(txt)
104
+ require_qedoc
105
+ markup = Markup.new(txt)
106
+ text << markup.to_html
105
107
  #text << markup.convert(iotext, formatter)
106
108
  when '.md', '.markdown'
107
109
  require_rdiscount
108
110
  markdown = RDiscount.new(txt)
109
111
  text << markdown.to_html
110
112
  end
111
- =end
112
113
 
113
- output << "#{body}\n"
114
+ output << "#{text}\n"
114
115
  end
115
116
 
116
117
  temp = Template.new(template, output, title, css)
@@ -155,24 +156,24 @@ module QED
155
156
  private
156
157
 
157
158
  #
158
- #def file_type(text)
159
- # rdoc = text.index(/^\=/)
160
- # markdown = text.index(/^\#/)
161
- # if markdown && rdoc
162
- # rdoc < markdown ? '.rdoc' : '.markdown'
163
- # elsif rdoc
164
- # '.rdoc'
165
- # elsif markdown
166
- # '.markdown'
167
- # else # fallback to rdoc
168
- # '.rdoc'
169
- # end
170
- #end
159
+ def file_type(text)
160
+ rdoc = text.index(/^\=/)
161
+ markdown = text.index(/^\#/)
162
+ if markdown && rdoc
163
+ rdoc < markdown ? '.rdoc' : '.markdown'
164
+ elsif rdoc
165
+ '.rdoc'
166
+ elsif markdown
167
+ '.markdown'
168
+ else # fallback to rdoc
169
+ '.rdoc'
170
+ end
171
+ end
171
172
 
172
173
  #
173
174
  def require_qedoc
174
- @require_rdoc ||= (
175
- require 'qed/document/markup'
175
+ @require_qedoc ||= (
176
+ require 'qedoc/document/markup'
176
177
  true
177
178
  )
178
179
  end
@@ -1,53 +1,58 @@
1
- require 'rdoc/markup/simple_markup'
2
- require 'rdoc/markup/simple_markup/to_html'
1
+ require 'rdoc/markup'
2
+ require 'rdoc/markup/to_html'
3
3
 
4
4
  module QED
5
- class Document
6
-
7
- # = QED Document Markup
8
- #
9
- # QED Document Markup is based on RDoc's SimpleMarkup format but adds
10
- # some additional features.
11
- #
12
- # * `[no-spaces]` produces <code>[no-space]</code>.
13
- #
14
- class Markup
15
-
16
- def initialize(text, options={})
17
- @text = text
18
- end
19
5
 
20
- def to_html
21
- parser.convert(@text, formatter)
22
- end
6
+ class Document
23
7
 
24
- def parser
25
- @parser ||= (
26
- p = SM::SimpleMarkup.new
27
- #p.add_word_pair("{", "}", :STRIKE)
28
- #p.add_html("no", :STRIKE)
29
- #p.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
30
- p.add_special(/\`(\S+?)\`/, :CODE)
31
- p
32
- )
33
- end
8
+ # = QED Document Markup
9
+ #
10
+ # QED Document Markup is based on RDoc's SimpleMarkup format but adds
11
+ # some additional features.
12
+ #
13
+ # * `[no-spaces]` produces <code>[no-space]</code>.
14
+ #
15
+ # FIXME: Can't get `brackets` to work.
16
+ class Markup
34
17
 
35
- def formatter
36
- @formatter ||= (
37
- f = ToHTML.new
38
- #f.add_tag(:STRIKE, "<strike>", "</strike>")
39
- f
40
- )
41
- end
18
+ def initialize(text, options={})
19
+ @text = text
20
+ end
21
+
22
+ def to_html
23
+ parser.convert(@text, formatter)
24
+ end
42
25
 
43
- # Formatter
44
- class ToHTML < SM::ToHtml
45
- def handle_special_CODE(special)
46
- "<code>" + special.text.sub('`','').chomp('`') + "</code>"
26
+ def parser
27
+ @parser ||= (
28
+ m = RDoc::Markup.new
29
+ #p.add_word_pair("{", "}", :STRIKE)
30
+ #p.add_html("no", :STRIKE)
31
+ #p.add_special(/\b([A-Z][a-z]+[A-Z]\w+)/, :WIKIWORD)
32
+ #m.add_word_pair('`', '`', :CODE)
33
+ m.add_special(/\`(\b.*?)\`/, :CODE)
34
+ m
35
+ )
47
36
  end
37
+
38
+ def formatter
39
+ @formatter ||= (
40
+ f = ToHTML.new
41
+ #f.add_tag(:STRIKE, "<strike>", "</strike>")
42
+ f.add_tag(:CODE, "<code>", "</code>")
43
+ f
44
+ )
45
+ end
46
+
47
+ # Formatter
48
+ class ToHTML < RDoc::Markup::ToHtml
49
+ def handle_special_CODE(special)
50
+ "<code>" + special.text.sub('`','').chomp('`') + "</code>"
51
+ end
52
+ end
53
+
48
54
  end
49
55
 
50
56
  end
51
57
 
52
58
  end
53
- end
@@ -7,60 +7,60 @@
7
7
  <style>
8
8
  #container{ margin: 0 auto; width: 800px; }
9
9
 
10
- /* Debug borders */
10
+ /* Debug borders */
11
11
  /* p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { border: 1px solid red; } */
12
-
13
- body { font-size: 14px; line-height: 20px; margin: 1em 5% 1em 5%; font-family: Verdana, Arial, Helvetica, sans-serif; }
14
- a { color: #336; text-decoration: underline; }
15
- a:visited { color: #334; }
16
- em { font-style: italic; }
17
- strong { font-weight: bold; }
18
- tt { color: navy; }
19
-
20
- h1, h2, h3, h4, h5, h6 { color: #223; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; }
12
+
13
+ body { font-size: 14px; line-height: 20px; margin: 1em 5% 1em 5%; font-family: Verdana, Arial, Helvetica, sans-serif; }
14
+ a { color: #336; text-decoration: underline; }
15
+ a:visited { color: #334; }
16
+ em { font-style: italic; }
17
+ strong { font-weight: bold; }
18
+ tt { color: navy; }
19
+
20
+ h1, h2, h3, h4, h5, h6 { color: #223; margin-top: 1.2em; margin-bottom: 0.5em; line-height: 1.3; }
21
21
  h1 { border-bottom: 2px solid silver; }
22
- h2 { border-bottom: 2px solid silver; padding-top: 0.5em; }
22
+ h2 { border-bottom: 2px solid silver; padding-top: 0.5em; }
23
23
 
24
- hr { color: #ccc; margin-top: 1.6em; }
24
+ hr { color: #ccc; margin-top: 1.6em; }
25
25
 
26
- p { color: #222; text-align: justify; margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.4em; }
26
+ p { color: #222; text-align: justify; margin-top: 0.5em; margin-bottom: 0.5em; line-height: 1.4em; }
27
27
 
28
28
  /* pre { padding: 10; margin: 0; font-family: monospace; font-size: 0.9em; } */
29
29
 
30
30
  pre.pass { color: green; }
31
31
  pre.fail { color: red; }
32
32
  pre.error { color: red; font-weight: bold; }
33
-
34
- span#author { color: #527bbd; font-weight: bold; font-size: 1.1em; }
33
+
34
+ span#author { color: #527bbd; font-weight: bold; font-size: 1.1em; }
35
35
  span#email { }
36
36
  span#revision { }
37
-
37
+
38
38
  div#footer { font-size: small; border-top: 2px solid silver; padding-top: 0.5em; margin-top: 4.0em; }
39
39
  div#footer-text { float: left; padding-bottom: 0.5em; }
40
- div#footer-badges { float: right; padding-bottom: 0.5em; }
40
+ div#footer-badges { float: right; padding-bottom: 0.5em; }
41
41
 
42
42
  /* Block element content. */
43
- div.content { padding: 0; }
43
+ div.content { padding: 0; }
44
44
 
45
- /* Block element titles. */
46
- h1.title { font-weight: bold; text-align: left; font-size: 3em; margin-top: 1.0em; margin-bottom: 0.5em; }
45
+ /* Block element titles. */
46
+ h1.title { font-weight: bold; text-align: left; font-size: 3em; margin-top: 1.0em; margin-bottom: 0.5em; }
47
47
 
48
- /* Block element titles. */
49
- div.title, caption.title { font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; }
50
- div.title + * { margin-top: 0; }
51
- td div.title:first-child { margin-top: 0.0em; }
52
- div.content div.title:first-child { margin-top: 0.0em; }
53
- div.content + div.title { margin-top: 0.0em; }
54
- div.sidebarblock > div.content { background: #ffffee; border: 1px solid silver; padding: 0.5em; }
48
+ /* Block element titles. */
49
+ div.title, caption.title { font-weight: bold; text-align: left; margin-top: 1.0em; margin-bottom: 0.5em; }
50
+ div.title + * { margin-top: 0; }
51
+ td div.title:first-child { margin-top: 0.0em; }
52
+ div.content div.title:first-child { margin-top: 0.0em; }
53
+ div.content + div.title { margin-top: 0.0em; }
54
+ div.sidebarblock > div.content { background: #ffffee; border: 1px solid silver; padding: 0.5em; }
55
55
 
56
- img { border-style: none; }
56
+ img { border-style: none; }
57
57
 
58
- dl { margin-top: 0.8em; margin-bottom: 0.8em; }
59
- dt { margin-top: 0.5em; margin-bottom: 0; font-style: italic; }
60
- dd > *:first-child { margin-top: 0; }
61
- ul, ol { list-style-position: outside; }
58
+ dl { margin-top: 0.8em; margin-bottom: 0.8em; }
59
+ dt { margin-top: 0.5em; margin-bottom: 0; font-style: italic; }
60
+ dd > *:first-child { margin-top: 0; }
61
+ ul, ol { list-style-position: outside; }
62
62
 
63
- thead { font-weight: bold; }
63
+ thead { font-weight: bold; }
64
64
  tfoot { font-weight: bold; }
65
65
 
66
66
  *{margin:0;padding:0;}
data/meta/data.rb CHANGED
@@ -1,29 +1,27 @@
1
- Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION) # becuase Ruby 1.8~ gets in the way
2
-
3
1
  module QED
4
2
 
5
- def self.__DIR__
6
- File.dirname(__FILE__)
7
- end
3
+ DIRECTORY = File.dirname(__FILE__)
8
4
 
9
- def self.gemfile
10
- @gemfile ||= (
5
+ def self.package
6
+ @package ||= (
11
7
  require 'yaml'
12
- YAML.load(File.new(__DIR__ + '/gemfile'))
8
+ YAML.load(File.new(DIRECTORY + '/package'))
13
9
  )
14
10
  end
15
11
 
16
12
  def self.profile
17
13
  @profile ||= (
18
14
  require 'yaml'
19
- YAML.load(File.new(__DIR__ + '/profile'))
15
+ YAML.load(File.new(DIRECTORY + '/profile'))
20
16
  )
21
17
  end
22
18
 
23
19
  def self.const_missing(name)
24
20
  key = name.to_s.downcase
25
- gemfile[key] || profile[key] || super(name)
21
+ package[key] || profile[key] || super(name)
26
22
  end
27
23
 
28
24
  end
29
25
 
26
+ # becuase Ruby 1.8~ gets in the way
27
+ Object.__send__(:remove_const, :VERSION) if Object.const_defined?(:VERSION)