Permalink
Browse files

Almost working generate and thor CLI rewrite

  • Loading branch information...
quirkey committed Sep 22, 2010
1 parent b6ac2c7 commit 2afc197c5875161d1e9bdd13851eedcaa2e63c29
View
@@ -2,4 +2,4 @@
require 'soca'
-Soca::CLI.new(ARGV).run
+Soca::CLI.start
View
@@ -37,16 +37,37 @@ def initialize(*)
logger.level = Logger::DEBUG
options[:quiet] = false
end
+ self.source_paths << File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
end
- desc 'init', 'turns any directory into a soca app, generating a config.js'
- def init
-
+ method_option "appname",
+ :type => :string,
+ :banner => "set the name of the application for templating. defaults to the basename of the appdir"
+
+ desc 'init [APPDIR]', 'turns any directory into a soca app, generating a config.js'
+ def init(to = nil)
+ self.appdir = to if to
+ self.destination_root = appdir
+ template('config.js.erb', 'config.js')
+ template('couchapprc.erb', '.couchapprc')
end
- desc 'generate [APPDIR]', 'generates the basic soca app structure'
- def generate(appdir = nil)
+ method_option "appname",
+ :type => :string,
+ :banner => "set the name of the application for templating. defaults to the basename of the appdir"
+ desc 'generate [APPDIR]', 'generates the basic soca app structure'
+ def generate(to = nil)
+ self.appdir = to if to
+ self.destination_root = appdir
+
+ directory('hooks')
+ directory('js')
+ directory('css')
+ template('Jimfile')
+ template('index.html.erb', 'index.html.erb')
+ template('config.js.erb', 'config.js')
+ template('couchapprc.erb', '.couchapprc')
end
desc 'url [ENV]', 'outputs the app url for the ENV'
@@ -66,13 +87,12 @@ def push(env = 'default')
desc 'build [ENV]', 'builds the app as a ruby hash and outputs it to stdout'
def build(env = 'default')
- require 'pp'
- pp pusher(env).build
+ say pusher(env).build
end
desc 'compact [ENV]', 'runs a DB compact against the couchdb for ENV'
def compact(env = 'default')
- pusher(env).compact
+ pusher(env).compact!
end
desc 'json [ENV]', 'builds and then outputs the design doc JSON for the app'
@@ -114,6 +134,10 @@ def autopush(env = 'default')
end
private
+ def appname
+ @appname = options[:name] || File.basename(appdir)
+ end
+
def logger
Soca.logger
end
View
@@ -41,9 +41,13 @@ def json
end
def db_url
- env_config = config['couchapprc']['env'][env]
- raise "No such env: #{env}" unless env_config && env_config['db']
- env_config['db']
+ if env =~ /^http\:\/\// # the env is actual a db_url
+ env
+ else
+ env_config = config['couchapprc']['env'][env]
+ raise "No such env: #{env}" unless env_config && env_config['db']
+ env_config['db']
+ end
end
def push_url
@@ -82,7 +86,7 @@ def push!
run_hook_file!(:after_push)
end
- def compact
+ def compact!
logger.debug "compacting #{db_url}"
post!("#{db_url}/_compact")
end
View
@@ -0,0 +1,11 @@
+// bundled_path: js/default.js
+// compressed_path: js/production.js
+// vendor_dir: js/vendor
+
+/ start adding your requirements below:
+
+sha1
+jquery 1.4.2
+jquery.couch 0.11
+sammy 0.6.1
+js/app
@@ -0,0 +1,6 @@
+{
+ "id": "<%= appdir %>",
+ "mapDirectories": {
+ "config.js": ""
+ }
+}
@@ -0,0 +1,10 @@
+{
+ "env": {
+ "default": {
+ "db": "http://admin:admin@localhost:5984/<%= appname %>"
+ },
+ "production": {
+ "db": ""http://admin:admin@localhost:5984/<%= appname %>"
+ }
+ }
+}
@@ -0,0 +1 @@
+body {}
@@ -0,0 +1 @@
+# any pre build scripting should go here
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <title><%= appname %></title>
+
+ <link href="css/screen.css" media="screen, projection" rel="stylesheet" type="text/css" />
+ <link href="css/print.css" media="print" rel="stylesheet" type="text/css" />
+ <!--[if lt IE 8]>
+ <link href="css/ie.css" media="screen, projection" rel="stylesheet" type="text/css" />
+ <![endif]-->
+</head>
+<body>
+ <div id="container">
+ </div>
+ <script src="js/default.js" type="text/javascript" charset="utf-8"></script>
+</body>
+</html>
@@ -0,0 +1,12 @@
+(function($) {
+
+ var app = $.sammy('#container', function() {
+
+
+ });
+
+ $(function() {
+ app.run();
+ });
+
+})(jQuery);
Oops, something went wrong.

0 comments on commit 2afc197

Please sign in to comment.