dot_why 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/dot_why +16 -0
- data/lib/Cosmo.rb +45 -0
- data/lib/Diet_Dot.rb +62 -0
- data/lib/Ok.rb +59 -0
- data/lib/dot_why.rb +69 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 46f5b1b525ac28d6b7ee666075b243792de028a8
|
4
|
+
data.tar.gz: fe4ad00f977203729ce3465449fb9eb871024b8f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bf9bd5af59f969059ffdbc3147e1a8f9ac405f82ed78175a56e0dc028d25626157555bd4939f1caef603be86c068f7e9174e6516dd0c0431ff6e818ba8a20932
|
7
|
+
data.tar.gz: 73a60a2e3bc9404e4d9256c6c9ea9b58867ea507475f74ca810237e04b6e46abd862cee09535ac422dd34d04430bf94b47264e0136badb8bc4ed1bc8cc0fa07c
|
data/bin/dot_why
ADDED
data/lib/Cosmo.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
|
2
|
+
module Cosmo
|
3
|
+
|
4
|
+
def inline_var name
|
5
|
+
"$#{name}"
|
6
|
+
end
|
7
|
+
|
8
|
+
def var name, &blok
|
9
|
+
if block_given?
|
10
|
+
var_block(name, &blok)
|
11
|
+
else
|
12
|
+
text inline_var(name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def var_block name, args = ''
|
17
|
+
if args && args.strip.length > 0
|
18
|
+
args = "{#{args}}"
|
19
|
+
end
|
20
|
+
|
21
|
+
text "$#{name}#{args}[["
|
22
|
+
yield
|
23
|
+
text "]]"
|
24
|
+
end
|
25
|
+
|
26
|
+
end # === module
|
27
|
+
|
28
|
+
|
29
|
+
module Dot_Why
|
30
|
+
class Template
|
31
|
+
include Cosmo
|
32
|
+
end
|
33
|
+
end # === module
|
34
|
+
|
35
|
+
|
36
|
+
"$do_players[=[
|
37
|
+
$player has
|
38
|
+
$do_cards[[$rank of $suit]],
|
39
|
+
[[, $rank of $suit]],
|
40
|
+
[[, and $rank of $suit]]
|
41
|
+
]=]"
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
data/lib/Diet_Dot.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
|
2
|
+
module Diet_Dot
|
3
|
+
|
4
|
+
def dot_i str = "i", v = nil
|
5
|
+
rawdot str, v
|
6
|
+
end
|
7
|
+
|
8
|
+
def dot_v str = "v", v = nil
|
9
|
+
rawdot str, v
|
10
|
+
end
|
11
|
+
|
12
|
+
def inline_rawdot str
|
13
|
+
return( capture {
|
14
|
+
rawtext(rawdot(str, :inline))
|
15
|
+
})
|
16
|
+
end
|
17
|
+
|
18
|
+
def rawdot val, v = nil
|
19
|
+
str = "[[=#{val}]]"
|
20
|
+
if v === :inline
|
21
|
+
return str
|
22
|
+
end
|
23
|
+
text str + (v || "")
|
24
|
+
end
|
25
|
+
|
26
|
+
def dot name, v = ""
|
27
|
+
text "[[=data.#{name}]]#{v || ""}"
|
28
|
+
end
|
29
|
+
|
30
|
+
def var *args, &blok
|
31
|
+
dot(*args, &blok)
|
32
|
+
end
|
33
|
+
|
34
|
+
def dot_array name
|
35
|
+
text "[[~data." + name + " :v:i]]"
|
36
|
+
yield
|
37
|
+
text "[[~]]"
|
38
|
+
end
|
39
|
+
|
40
|
+
def dot_tertiary a, b, c
|
41
|
+
rawtext "[[? #{a} ]]"
|
42
|
+
rawdot b
|
43
|
+
rawtext "[[??]]"
|
44
|
+
rawdot c
|
45
|
+
rawtext "[[?]]"
|
46
|
+
end
|
47
|
+
|
48
|
+
end # === module
|
49
|
+
|
50
|
+
|
51
|
+
module Dot_Why
|
52
|
+
class Template
|
53
|
+
include Diet_Dot
|
54
|
+
end
|
55
|
+
end # === module
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
|
62
|
+
|
data/lib/Ok.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
module Ok
|
3
|
+
|
4
|
+
def on_off val = false, show_more = false
|
5
|
+
_class = (!val || val === 'off') ? 'off' : 'on'
|
6
|
+
span(:class=>"on_off #{_class}") {
|
7
|
+
a("On", :class=>'on', :href=>"#on")
|
8
|
+
a("Off", :class=>'off', :href=>"#off")
|
9
|
+
if (show_more)
|
10
|
+
a("Settings", :class=>'show_more', :href=>"#more_settings")
|
11
|
+
end
|
12
|
+
}
|
13
|
+
end
|
14
|
+
|
15
|
+
def span_as
|
16
|
+
span(:class=>'as_this_life') {
|
17
|
+
span("as: ", :class=>'as')
|
18
|
+
as_this_life_menu
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
def as_this_life_menu
|
23
|
+
select(:name=>"as_this_life") {
|
24
|
+
customer_screen_names.each do |k, v|
|
25
|
+
option(v, :value=>"#{v}")
|
26
|
+
end
|
27
|
+
}
|
28
|
+
end
|
29
|
+
|
30
|
+
def add_mtime src
|
31
|
+
puts "add_mtime not done"
|
32
|
+
return src
|
33
|
+
end
|
34
|
+
|
35
|
+
def script src
|
36
|
+
super(:type=>"text/javascript", :src=>add_mtime(src))
|
37
|
+
end
|
38
|
+
|
39
|
+
def applet name
|
40
|
+
blade_file = "../../applets/" + name + "/markup.blade"
|
41
|
+
js_file = "/applets/" + name + "/script.js"
|
42
|
+
css_file = "/applets/" + name + "/style.css"
|
43
|
+
eval(File.read( blade_file ), null, blade_file, 1)
|
44
|
+
styles { link(css_file) }
|
45
|
+
scripts { script js_file }
|
46
|
+
end
|
47
|
+
|
48
|
+
end # === module
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
module Dot_Why
|
53
|
+
class Template
|
54
|
+
include Ok
|
55
|
+
end
|
56
|
+
end # === module
|
57
|
+
|
58
|
+
|
59
|
+
|
data/lib/dot_why.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
require 'erector'
|
4
|
+
|
5
|
+
module Dot_Why
|
6
|
+
|
7
|
+
class Template < Erector::Widget
|
8
|
+
|
9
|
+
def initialize raw_file, *args
|
10
|
+
file = File.expand_path(raw_file).sub(".rb", "") + '.rb'
|
11
|
+
@_blocks = {}
|
12
|
+
super(*args)
|
13
|
+
eval(File.read("#{file}"), nil, file, 1)
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def blocks *args
|
18
|
+
args.each do |word|
|
19
|
+
define_method(word.to_sym) do |pos = :bottom, &b|
|
20
|
+
block word, pos, &b
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
blocks :main
|
27
|
+
|
28
|
+
def block raw_name, pos = :bottom, *args, &b
|
29
|
+
name = raw_name.to_sym
|
30
|
+
if (b)
|
31
|
+
@_blocks[name] ||= []
|
32
|
+
if (pos == :top)
|
33
|
+
@_blocks[name].unshift(b)
|
34
|
+
elsif (pos == :replace)
|
35
|
+
@_blocks[name] = [b]
|
36
|
+
else
|
37
|
+
@_blocks[name].push(b)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
(@_blocks[name] || []).each do |bl|
|
41
|
+
bl.call
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def styles *args, &b
|
47
|
+
@_link_type = :css
|
48
|
+
block :styles, *args, &b
|
49
|
+
@_link_type = nil
|
50
|
+
end
|
51
|
+
|
52
|
+
def link *args
|
53
|
+
if (@_link_type == :css && args.length == 1 && args[0].instance_of?(String))
|
54
|
+
super(:rel=>"stylesheet", :type=>"text/css", :href=>args[0])
|
55
|
+
else
|
56
|
+
super
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def content
|
61
|
+
main
|
62
|
+
end
|
63
|
+
|
64
|
+
end # === Layout
|
65
|
+
|
66
|
+
end # === module
|
67
|
+
|
68
|
+
|
69
|
+
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dot_why
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- da99
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: erector
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: active_support
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Use of Erector to generate various types of templates.
|
42
|
+
email: da99@da99
|
43
|
+
executables:
|
44
|
+
- dot_why
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/Cosmo.rb
|
49
|
+
- lib/Diet_Dot.rb
|
50
|
+
- lib/dot_why.rb
|
51
|
+
- lib/Ok.rb
|
52
|
+
- bin/dot_why
|
53
|
+
homepage: http://www.github.com/da99/dot_why
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.0.6
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Erector to create other templates.
|
77
|
+
test_files: []
|