sing 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/sing +171 -0
  2. data/lib/sing_version.rb +3 -0
  3. metadata +99 -0
data/bin/sing ADDED
@@ -0,0 +1,171 @@
1
+ #!/usr/bin/env ruby
2
+ # 1.9 adds realpath to resolve symlinks; 1.8 doesn't
3
+ # have this method, so we add it so we get resolved symlinks
4
+ # and compatibility
5
+ unless File.respond_to? :realpath
6
+ class File #:nodoc:
7
+ def self.realpath path
8
+ return realpath(File.readlink(path)) if symlink?(path)
9
+ path
10
+ end
11
+ end
12
+ end
13
+ $: << File.expand_path(File.dirname(File.realpath(__FILE__)) + '/../lib')
14
+ require 'rubygems'
15
+ require 'gli'
16
+ require 'sing_version'
17
+ require 'fileutils'
18
+ require 'net/http'
19
+
20
+ include GLI
21
+
22
+ program_desc 'Sing will create the basic directory structure and base files for a Sinatra application.'
23
+
24
+ version Sing::VERSION
25
+
26
+ # desc 'display the version'
27
+ # switch [:v,:version]
28
+
29
+ # desc 'runs with output (default)'
30
+ # switch [:V,:verbose]
31
+
32
+ # desc 'runs with minimal output'
33
+ # switch [:q,:quiet]
34
+
35
+ # desc 'the project name'
36
+ # default_value 'my_app'
37
+ # arg_name 'project_name'
38
+ # flag [:p,:project]
39
+
40
+ desc 'Creates new project'
41
+ arg_name 'project_name'
42
+ command :new do |c|
43
+ # c.desc 'Describe a switch to new'
44
+ # c.switch :s
45
+
46
+ # c.desc 'Describe a flag to new'
47
+ # c.default_value 'default'
48
+ # c.flag :f
49
+ c.action do |global_options,options,args|
50
+ # Define the directory structure that you want
51
+ dir_structure = ['public/stylesheets','public/javascripts','public/images', 'views']
52
+ javascript_dir = 'public/javascripts'
53
+ css_dir = 'public/stylesheets'
54
+
55
+ # This makes sure that a project name is present
56
+ if args.length == 0
57
+ puts "Please enter the name of your project"
58
+ exit 1
59
+ end
60
+
61
+ # Sets the project name and creates the main directory
62
+ project = args[0]
63
+ FileUtils.mkdir_p project
64
+ puts "created - /#{project}"
65
+
66
+ # Move into the main directory
67
+ FileUtils.cd project
68
+
69
+ # Creates app.rb, config.ru, gemfile, README.md
70
+ File.open("./app.rb", 'w') do |file|
71
+ file.puts "require 'rubygems'\nrequire 'sinatra'\nrequire 'haml'\n\nget '/' do\n\t@title = 'Hello World'\n\thaml :index\nend"
72
+ end
73
+ puts "\ncreated - app.rb"
74
+
75
+ File.open("./config.ru", 'w') do |file|
76
+ file.puts "require './app'\nrun Sinatra::Application"
77
+ end
78
+ puts "created - config.ru"
79
+
80
+ File.open("./Gemfile", 'w') do |file|
81
+ file.puts "source 'http://rubygems.org'\n\ngem 'sinatra'\ngem 'haml'\ngem 'activesupport'"
82
+ end
83
+ puts "created - Gemfile"
84
+
85
+ File.open("./README.md", 'w') do |file|
86
+ file.puts "This is your README. Use markdown to create it."
87
+ end
88
+ puts "created - README.md"
89
+
90
+ puts "\n"
91
+
92
+ # Creates the directory structure
93
+ dir_structure.each do |dir|
94
+ FileUtils.mkdir_p dir
95
+ puts "created - /#{dir}"
96
+ end
97
+
98
+ puts "\n"
99
+
100
+ #creates layout.haml, and index.haml (includes jquery, and bootstrap css, responsive css, and all plugins)
101
+ File.open("./views/layout.haml", 'w') do |file|
102
+ file.puts "!!!"
103
+ file.puts "%html"
104
+ file.puts " %head"
105
+ file.puts " %title= @title"
106
+ file.puts ""
107
+ file.puts " %meta{:charset => 'utf-8'}"
108
+ file.puts ""
109
+ file.puts " %script{:src => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'}"
110
+ file.puts " %script{:src => 'http://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/2.0.2/bootstrap.min.js'}"
111
+ file.puts " %script{:src => 'javascripts/application.js'}"
112
+ file.puts ""
113
+ file.puts " %link{:type => 'text/css', :rel => 'stylesheet', :media => 'screen', :href => 'http://twitter.github.com/bootstrap/assets/css/bootstrap.css'}"
114
+ file.puts " %link{:type => 'text/css', :rel => 'stylesheet', :media => 'screen', :href => 'http://twitter.github.com/bootstrap/assets/css/bootstrap-responsive.css'}"
115
+ file.puts " %link{:type => 'text/css', :rel => 'stylesheet', :media => 'screen', :href => 'stylesheets/application.css'}"
116
+ file.puts " %body{:style => 'padding-top: 60px'}"
117
+ file.puts ""
118
+ file.puts " = yield"
119
+ file.puts ""
120
+ file.puts " .container"
121
+ file.puts " %hr"
122
+ end
123
+ puts "created - layout.haml"
124
+
125
+ File.open("./views/index.haml", 'w') do |file|
126
+ file.puts ".navbar.navbar-fixed-top"
127
+ file.puts " .navbar-inner"
128
+ file.puts " .container"
129
+ file.puts " %a.brand{:href => '/'}"
130
+ file.puts " Hello World!"
131
+ file.puts ".container"
132
+ file.puts " %h2.center Hello World"
133
+ end
134
+ puts "created - index.haml"
135
+
136
+ # Create the application.css file
137
+ File.open("./public/stylesheets/application.css", 'w') do |file|
138
+ file.puts ".center{\n\ttext-align: center;\n}\n\n.right{\n\tfloat: right;\n}\n\n.left{\n\tfloat: left;\n}\n\n.clear{\n\tclear: both;\n}"
139
+ end
140
+ puts "created - application.css"
141
+
142
+ # Creates application.js file
143
+ File.open("./public/javascripts/application.js", 'w') do |file|
144
+ file.puts "// Application javascript goes here"
145
+ end
146
+ puts "created - application.js"
147
+ end
148
+ end
149
+
150
+ pre do |global,command,options,args|
151
+ # Pre logic here
152
+ # Return true to proceed; false to abort and not call the
153
+ # chosen command
154
+ # Use skips_pre before a command to skip this block
155
+ # on that command only
156
+ true
157
+ end
158
+
159
+ post do |global,command,options,args|
160
+ # Post logic here
161
+ # Use skips_post before a command to skip this
162
+ # block on that command only
163
+ end
164
+
165
+ on_error do |exception|
166
+ # Error logic here
167
+ # return false to skip default error handling
168
+ true
169
+ end
170
+
171
+ exit GLI.run(ARGV)
@@ -0,0 +1,3 @@
1
+ module Sing
2
+ VERSION = '0.0.1'
3
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sing
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ian Greulich
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-04-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: gli
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Sing will create the basic directory structure and base files for a Sinatra
63
+ webapp. It creates your Gemfile (containing haml, sinatra, and rubygems), config.ru,
64
+ index.haml, layout.haml (includes Twitter Bootstrap, and the current jQuery), application.css.
65
+ email: ian.greulich@gmail.com
66
+ executables:
67
+ - sing
68
+ extensions: []
69
+ extra_rdoc_files: []
70
+ files:
71
+ - bin/sing
72
+ - lib/sing_version.rb
73
+ homepage: http://igreulich.github.com/sing/
74
+ licenses: []
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 1.8.21
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Sing will create the basic directory structure and base files for a Sinatra
98
+ webapp
99
+ test_files: []