coherent 0.1.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/LICENSE +203 -0
- data/README.rdoc +3 -0
- data/Rakefile +61 -0
- data/VERSION +1 -0
- data/app_generators/coherent/USAGE +5 -0
- data/app_generators/coherent/coherent_generator.rb +95 -0
- data/app_generators/coherent/templates/distil.yml.erb +40 -0
- data/app_generators/coherent/templates/src/NOTICE.erb +2 -0
- data/app_generators/coherent/templates/src/css/@name@.css.erb +120 -0
- data/app_generators/coherent/templates/src/css/reset.css +70 -0
- data/app_generators/coherent/templates/src/js/@name@.js.erb +5 -0
- data/app_generators/coherent/templates/src/pages/index.html.erb +25 -0
- data/bin/coherent +31 -0
- data/coherent.gemspec +84 -0
- data/generators/class/USAGE +5 -0
- data/generators/class/class_generator.rb +56 -0
- data/generators/class/templates/@name@.js.erb +19 -0
- data/generators/coherent_library/USAGE +5 -0
- data/generators/coherent_library/coherent_library_generator.rb +44 -0
- data/generators/gallery_sample/USAGE +5 -0
- data/generators/gallery_sample/gallery_sample_generator.rb +48 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/@name@.css +116 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/@name@.html +6 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/@name@.jsnib.erb +40 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/@name@.json +25 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/images/next.gif +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/images/prev.gif +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/photos/molly-1.jpg +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/photos/molly-2.jpg +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/photos/molly-3.jpg +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/photos/molly-4.jpg +0 -0
- data/generators/gallery_sample/templates/src/nibs/@name@/photos/molly-5.jpg +0 -0
- data/generators/nib/USAGE +5 -0
- data/generators/nib/nib_generator.rb +50 -0
- data/generators/nib/templates/@name@.css.erb +1 -0
- data/generators/nib/templates/@name@.html.erb +4 -0
- data/generators/nib/templates/@name@.jsnib.erb +19 -0
- data/lib/coherent.rb +42 -0
- data/vendor/Makefile +4 -0
- data/vendor/checkout_coherent.sh +6 -0
- data/vendor/extconf.rb +3 -0
- metadata +105 -0
data/coherent.gemspec
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# Generated by jeweler
|
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
|
4
|
+
# -*- encoding: utf-8 -*-
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |s|
|
|
7
|
+
s.name = %q{coherent}
|
|
8
|
+
s.version = "0.1.0"
|
|
9
|
+
|
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
|
+
s.authors = ["Jeff Watkins"]
|
|
12
|
+
s.date = %q{2009-12-21}
|
|
13
|
+
s.default_executable = %q{coherent}
|
|
14
|
+
s.description = %q{Tools for building Coherent application or modules.}
|
|
15
|
+
s.email = %q{jeff@metrocat.org}
|
|
16
|
+
s.executables = ["coherent"]
|
|
17
|
+
s.extensions = ["vendor/extconf.rb"]
|
|
18
|
+
s.extra_rdoc_files = [
|
|
19
|
+
"LICENSE",
|
|
20
|
+
"README.rdoc"
|
|
21
|
+
]
|
|
22
|
+
s.files = [
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"README.rdoc",
|
|
25
|
+
"Rakefile",
|
|
26
|
+
"VERSION",
|
|
27
|
+
"app_generators/coherent/USAGE",
|
|
28
|
+
"app_generators/coherent/coherent_generator.rb",
|
|
29
|
+
"app_generators/coherent/templates/distil.yml.erb",
|
|
30
|
+
"app_generators/coherent/templates/src/NOTICE.erb",
|
|
31
|
+
"app_generators/coherent/templates/src/css/@name@.css.erb",
|
|
32
|
+
"app_generators/coherent/templates/src/css/reset.css",
|
|
33
|
+
"app_generators/coherent/templates/src/js/@name@.js.erb",
|
|
34
|
+
"app_generators/coherent/templates/src/pages/index.html.erb",
|
|
35
|
+
"bin/coherent",
|
|
36
|
+
"coherent.gemspec",
|
|
37
|
+
"generators/class/USAGE",
|
|
38
|
+
"generators/class/class_generator.rb",
|
|
39
|
+
"generators/class/templates/@name@.js.erb",
|
|
40
|
+
"generators/coherent_library/USAGE",
|
|
41
|
+
"generators/coherent_library/coherent_library_generator.rb",
|
|
42
|
+
"generators/gallery_sample/USAGE",
|
|
43
|
+
"generators/gallery_sample/gallery_sample_generator.rb",
|
|
44
|
+
"generators/gallery_sample/templates/src/nibs/@name@/@name@.css",
|
|
45
|
+
"generators/gallery_sample/templates/src/nibs/@name@/@name@.html",
|
|
46
|
+
"generators/gallery_sample/templates/src/nibs/@name@/@name@.jsnib.erb",
|
|
47
|
+
"generators/gallery_sample/templates/src/nibs/@name@/@name@.json",
|
|
48
|
+
"generators/gallery_sample/templates/src/nibs/@name@/images/next.gif",
|
|
49
|
+
"generators/gallery_sample/templates/src/nibs/@name@/images/prev.gif",
|
|
50
|
+
"generators/gallery_sample/templates/src/nibs/@name@/photos/molly-1.jpg",
|
|
51
|
+
"generators/gallery_sample/templates/src/nibs/@name@/photos/molly-2.jpg",
|
|
52
|
+
"generators/gallery_sample/templates/src/nibs/@name@/photos/molly-3.jpg",
|
|
53
|
+
"generators/gallery_sample/templates/src/nibs/@name@/photos/molly-4.jpg",
|
|
54
|
+
"generators/gallery_sample/templates/src/nibs/@name@/photos/molly-5.jpg",
|
|
55
|
+
"generators/nib/USAGE",
|
|
56
|
+
"generators/nib/nib_generator.rb",
|
|
57
|
+
"generators/nib/templates/@name@.css.erb",
|
|
58
|
+
"generators/nib/templates/@name@.html.erb",
|
|
59
|
+
"generators/nib/templates/@name@.jsnib.erb",
|
|
60
|
+
"lib/coherent.rb",
|
|
61
|
+
"vendor/Makefile",
|
|
62
|
+
"vendor/checkout_coherent.sh",
|
|
63
|
+
"vendor/extconf.rb"
|
|
64
|
+
]
|
|
65
|
+
s.homepage = %q{http://coherentjs.org}
|
|
66
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
|
67
|
+
s.require_paths = ["lib"]
|
|
68
|
+
s.rubygems_version = %q{1.3.5}
|
|
69
|
+
s.summary = %q{Tools for building Coherent application or modules.}
|
|
70
|
+
|
|
71
|
+
if s.respond_to? :specification_version then
|
|
72
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
73
|
+
s.specification_version = 3
|
|
74
|
+
|
|
75
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
|
76
|
+
s.add_runtime_dependency(%q<distil>, [">= 0.7.0"])
|
|
77
|
+
else
|
|
78
|
+
s.add_dependency(%q<distil>, [">= 0.7.0"])
|
|
79
|
+
end
|
|
80
|
+
else
|
|
81
|
+
s.add_dependency(%q<distil>, [">= 0.7.0"])
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/coherent"
|
|
2
|
+
|
|
3
|
+
class ClassGenerator < CoherentBaseGenerator
|
|
4
|
+
|
|
5
|
+
default_options :author => nil
|
|
6
|
+
|
|
7
|
+
attr_reader :name, :full_name, :namespace
|
|
8
|
+
|
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
|
10
|
+
super
|
|
11
|
+
usage if args.empty?
|
|
12
|
+
full_name= args.shift
|
|
13
|
+
parts= full_name.split(".")
|
|
14
|
+
|
|
15
|
+
@namespace= parts[0..-2].join(".")
|
|
16
|
+
@name= parts[-1]
|
|
17
|
+
@full_name= full_name
|
|
18
|
+
|
|
19
|
+
extract_options
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def manifest
|
|
23
|
+
record do |m|
|
|
24
|
+
|
|
25
|
+
copy_template_folder m, "src/js/#{@namespace.gsub(".", "/")}"
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
def banner
|
|
32
|
+
<<-EOS
|
|
33
|
+
Creates a ...
|
|
34
|
+
|
|
35
|
+
USAGE: #{$0} #{spec.name} name
|
|
36
|
+
EOS
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def add_options!(opts)
|
|
40
|
+
# opts.separator ''
|
|
41
|
+
# opts.separator 'Options:'
|
|
42
|
+
# For each option below, place the default
|
|
43
|
+
# at the top of the file next to "default_options"
|
|
44
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
|
45
|
+
# "Some comment about this option",
|
|
46
|
+
# "Default: none") { |o| options[:author] = o }
|
|
47
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def extract_options
|
|
51
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
|
52
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
|
53
|
+
# raw instance variable value.
|
|
54
|
+
# @author = options[:author]
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*jsl:import coherent-uncompressed.js*/
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
|
|
6
|
+
*/
|
|
7
|
+
<%= namespace.empty? ? "var " : ""%><%=full_name%>= Class.create(coherent.KVO, {
|
|
8
|
+
|
|
9
|
+
sampleProperty: function()
|
|
10
|
+
{
|
|
11
|
+
return this.__sampleProperty;
|
|
12
|
+
},
|
|
13
|
+
|
|
14
|
+
setSampleProperty: function(newSampleProperty)
|
|
15
|
+
{
|
|
16
|
+
this.__sampleProperty= newSampleProperty;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/coherent"
|
|
2
|
+
|
|
3
|
+
class CoherentLibraryGenerator < CoherentBaseGenerator
|
|
4
|
+
|
|
5
|
+
default_options :author => nil
|
|
6
|
+
|
|
7
|
+
def initialize(runtime_args, runtime_options = {})
|
|
8
|
+
super
|
|
9
|
+
extract_options
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def manifest
|
|
13
|
+
record do |m|
|
|
14
|
+
copy_template_folder m
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
protected
|
|
19
|
+
def banner
|
|
20
|
+
<<-EOS
|
|
21
|
+
Creates a ...
|
|
22
|
+
|
|
23
|
+
USAGE: #{$0} #{spec.name} name
|
|
24
|
+
EOS
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def add_options!(opts)
|
|
28
|
+
# opts.separator ''
|
|
29
|
+
# opts.separator 'Options:'
|
|
30
|
+
# For each option below, place the default
|
|
31
|
+
# at the top of the file next to "default_options"
|
|
32
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
|
33
|
+
# "Some comment about this option",
|
|
34
|
+
# "Default: none") { |o| options[:author] = o }
|
|
35
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def extract_options
|
|
39
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
|
40
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
|
41
|
+
# raw instance variable value.
|
|
42
|
+
# @author = options[:author]
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/coherent"
|
|
2
|
+
|
|
3
|
+
class GallerySampleGenerator < CoherentBaseGenerator
|
|
4
|
+
|
|
5
|
+
default_options :author => nil
|
|
6
|
+
|
|
7
|
+
attr_reader :name
|
|
8
|
+
|
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
|
10
|
+
super
|
|
11
|
+
usage if args.empty?
|
|
12
|
+
@name = args.shift
|
|
13
|
+
extract_options
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def manifest
|
|
17
|
+
record do |m|
|
|
18
|
+
copy_template_folder m
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
protected
|
|
23
|
+
def banner
|
|
24
|
+
<<-EOS
|
|
25
|
+
Creates a ...
|
|
26
|
+
|
|
27
|
+
USAGE: #{$0} #{spec.name} name
|
|
28
|
+
EOS
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def add_options!(opts)
|
|
32
|
+
# opts.separator ''
|
|
33
|
+
# opts.separator 'Options:'
|
|
34
|
+
# For each option below, place the default
|
|
35
|
+
# at the top of the file next to "default_options"
|
|
36
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
|
37
|
+
# "Some comment about this option",
|
|
38
|
+
# "Default: none") { |o| options[:author] = o }
|
|
39
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def extract_options
|
|
43
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
|
44
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
|
45
|
+
# raw instance variable value.
|
|
46
|
+
# @author = options[:author]
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
.gallery
|
|
2
|
+
{
|
|
3
|
+
border: 1px solid #888;
|
|
4
|
+
-webkit-border-radius: 5px;
|
|
5
|
+
background-color: #f8f8f8;
|
|
6
|
+
padding: 10px 10px 35px 10px;
|
|
7
|
+
width: 254px;
|
|
8
|
+
height: 200px;
|
|
9
|
+
-webkit-box-shadow: 0px 2px 5px rgba(0,0,0,0.5);
|
|
10
|
+
|
|
11
|
+
overflow: hidden;
|
|
12
|
+
position: fixed;
|
|
13
|
+
left: 50%;
|
|
14
|
+
top: 50%;
|
|
15
|
+
margin: -125px 0 0 -127px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.gallery.invisible
|
|
19
|
+
{
|
|
20
|
+
opacity: 0.5;
|
|
21
|
+
width: 50px;
|
|
22
|
+
height: 50px;
|
|
23
|
+
margin: -25px 0 0 -25px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.gallery.invisible *
|
|
27
|
+
{
|
|
28
|
+
display: none !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.gallery p
|
|
32
|
+
{
|
|
33
|
+
font-family: helvetica, arial, sans serif;
|
|
34
|
+
font-size: 13px;
|
|
35
|
+
color: #555;
|
|
36
|
+
background-color: inherit;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.gallery p.updating
|
|
40
|
+
{
|
|
41
|
+
background-color: yellow;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.gallery img
|
|
45
|
+
{
|
|
46
|
+
border: 1px solid #666;
|
|
47
|
+
padding: 1px;
|
|
48
|
+
background-color: white;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.gallery a.next
|
|
52
|
+
{
|
|
53
|
+
position: absolute;
|
|
54
|
+
display: block;
|
|
55
|
+
text-indent: -9999px;
|
|
56
|
+
outline: none;
|
|
57
|
+
background-image: url(images/next.gif);
|
|
58
|
+
right: 10px;
|
|
59
|
+
bottom: 10px;
|
|
60
|
+
height: 22px;
|
|
61
|
+
width: 22px;
|
|
62
|
+
background-position: 0px -22px;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.gallery a.prev
|
|
66
|
+
{
|
|
67
|
+
position: absolute;
|
|
68
|
+
display: block;
|
|
69
|
+
outline: none;
|
|
70
|
+
text-indent: -9999px;
|
|
71
|
+
background-image: url(images/prev.gif);
|
|
72
|
+
left: 10px;
|
|
73
|
+
bottom: 10px;
|
|
74
|
+
height: 22px;
|
|
75
|
+
width: 22px;
|
|
76
|
+
background-position: 0px -22px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.gallery a.next:active,
|
|
80
|
+
.gallery a.prev:active
|
|
81
|
+
{
|
|
82
|
+
background-position: 0px 0px;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.gallery a.disabled,
|
|
86
|
+
.gallery a.disabled:active
|
|
87
|
+
{
|
|
88
|
+
background-position: 0px -44px;
|
|
89
|
+
cursor: default;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.modal-overlay-guard
|
|
93
|
+
{
|
|
94
|
+
position: fixed;
|
|
95
|
+
left: 0;
|
|
96
|
+
top: 0;
|
|
97
|
+
width: 100%;
|
|
98
|
+
height: 100%;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
.modal-overlay-backdrop
|
|
102
|
+
{
|
|
103
|
+
background-color: black;
|
|
104
|
+
opacity: 0.65;
|
|
105
|
+
position: fixed;
|
|
106
|
+
left: 0;
|
|
107
|
+
top: 0;
|
|
108
|
+
width: 100%;
|
|
109
|
+
height: 100%;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.modal-overlay-backdrop.invisible
|
|
113
|
+
{
|
|
114
|
+
opacity: 0;
|
|
115
|
+
}
|
|
116
|
+
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*jsl:import coherent-uncompressed.js*/
|
|
2
|
+
|
|
3
|
+
NIB.asset('<%=name%>.css');
|
|
4
|
+
|
|
5
|
+
NIB({
|
|
6
|
+
|
|
7
|
+
'<%=name%>': VIEW(NIB.asset('<%=name%>.html'), {
|
|
8
|
+
':root': coherent.View({
|
|
9
|
+
visibleBinding: 'controller.arrangedObjects.@count'
|
|
10
|
+
}),
|
|
11
|
+
'img': coherent.Image({
|
|
12
|
+
srcBinding: 'controller.selection.href'
|
|
13
|
+
}),
|
|
14
|
+
'p': coherent.View({
|
|
15
|
+
textBinding: 'controller.selection.caption'
|
|
16
|
+
}),
|
|
17
|
+
'a.next': coherent.Anchor({
|
|
18
|
+
enabledBinding: 'controller.canSelectNext',
|
|
19
|
+
target: 'controller',
|
|
20
|
+
action: 'selectNext'
|
|
21
|
+
}),
|
|
22
|
+
'a.prev': coherent.Anchor({
|
|
23
|
+
enabledBinding: 'controller.canSelectPrevious',
|
|
24
|
+
target: 'controller',
|
|
25
|
+
action: 'selectPrevious'
|
|
26
|
+
})
|
|
27
|
+
}),
|
|
28
|
+
|
|
29
|
+
'data': NIB.asset('<%=name%>.json'),
|
|
30
|
+
|
|
31
|
+
'controller': coherent.ArrayController({
|
|
32
|
+
contentBinding: 'data.photos'
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
'owner': {
|
|
36
|
+
view: '<%=name%>'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
photos: [
|
|
3
|
+
{
|
|
4
|
+
caption: "Molly on the slide.",
|
|
5
|
+
href: NIB.asset("photos/molly-1.jpg")
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
caption: "Monkey in training",
|
|
9
|
+
href: NIB.asset("photos/molly-2.jpg")
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
caption: "Spaz attack!",
|
|
13
|
+
href: NIB.asset("photos/molly-3.jpg")
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
caption: "Ride `Em, Molly!",
|
|
17
|
+
href: NIB.asset("photos/molly-4.jpg")
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
caption: "Don't mess with my zebra.",
|
|
21
|
+
href: NIB.asset("photos/molly-5.jpg")
|
|
22
|
+
}
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
}
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require "#{File.dirname(__FILE__)}/../../lib/coherent"
|
|
2
|
+
|
|
3
|
+
class NibGenerator < CoherentBaseGenerator
|
|
4
|
+
|
|
5
|
+
default_options :author => nil
|
|
6
|
+
|
|
7
|
+
attr_reader :name
|
|
8
|
+
|
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
|
10
|
+
super
|
|
11
|
+
usage if args.empty?
|
|
12
|
+
@name = args.shift
|
|
13
|
+
|
|
14
|
+
extract_options
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def manifest
|
|
18
|
+
record do |m|
|
|
19
|
+
m.directory "src/nibs"
|
|
20
|
+
copy_template_folder m, "src/nibs/#{@name}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
protected
|
|
25
|
+
def banner
|
|
26
|
+
<<-EOS
|
|
27
|
+
Creates a ...
|
|
28
|
+
|
|
29
|
+
USAGE: #{$0} #{spec.name} name
|
|
30
|
+
EOS
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def add_options!(opts)
|
|
34
|
+
# opts.separator ''
|
|
35
|
+
# opts.separator 'Options:'
|
|
36
|
+
# For each option below, place the default
|
|
37
|
+
# at the top of the file next to "default_options"
|
|
38
|
+
# opts.on("-a", "--author=\"Your Name\"", String,
|
|
39
|
+
# "Some comment about this option",
|
|
40
|
+
# "Default: none") { |o| options[:author] = o }
|
|
41
|
+
# opts.on("-v", "--version", "Show the #{File.basename($0)} version number and quit.")
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def extract_options
|
|
45
|
+
# for each option, extract it into a local variable (and create an "attr_reader :author" at the top)
|
|
46
|
+
# Templates can access these value via the attr_reader-generated methods, but not the
|
|
47
|
+
# raw instance variable value.
|
|
48
|
+
# @author = options[:author]
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/* CSS Rules for the <%=name%> NIB. */
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*jsl:import coherent-uncompressed.js*/
|
|
2
|
+
|
|
3
|
+
NIB.asset('<%=name%>.css');
|
|
4
|
+
|
|
5
|
+
NIB({
|
|
6
|
+
|
|
7
|
+
'<%=name%>': VIEW(NIB.asset('<%=name%>.html'), {
|
|
8
|
+
/* Put your view structure here. */
|
|
9
|
+
|
|
10
|
+
':root': coherent.View({
|
|
11
|
+
/* This is the container DOM element. */
|
|
12
|
+
})
|
|
13
|
+
}),
|
|
14
|
+
|
|
15
|
+
'owner': {
|
|
16
|
+
view: '<%=name%>'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
});
|
data/lib/coherent.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require "activesupport"
|
|
2
|
+
|
|
3
|
+
class CoherentBaseGenerator < RubiGen::Base
|
|
4
|
+
|
|
5
|
+
def copy_template_folder(m, path=nil)
|
|
6
|
+
path = path ? "#{path}/" : ""
|
|
7
|
+
prefix_regex= Regexp.new("^#{Regexp.escape(source_root)}/(.*)$")
|
|
8
|
+
all_files= Dir.glob("#{source_root}/**/*").select { |filepath| File.file?(filepath) }
|
|
9
|
+
|
|
10
|
+
all_files.map! { |filepath| prefix_regex.match(filepath)[1] }
|
|
11
|
+
|
|
12
|
+
b= binding
|
|
13
|
+
|
|
14
|
+
all_folders= all_files.map { |filepath|
|
|
15
|
+
File.dirname(filepath).gsub(/@(\w+)@/) { |match|
|
|
16
|
+
begin
|
|
17
|
+
eval($1, b)
|
|
18
|
+
rescue
|
|
19
|
+
"@#{$1}@"
|
|
20
|
+
end
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
all_folders.uniq.each { |folder| m.directory "#{path}#{folder}" }
|
|
24
|
+
|
|
25
|
+
all_files.each { |filepath|
|
|
26
|
+
output_path= filepath.gsub(/\.erb$/, '').gsub(/@(\w+)@/) { |match|
|
|
27
|
+
begin
|
|
28
|
+
eval($1, b)
|
|
29
|
+
rescue
|
|
30
|
+
"@#{$1}@"
|
|
31
|
+
end
|
|
32
|
+
}
|
|
33
|
+
output_path= "#{path}#{output_path}"
|
|
34
|
+
if (filepath[/\.erb$/])
|
|
35
|
+
m.template filepath, output_path
|
|
36
|
+
else
|
|
37
|
+
m.file filepath, output_path
|
|
38
|
+
end
|
|
39
|
+
}
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
data/vendor/Makefile
ADDED
data/vendor/extconf.rb
ADDED