Permalink
Browse files

Merge pull request #1 from igreulich/make_app

Make app
  • Loading branch information...
2 parents 65228cd + 9eb9929 commit 4b14a7715345e13655a51d4637ea684df7a24d51 Ian Greulich committed Apr 9, 2012
Showing with 242 additions and 99 deletions.
  1. +2 −0 Gemfile
  2. +23 −0 Rakefile
  3. +21 −11 Readme.md
  4. +151 −0 bin/sing
  5. +3 −0 lib/sing_version.rb
  6. +23 −0 sing.gemspec
  7. +0 −88 sing.rb
  8. +5 −0 sing.rdoc
  9. +14 −0 test/tc_nothing.rb
View
@@ -0,0 +1,2 @@
+source :rubygems
+gemspec
View
@@ -0,0 +1,23 @@
+require 'rake/clean'
+require 'rubygems'
+require 'rubygems/package_task'
+require 'rdoc/task'
+
+Rake::RDocTask.new do |rd|
+ rd.main = "README.rdoc"
+ rd.rdoc_files.include("README.md","lib/**/*.rb","bin/**/*")
+ rd.title = 'Sing'
+end
+
+spec = eval(File.read('sing.gemspec'))
+
+Gem::PackageTask.new(spec) do |pkg|
+end
+
+require 'rake/testtask'
+Rake::TestTask.new do |t|
+ t.libs << "test"
+ t.test_files = FileList['test/tc_*.rb']
+end
+
+task :default => :test
View
@@ -16,38 +16,48 @@ to live in:
Other examples:
- sing -p my_project
- sing --verbose my_project
+ sing -q new my_project
+ sing --verbose new my_project
### Usage
---
- sing [options] my_project
+ sing [options] command [project_name]
For help use:
- sing -h
+ sing help
+
+### Commands
+---
+Currently the commands are limited to:
+
+ sing new
+ sing help
+
+but I am open to adding more.
### Options
---
- -h, --help Displays help message
-v, --version Display the version
-q, --quiet Output as little as possible, overrides verbose
-V, --verbose Verbose output (default)
### Authors
---
- Ian Greulich
- Based on Sow by David Duggins
+Ian Greulich
+Based on Sow by David Duggins
### Copyright
---
- Copyright (c) 2012 Ian Greulich. Licensed under the MIT License:
- http://www.opensource.org/licenses/mit-license.php
- Copyright (c) 2010 David Duggins. Licensed under GPL2:
- http://www.opensource.org/licenses/GPL-2.0
+Copyright (c) 2012 Ian Greulich. Licensed under the MIT License:
+http://www.opensource.org/licenses/mit-license.php
+Copyright (c) 2010 David Duggins. Licensed under GPL2:
+http://www.opensource.org/licenses/GPL-2.0
### CHANGE LOG:
---
+#### 2012.04.09
+Refactored so basic command line structure now works ```sing new my_project```. Flags do not work, and generates incorrect files.
#### 2012.04.04
Changed Readme.md to define the scope of the next steps of the development of Sing.
#### 2010.05.14
View
151 bin/sing
@@ -0,0 +1,151 @@
+#!/usr/bin/env ruby
+# 1.9 adds realpath to resolve symlinks; 1.8 doesn't
+# have this method, so we add it so we get resolved symlinks
+# and compatibility
+unless File.respond_to? :realpath
+ class File #:nodoc:
+ def self.realpath path
+ return realpath(File.readlink(path)) if symlink?(path)
+ path
+ end
+ end
+end
+$: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
+require 'rubygems'
+require 'gli'
+require 'sing_version'
+require 'fileutils'
+require 'net/http'
+
+include GLI
+
+program_desc 'Sing will create the basic directory structure and base files for a Sinatra application.'
+
+version Sing::VERSION
+
+desc 'display the version'
+switch [:v,:version]
+
+desc 'runs with output (default)'
+switch [:V,:verbose]
+
+desc 'runs with minimal output'
+switch [:q,:quiet]
+
+# desc 'the project name'
+# default_value 'my_app'
+# arg_name 'project_name'
+# flag [:p,:project]
+
+desc 'Creates new project'
+arg_name 'project_name'
+command :new do |c|
+ # c.desc 'Describe a switch to new'
+ # c.switch :s
+
+ # c.desc 'Describe a flag to new'
+ # c.default_value 'default'
+ # c.flag :f
+ c.action do |global_options,options,args|
+###############################################################################
+# From sow.rb #
+# TODO: Clean up, test #
+###############################################################################
+ # Here you can define the directory structure that you want on the base level
+ dir_structure = ['stylesheets','javascript','images']
+ javascript_dir = 'javascript'
+
+ #TODO Need to add some code for css and maybe some automatic image stuff
+ css_dir = 'stylesheets'
+
+ # This makes sure that a variable has been passed
+ if args.length == 0
+ puts "Please enter the name of your Project"
+ exit 0
+ end
+
+ # Sets the project name
+ project = args[0]
+ FileUtils.mkdir_p project
+ puts "#{project}:CREATED"
+ FileUtils.cd project
+ # Creates a XHTML Strict Doctype Index file
+ File.open("index.html", 'w') {|file|
+ file.puts "<!DOCTYPE html>"
+ file.puts "<html>"
+ file.puts " <head>"
+ file.puts " <title></title>"
+ file.puts " </head>"
+ file.puts " <body>"
+ file.puts " "
+ file.puts " </body>"
+ file.puts "</html>"}
+ puts "index.html........done"
+
+ # Runs through the array defined in options to create the Directory Structure.
+
+ dir_structure.each do |i|
+ FileUtils.mkdir_p i
+ puts "#{i}:CREATED"
+ end
+ #Here we load the base CSS file
+ File.open("stylesheets/style.css", 'w'){ |file|
+ file.puts "# Insert style Here"
+ }
+ puts "style.css.....done"
+ #this is where we load the JavaScript Libraries into the JavaScript folder
+ FileUtils.cd javascript_dir
+ Net::HTTP.start("script.aculo.us") { |http|
+ resp = http.get("/dist/scriptaculous-js-1.8.3.tar.bz2")
+ open("scriptaculous-js-1.8.3.tar.bz2", "wb") { |file|
+ file.write(resp.body)
+ }
+ }
+ puts "Prototype.........Downloaded"
+ puts "Scriptaculous.....Downloaded"
+
+ # TODO Need to add some code to extract the prototype/scriptaculous libraries
+
+ Net::HTTP.start("code.jquery.com") { |http|
+ resp = http.get("/jquery-1.4.2.js")
+ open("jquery-1.4.2.js", "wb") { |file|
+ file.write(resp.body)
+ }
+ }
+ puts "JQuery............Downloaded"
+
+ Net::HTTP.start("mootools.net") { |http|
+ resp = http.get("/download/get/mootools-1.2.4-core-nc.js")
+ open("mootools-1.2.4-core-nc.js", "wb") { |file|
+ file.write(resp.body)
+ }
+ }
+ puts "MooTools..........Downloaded"
+###############################################################################
+# END: From sow.rb #
+###############################################################################
+ end
+end
+
+pre do |global,command,options,args|
+ # Pre logic here
+ # Return true to proceed; false to abort and not call the
+ # chosen command
+ # Use skips_pre before a command to skip this block
+ # on that command only
+ true
+end
+
+post do |global,command,options,args|
+ # Post logic here
+ # Use skips_post before a command to skip this
+ # block on that command only
+end
+
+on_error do |exception|
+ # Error logic here
+ # return false to skip default error handling
+ true
+end
+
+exit GLI.run(ARGV)
View
@@ -0,0 +1,3 @@
+module Sing
+ VERSION = '0.0.1'
+end
View
@@ -0,0 +1,23 @@
+# Ensure we require the local version and not one we might have installed already
+require File.join([File.dirname(__FILE__),'lib','sing_version.rb'])
+spec = Gem::Specification.new do |s|
+ s.name = 'sing'
+ s.version = Sing::VERSION
+ s.author = 'Ian Greulich'
+ s.email = 'ian.greulich@gmail.com'
+ s.homepage = 'http://igreulich.github.com/sing/'
+ s.platform = Gem::Platform::RUBY
+ s.summary = 'Sing will create the basic directory structure and base files for a Sinatra webapp. It creates your Gemfile (containing haml, sass, and compass), config.ru, index.haml, application.scss, and downloads jquery for you.'
+# Add your other files here if you make them
+ s.files = %w(
+bin/sing
+ )
+ s.require_paths << 'lib'
+ s.has_rdoc = true
+ s.extra_rdoc_files = ['README.rdoc','sing.rdoc']
+ s.rdoc_options << '--title' << 'sing' << '--main' << 'README.rdoc' << '-ri'
+ s.bindir = 'bin'
+ s.executables << 'sing'
+ s.add_development_dependency('rake')
+ s.add_development_dependency('rdoc')
+end
View
88 sing.rb
@@ -1,88 +0,0 @@
-#
-# Basic Ruby script to create a new project for basic web development
-#
-# Author: David Duggins
-# Email: weatheredwatcher@gmail.com
-#
-# Created: 5/4/2010
-# License: GPL2
-#
-
-require 'fileutils'
-require 'net/http'
-#OPTIONS
-
-# Here you can define the directory structure that you want on the base level
-dir_structure = ['stylesheets','javascript','images','db']
-javascript_dir = 'javascript'
-
-#TODO Need to add some code for css and maybe some automatic image stuff
-css_dir = 'stylesheets'
-
-
-# This makes sure that a variable has been passed
-if ARGV.length == 0
- puts "Please enter the name of your Project"
- exit 0
-end
-
-# Sets the project name
-project = ARGV[0]
-FileUtils.mkdir_p project
-puts "#{project}:CREATED"
-FileUtils.cd project
-# Creates a XHTML Strict Doctype Index file
-File.open("index.html", 'w') {|file|
-file.puts "<!DOCTYPE html>"
-file.puts "<html>"
-file.puts " <head>"
-file.puts " <title></title>"
-file.puts " </head>"
-file.puts " <body>"
-file.puts " "
-file.puts " </body>"
-file.puts "</html>"}
-puts "index.html........done"
-
-
-
-# Runs through the array defined in options to create the Directory Structure.
-
-dir_structure.each do |i|
- FileUtils.mkdir_p i
- puts "#{i}:CREATED"
-end
-#Here we load the base CSS file
-File.open("stylesheets/style.css", 'w'){ |file|
-file.puts "# Insert style Here"
-}
-puts "style.css.....done"
-#this is where we load the JavaScript Libraries into the JavaScript folder
-FileUtils.cd javascript_dir
-Net::HTTP.start("script.aculo.us") { |http|
- resp = http.get("/dist/scriptaculous-js-1.8.3.tar.bz2")
- open("scriptaculous-js-1.8.3.tar.bz2", "wb") { |file|
- file.write(resp.body)
- }
-}
-puts "Prototype.........Downloaded"
-puts "Scriptaculous.....Downloaded"
-=begin
- TODO Need to add some code to extract the prototype/scriptaculous libraries
-=end
-Net::HTTP.start("code.jquery.com") { |http|
- resp = http.get("/jquery-1.4.2.js")
- open("jquery-1.4.2.js", "wb") { |file|
- file.write(resp.body)
- }
-}
-puts "JQuery............Downloaded"
-
-Net::HTTP.start("mootools.net") { |http|
- resp = http.get("/download/get/mootools-1.2.4-core-nc.js")
- open("mootools-1.2.4-core-nc.js", "wb") { |file|
- file.write(resp.body)
- }
-}
-puts "MooTools..........Downloaded"
-
View
@@ -0,0 +1,5 @@
+= sing
+
+Generate this with
+ sing rdoc
+After you have described your command line interface
View
@@ -0,0 +1,14 @@
+require 'test/unit'
+
+class TC_testNothing < Test::Unit::TestCase
+
+ def setup
+ end
+
+ def teardown
+ end
+
+ def test_the_truth
+ assert true
+ end
+end

0 comments on commit 4b14a77

Please sign in to comment.