wunderbar 0.8.7 → 0.8.8

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,59 +16,59 @@ Quick Start
16
16
 
17
17
  Simple element:
18
18
 
19
- _br
19
+ _br
20
20
 
21
21
  Nested elements:
22
22
 
23
- _div do
24
- _hr
25
- end
23
+ _div do
24
+ _hr
25
+ end
26
26
 
27
27
  Element with text:
28
28
 
29
- _h1 "My weblog"
29
+ _h1 "My weblog"
30
30
 
31
31
  Element with attributes:
32
32
 
33
- _img src: '/img/logo.jpg', alt: 'site logo'
33
+ _img src: '/img/logo.jpg', alt: 'site logo'
34
34
 
35
35
  Element with both text and attributes:
36
36
 
37
- _a 'search', href: 'http://google.com'
37
+ _a 'search', href: 'http://google.com'
38
38
 
39
39
  Text:
40
40
 
41
- _ "hello"
41
+ _ "hello"
42
42
 
43
43
  Mixed content (autospaced):
44
44
 
45
- _p do
46
- _ 'It is a'
47
- _em 'very'
48
- _ 'nice day.'
49
- end
45
+ _p do
46
+ _ 'It is a'
47
+ _em 'very'
48
+ _ 'nice day.'
49
+ end
50
50
 
51
51
  Mixed content (space controlled):
52
52
 
53
- _p! do
54
- _ 'Source is on '
55
- _a 'github', href: 'https://github.com/'
56
- _ '.'
57
- end
53
+ _p! do
54
+ _ 'Source is on '
55
+ _a 'github', href: 'https://github.com/'
56
+ _ '.'
57
+ end
58
58
 
59
59
  Insert blank lines between rows in the HTML produced:
60
60
 
61
- _tbody do
62
- _tr_ do
63
- _td 1
64
- end
65
- _tr_ do
66
- _td 2
67
- end
68
- _tr_ do
69
- _td 3
70
- end
71
- end
61
+ _tbody do
62
+ _tr_ do
63
+ _td 1
64
+ end
65
+ _tr_ do
66
+ _td 2
67
+ end
68
+ _tr_ do
69
+ _td 3
70
+ end
71
+ end
72
72
 
73
73
  Capture exceptions:
74
74
 
@@ -83,31 +83,36 @@ Basic interface
83
83
  A typical main program produces one or more of HTML, JSON, or plain text
84
84
  output. This is accomplished by providing one or more of the following:
85
85
 
86
- Wunderbar.html do
87
- code
88
- end
89
-
90
- Wunderbar.json do
91
- expression
92
- end
93
-
94
- Wunderbar.text do
95
- code
96
- end
86
+ Wunderbar.html do
87
+ code
88
+ end
89
+
90
+ Wunderbar.xhtml do
91
+ code
92
+ end
93
+
94
+ Wunderbar.json do
95
+ expression
96
+ end
97
+
98
+ Wunderbar.text do
99
+ code
100
+ end
97
101
 
98
102
  Arbitrary Ruby code can be placed in each. For html, use the `_` methods described here. For json, the results (typically a hash or array) are converted to JSON. For text, use `puts` and `print` statements to produce the desired results.
99
103
 
100
104
  Methods provided to Wunderbar.html
101
105
  ---
102
106
 
103
- Invoking methods that start with a Unicode "low line" character ("_") will
104
- generate a HTML tag. As with builder on which this library is based, these
105
- tags can have text content and attributes. Tags can also be nested. Logic
106
- can be freely intermixed.
107
+ Invoking methods that start with a Unicode
108
+ [low line](http://www.fileformat.info/info/unicode/char/5f/index.htm)
109
+ character ("_") will generate a HTML tag. As with builder on which this
110
+ library is based, these tags can have text content and attributes. Tags can
111
+ also be nested. Logic can be freely intermixed.
107
112
 
108
113
  Wunderbar knows which HTML tags need to be explicitly closed with separate end
109
- tags (example: textarea), and which should never be closed with separate end
110
- tags (example: br). It also takes care of HTML quoting and escaping of
114
+ tags (example: `textarea`), and which should never be closed with separate end
115
+ tags (example: `br`). It also takes care of HTML quoting and escaping of
111
116
  arguments and text.
112
117
 
113
118
  Suffixes after the tag name will modify the processing.
@@ -120,9 +125,9 @@ The "`_`" method serves a number of purposes. Calling it with a single argument
120
125
  produces text nodes. Inserting markup verbatim is done by "`_ << text`". A
121
126
  number of other convenience methods are defined:
122
127
 
123
- * _.`post?` -- was this invoked via HTTP POST?
124
- * _.`system` -- invokes a shell command, captures stdin, stdout, and stderr
125
- * _.`submit`: runs command (or block) as a deamon process
128
+ * `_.post?` -- was this invoked via HTTP POST?
129
+ * `_.system` -- invokes a shell command, captures stdin, stdout, and stderr
130
+ * `_.submit`: runs command (or block) as a deamon process
126
131
 
127
132
  Access to all of the builder _defined_ methods (typically these end in an esclamation mark) and all of the Wunderbar module methods can be accessed in this way. Examples:
128
133
 
@@ -189,24 +194,24 @@ Builder extensions
189
194
 
190
195
  Logging:
191
196
  ---
192
- * _.`debug`: debug messages
193
- * _.`info`: informational messages
194
- * _.`warn`: warning messages
195
- * _.`error`: error messages
196
- * _.`fatal`: fatal error messages
197
- * _.`log_level`=: set logging level (default: `:warn`)
198
- * _.`logger`: return [Logger](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html) instance
197
+ * `_.debug`: debug messages
198
+ * `_.info`: informational messages
199
+ * `_.warn`: warning messages
200
+ * `_.error`: error messages
201
+ * `_.fatal`: fatal error messages
202
+ * `_.log_level`=: set logging level (default: `:warn`)
203
+ * `_.logger`: return [Logger](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/logger/rdoc/Logger.html) instance
199
204
 
200
205
  Command line options
201
206
  ---
202
207
  When run from the command line, CGI name=value pairs can be specified.
203
208
  Additionally, the following options are supported:
204
209
 
205
- * --`html`: HTML (HTTP GET) output is expected
206
- * --`post`: HTML (HTTP POST) output is expected
207
- * --`json`: JSON (XML HTTP Request) output is expected
208
- * --`xhtml`: XHTML output is expected
209
- * --`prompt` or --`offline`: prompt for key/value pairs using stdin
210
- * --`debug`, --`info`,--`warn`, --`error`, --`fatal`: set log level
211
- * --`install`=path: produce an suexec-callable wrapper script
212
- * --`rescue` or --`backtrace` cause wrapper script to capture errors
210
+ * `--get`: HTML (HTTP GET) output is expected
211
+ * `--post`: HTML (HTTP POST) output is expected
212
+ * `--json`: JSON (XML HTTP Request) output is expected
213
+ * `--html`: force HTML output
214
+ * `--prompt` or `--offline`: prompt for key/value pairs using stdin
215
+ * `--debug`, `--info`, `--warn`, `--error`, `--fatal`: set log level
216
+ * `--install=`path: produce an suexec-callable wrapper script
217
+ * `--rescue` or `--backtrace` cause wrapper script to capture errors
@@ -116,6 +116,12 @@ end
116
116
  # canonical interface
117
117
  module Wunderbar
118
118
  def self.html(*args, &block)
119
+ $XHTML = false unless ARGV.delete('--xhtml')
120
+ $cgi.html!(*args, &block)
121
+ end
122
+
123
+ def self.xhtml(*args, &block)
124
+ $XHTML = false if ARGV.delete('--html')
119
125
  $cgi.html!(*args, &block)
120
126
  end
121
127
 
@@ -127,4 +133,3 @@ module Wunderbar
127
133
  $cgi.text!(*args, &block)
128
134
  end
129
135
  end
130
-
@@ -1,8 +1,7 @@
1
1
  # explicit request types
2
- $HTTP_GET = ARGV.delete('--html')
2
+ $HTTP_GET = ARGV.delete('--get')
3
3
  $HTTP_POST = ARGV.delete('--post')
4
4
  $XHR_JSON = ARGV.delete('--json')
5
- $XHTML = ARGV.delete('--xhtml')
6
5
  $TEXT = ARGV.delete('--text')
7
6
 
8
7
  # Only prompt if explicitly asked for
@@ -17,8 +16,8 @@ $param = $cgi.params
17
16
  $HTTP_GET ||= ($cgi.request_method == 'GET')
18
17
  $HTTP_POST ||= ($cgi.request_method == 'POST')
19
18
  $XHR_JSON ||= ($cgi.accept.to_s =~ /json/)
20
- $XHTML ||= ($cgi.accept.to_s =~ /xhtml/)
21
19
  $TEXT ||= ($cgi.accept.to_s =~ /plain/ and $cgi.accept.to_s !~ /html/)
20
+ $XHTML = ($cgi.accept.to_s =~ /xhtml/ or $cgi.accept == nil)
22
21
 
23
22
  # get arguments if CGI couldn't find any...
24
23
  $param.merge!(CGI.parse(ARGV.join('&'))) if $param.empty?
@@ -96,7 +96,7 @@ class HtmlMarkup
96
96
 
97
97
  def _head(*args, &block)
98
98
  @x.tag!('head', *args) do
99
- @x.tag! :meta, :charset => 'utf-8' unless $XHTML
99
+ @x.tag! :meta, :charset => 'utf-8'
100
100
  block.call if block
101
101
  end
102
102
  end
@@ -2,7 +2,7 @@ module Wunderbar
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 8
5
- TINY = 7
5
+ TINY = 8
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
data/wunderbar.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "wunderbar"
5
- s.version = "0.8.7"
5
+ s.version = "0.8.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Sam Ruby"]
9
- s.date = "2012-03-17"
9
+ s.date = "2012-03-18"
10
10
  s.description = " Provides a number of globals, helper methods, and monkey patches which\n simplify the generation of HTML and the development of CGI scripts.\n"
11
11
  s.email = "rubys@intertwingly.net"
12
12
  s.extra_rdoc_files = ["COPYING", "README.md", "lib/wunderbar.rb", "lib/wunderbar/builder.rb", "lib/wunderbar/cgi-methods.rb", "lib/wunderbar/environment.rb", "lib/wunderbar/html-methods.rb", "lib/wunderbar/installation.rb", "lib/wunderbar/job-control.rb", "lib/wunderbar/logger.rb", "lib/wunderbar/version.rb"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wunderbar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 49
4
+ hash: 47
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 8
9
- - 7
10
- version: 0.8.7
9
+ - 8
10
+ version: 0.8.8
11
11
  platform: ruby
12
12
  authors:
13
13
  - Sam Ruby
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-17 00:00:00 Z
18
+ date: 2012-03-18 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: builder