couch 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/couch.gemspec +7 -1
- data/lib/couch/generators.rb +2 -2
- data/lib/couch/generators/list/USAGE +8 -0
- data/lib/couch/generators/list/list_generator.rb +9 -0
- data/lib/couch/generators/list/templates/list.js +23 -0
- data/lib/couch/generators/scaffold/scaffold_generator.rb +4 -4
- data/lib/couch/generators/show/USAGE +8 -0
- data/lib/couch/generators/show/show_generator.rb +9 -0
- data/lib/couch/generators/show/templates/show.js +19 -0
- data/lib/couch/generators/view/USAGE +1 -1
- data/lib/couch/version.rb +1 -1
- metadata +8 -2
data/couch.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{couch}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Johannes J. Schmidt"]
|
@@ -45,9 +45,15 @@ Gem::Specification.new do |s|
|
|
45
45
|
"lib/couch/generators/application/templates/gitignore",
|
46
46
|
"lib/couch/generators/application/templates/validate_doc_update.js",
|
47
47
|
"lib/couch/generators/base.rb",
|
48
|
+
"lib/couch/generators/list/USAGE",
|
49
|
+
"lib/couch/generators/list/list_generator.rb",
|
50
|
+
"lib/couch/generators/list/templates/list.js",
|
48
51
|
"lib/couch/generators/named_base.rb",
|
49
52
|
"lib/couch/generators/scaffold/USAGE",
|
50
53
|
"lib/couch/generators/scaffold/scaffold_generator.rb",
|
54
|
+
"lib/couch/generators/show/USAGE",
|
55
|
+
"lib/couch/generators/show/show_generator.rb",
|
56
|
+
"lib/couch/generators/show/templates/show.js",
|
51
57
|
"lib/couch/generators/validation/USAGE",
|
52
58
|
"lib/couch/generators/validation/validation_generator.rb",
|
53
59
|
"lib/couch/generators/view/USAGE",
|
data/lib/couch/generators.rb
CHANGED
@@ -6,7 +6,7 @@ module Couch
|
|
6
6
|
# Receives a name, arguments and the behavior to invoke the generator.
|
7
7
|
# It's used as the default entry point for generate and destroy commands.
|
8
8
|
def self.invoke(name, args = ARGV, config = {})
|
9
|
-
if klass = lookup(name)
|
9
|
+
if klass = lookup(name.to_s)
|
10
10
|
args << "--help" if args.empty? && klass.arguments.any? { |a| a.required? }
|
11
11
|
klass.start(args, config)
|
12
12
|
else
|
@@ -33,7 +33,7 @@ module Couch
|
|
33
33
|
puts " -s, [--skip] # Skip files that already exist"
|
34
34
|
puts " -q, [--quiet] # Supress status output"
|
35
35
|
puts
|
36
|
-
puts "Please choose a generator below
|
36
|
+
puts "Please choose a generator below:"
|
37
37
|
puts
|
38
38
|
puts generators
|
39
39
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
function(head, req) {
|
2
|
+
provides("html", function() {
|
3
|
+
var header = '<html><head><link rel="stylesheet" href="../../stylesheets/application.css" type="text/css" media="screen" charset="utf-8"></head><body><h1>Listing <%= pluralized_model_name.humanize %></h1><table><tr>';
|
4
|
+
<% attributes.each do |attribute| %>
|
5
|
+
header += '<th><%= attribute.humanize %></th>';
|
6
|
+
<% end %>
|
7
|
+
header += '</tr>';
|
8
|
+
send(header);
|
9
|
+
|
10
|
+
var row;
|
11
|
+
while (row = getRow()) {
|
12
|
+
var body = '<tr>';
|
13
|
+
<% attributes.each do |attribute| %>
|
14
|
+
body += '<td>' + row.value['<%= attribute %>'] + '</td>';
|
15
|
+
<% end %>
|
16
|
+
body += '</tr>';
|
17
|
+
send(body);
|
18
|
+
}
|
19
|
+
|
20
|
+
var tail = '</table></body></html>';
|
21
|
+
return tail;
|
22
|
+
});
|
23
|
+
}
|
@@ -3,19 +3,19 @@ require 'couch/generators/named_base'
|
|
3
3
|
module Couch::Generators
|
4
4
|
class ScaffoldGenerator < NamedBase
|
5
5
|
def create_view_function
|
6
|
-
Couch::Generators.invoke
|
6
|
+
Couch::Generators.invoke :view, name, :behavior => behavior
|
7
7
|
end
|
8
8
|
|
9
9
|
def inject_validations
|
10
|
-
Couch::Generators.invoke
|
10
|
+
Couch::Generators.invoke :validation, [name] + attributes, :behavior => behavior
|
11
11
|
end
|
12
12
|
|
13
13
|
def create_list_function
|
14
|
-
|
14
|
+
Couch::Generators.invoke :list, [name] + attributes, :behavior => behavior
|
15
15
|
end
|
16
16
|
|
17
17
|
def create_show_function
|
18
|
-
|
18
|
+
Couch::Generators.invoke :show, [name] + attributes, :behavior => behavior
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
function(doc, req) {
|
2
|
+
var head = '<html><head><link rel="stylesheet" href="../../stylesheets/application.css" type="text/css" media="screen" charset="utf-8"></head><body>';
|
3
|
+
var body = '';
|
4
|
+
var tail = '</body></html>';
|
5
|
+
if(doc) {
|
6
|
+
<% attributes.each do |attribute| %>
|
7
|
+
if(doc['<%= attribute %>']) {
|
8
|
+
body += '<p><strong><%= attribute.humanize %></strong>: ' + doc['<%= attribute %>'] + '</p>'
|
9
|
+
}
|
10
|
+
<% end %>
|
11
|
+
return head + '<h1>Showing <%= model_name.humanize %></h1>' + body + tail;
|
12
|
+
} else {
|
13
|
+
<% attributes.each do |attribute| %>
|
14
|
+
body += '<p><label><%= attribute.humanize %></label>: <input type="text" name="<%= model_name %>[<%= attribute %>]" id="<%= model_name %>_<%= attribute %>" /></p>'
|
15
|
+
<% end %>
|
16
|
+
body += '<p><input type="submit" /></p>'
|
17
|
+
return head + '<h1>New <%= model_name.humanize %></h1>' + body + tail;
|
18
|
+
}
|
19
|
+
}
|
data/lib/couch/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 4
|
9
|
+
version: 0.0.4
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Johannes J. Schmidt
|
@@ -124,9 +124,15 @@ files:
|
|
124
124
|
- lib/couch/generators/application/templates/gitignore
|
125
125
|
- lib/couch/generators/application/templates/validate_doc_update.js
|
126
126
|
- lib/couch/generators/base.rb
|
127
|
+
- lib/couch/generators/list/USAGE
|
128
|
+
- lib/couch/generators/list/list_generator.rb
|
129
|
+
- lib/couch/generators/list/templates/list.js
|
127
130
|
- lib/couch/generators/named_base.rb
|
128
131
|
- lib/couch/generators/scaffold/USAGE
|
129
132
|
- lib/couch/generators/scaffold/scaffold_generator.rb
|
133
|
+
- lib/couch/generators/show/USAGE
|
134
|
+
- lib/couch/generators/show/show_generator.rb
|
135
|
+
- lib/couch/generators/show/templates/show.js
|
130
136
|
- lib/couch/generators/validation/USAGE
|
131
137
|
- lib/couch/generators/validation/validation_generator.rb
|
132
138
|
- lib/couch/generators/view/USAGE
|