rbml 0.0.5.9.3.4 → 0.0.5.9.4
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/examples/cli/happycli.rbml +15 -0
- data/languages/doc/xhtml.rb +4 -4
- data/lib/base.rb +2 -2
- data/lib/cli_tools.rb +32 -4
- data/lib/rbml.rb +1 -1
- metadata +2 -2
data/examples/cli/happycli.rbml
CHANGED
@@ -3,6 +3,10 @@ cli :name=>"happycli", :prompt=>"^_^ " do
|
|
3
3
|
puts "unknown command: called #{method} with #{args}"
|
4
4
|
end
|
5
5
|
|
6
|
+
set :check do
|
7
|
+
puts make_sure('do you really want to do that?')
|
8
|
+
end
|
9
|
+
|
6
10
|
set :com do |args|
|
7
11
|
flag(:help => 'h'){
|
8
12
|
puts 'help docs for this command'
|
@@ -25,6 +29,17 @@ cli :name=>"happycli", :prompt=>"^_^ " do
|
|
25
29
|
puts "\nactive options: #{active_options}"
|
26
30
|
end
|
27
31
|
|
32
|
+
set :fate do
|
33
|
+
case choice('please choose your fate: ', ['happy', 'sad', 'random', 'happenstance'])
|
34
|
+
when 'happy' : puts 'this is fantastic!'
|
35
|
+
when 'happenstance' : puts 'this is how things go'
|
36
|
+
when 'sad' : puts 'aww, your doggie died!'
|
37
|
+
when 'random' : puts 'you turned 40 yesterday'
|
38
|
+
else
|
39
|
+
puts "\nyou made a stupid choice there, buddy"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
28
43
|
set :clear do
|
29
44
|
system 'clear'
|
30
45
|
end
|
data/languages/doc/xhtml.rb
CHANGED
@@ -19,14 +19,14 @@ module Rbml
|
|
19
19
|
|
20
20
|
def tags; %w(body title head p div ul li html a br span h1 h2 h3 h4 h5 h6 strong img i u b pre kbd code cite strong em ins sup sub del table tr td th ol blockquote)end
|
21
21
|
|
22
|
-
def stylesheets *sheets
|
22
|
+
def stylesheets dir, *sheets
|
23
23
|
all_sheets = ''
|
24
|
-
sheets.each {|sheet| all_sheets << stylesheet(sheet)}
|
24
|
+
sheets.each {|sheet| all_sheets << stylesheet(dir, sheet)}
|
25
25
|
all_sheets
|
26
26
|
end
|
27
27
|
|
28
|
-
def stylesheet what
|
29
|
-
"<link rel='stylesheet' href='
|
28
|
+
def stylesheet dir, what
|
29
|
+
"<link rel='stylesheet' href='#{dir}#{what}.css' type='text/css' />"
|
30
30
|
end
|
31
31
|
|
32
32
|
def doctype(options)
|
data/lib/base.rb
CHANGED
@@ -8,10 +8,10 @@ module Rbml
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def instance_eval_each(code, &blk)
|
11
|
-
|
11
|
+
@breaker = BlockBreaker.new do |name, args, block|
|
12
12
|
yield @dsl.__send__(name, *args, &block)
|
13
13
|
end
|
14
|
-
|
14
|
+
@breaker.__instance_eval__ &code
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/cli_tools.rb
CHANGED
@@ -11,7 +11,30 @@ end
|
|
11
11
|
module CliTools
|
12
12
|
def request_value words=nil
|
13
13
|
printf words+' ' if words
|
14
|
-
$stdin.gets
|
14
|
+
$stdin.gets.chop
|
15
|
+
end
|
16
|
+
|
17
|
+
def make_sure words='', default='Y', other='n'
|
18
|
+
answer = request_value(words+" [#{default}/#{other}]")
|
19
|
+
return true if answer==''
|
20
|
+
if answer.downcase == default.downcase or answer.downcase == other.downcase
|
21
|
+
return answer.downcase == default.downcase
|
22
|
+
else
|
23
|
+
return make_sure(words, default, other)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def choice say, array, with=nil
|
28
|
+
return nil if with == $/
|
29
|
+
with||=''
|
30
|
+
new_array = []
|
31
|
+
array.size.times do |i|
|
32
|
+
if (array[i]=~/#{with}/) || (with.to_i==i+1)
|
33
|
+
new_array << "#{array[i]}"
|
34
|
+
puts "\t#{new_array.size}: #{new_array.last}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
new_array.empty? ? nil : (new_array.size==1 ? new_array.first : choice(say, new_array, request_value(say)))
|
15
38
|
end
|
16
39
|
end
|
17
40
|
|
@@ -132,9 +155,7 @@ module Flagger
|
|
132
155
|
end
|
133
156
|
|
134
157
|
def active_options
|
135
|
-
|
136
|
-
keys = @active_keys || {}
|
137
|
-
flags.merge keys
|
158
|
+
active_flags.merge active_keys
|
138
159
|
end
|
139
160
|
def remaining_arguments
|
140
161
|
@remaining_argument||[]
|
@@ -143,6 +164,13 @@ module Flagger
|
|
143
164
|
@remaining_argument.join(' ')
|
144
165
|
end
|
145
166
|
|
167
|
+
def active_keys
|
168
|
+
@active_keys || {}
|
169
|
+
end
|
170
|
+
|
171
|
+
def active_flags
|
172
|
+
@active_flags || {}
|
173
|
+
end
|
146
174
|
end
|
147
175
|
|
148
176
|
|
data/lib/rbml.rb
CHANGED
@@ -2,7 +2,7 @@ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)) + "/../languages")
|
|
2
2
|
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
|
3
3
|
|
4
4
|
module Rbml
|
5
|
-
VERSION = '0.0.5.9.
|
5
|
+
VERSION = '0.0.5.9.4'
|
6
6
|
end
|
7
7
|
require 'extensions/kernel'
|
8
8
|
require 'extensions/primitives'
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: rbml
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.5.9.
|
7
|
-
date: 2007-05-
|
6
|
+
version: 0.0.5.9.4
|
7
|
+
date: 2007-05-31 00:00:00 -04:00
|
8
8
|
summary: Rbml is a dsl framework for writing other languages in ruby
|
9
9
|
require_paths:
|
10
10
|
- lib
|