showtime 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.
@@ -0,0 +1,4 @@
1
+ pkg
2
+ pkg/*
3
+ output
4
+ output/*
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 Lucas Mazza
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,14 @@
1
+ # Showtime
2
+
3
+ Showtime's a sinatra apps generator based on [thor](http://github.com/wycats/thor). Just run `showtime [appame]` and start hacking!
4
+
5
+ ## Installation
6
+
7
+ `gem install showtime`
8
+
9
+ ## Usage
10
+
11
+ `showtime [appname] [--heroku]`
12
+
13
+ appname folder name for the application. Otherwise uses the current folder.
14
+ --heroku builds a .gems file for heroku usage.
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+ require 'rubygems'
3
+ require 'rake'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "showtime"
9
+ gem.summary = %Q{Simple Sinatra generator}
10
+ gem.description = %Q{Application generator for simple Sinatra apps.}
11
+ gem.email = "luc4smazza@gmail.com"
12
+ gem.homepage = "http://github.com/lucasmazza/showtime"
13
+ gem.authors = ["Lucas Mazza"]
14
+ gem.add_development_dependency "rspec", ">= 1.3.0"
15
+ gem.require_path = 'lib'
16
+ gem.bindir = "bin"
17
+ gem.executables = %w(showtime)
18
+ gem.test_files.include 'spec/**/*'
19
+ gem.add_dependency "thor", "0.13.8"
20
+ end
21
+ Jeweler::GemcutterTasks.new
22
+ rescue LoadError
23
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
24
+ end
25
+
26
+ require 'spec/rake/spectask'
27
+ Spec::Rake::SpecTask.new(:spec) do |spec|
28
+ spec.libs << 'lib' << 'spec'
29
+ spec.spec_opts = %w(--format specdoc --color)
30
+ spec.spec_files = FileList['spec/**/*_spec.rb']
31
+ end
32
+
33
+ task :default => :spec
data/TODO ADDED
@@ -0,0 +1,2 @@
1
+ * Gemfile support
2
+ * Optional views generation
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- mode: ruby -*-
3
+ require 'showtime'
4
+
5
+ Showtime::Generator.start
@@ -0,0 +1,3 @@
1
+ require 'thor'
2
+ require 'thor/group'
3
+ require 'showtime/generator'
@@ -0,0 +1,37 @@
1
+ module Showtime
2
+ class Generator < Thor::Group
3
+ include Thor::Actions
4
+
5
+ argument :name, :optional => true, :default => '.'
6
+ class_options :heroku => :boolean
7
+
8
+ def self.source_root
9
+ File.join(File.dirname(__FILE__), "templates")
10
+ end
11
+
12
+ def create_application_file
13
+ template("application.rb", "#{name}/application.rb")
14
+ end
15
+ def create_rakefile
16
+ template("Rakefile", "#{name}/Rakefile")
17
+ end
18
+ def create_config_ru
19
+ template("config.ru", "#{name}/config.ru")
20
+ end
21
+
22
+ def create_lib_folder
23
+ empty_directory("#{name}/lib")
24
+ end
25
+
26
+ def create_spec_folder_and_helper
27
+ directory("spec", "#{name}/spec")
28
+ end
29
+
30
+ def create_gem_dependency_strategy
31
+ if options.heroku?
32
+ template(".gems", "#{name}/.gems")
33
+ end
34
+ end
35
+
36
+ end
37
+ end
@@ -0,0 +1 @@
1
+ sinatra
@@ -0,0 +1,9 @@
1
+ require 'spec/rake/spectask'
2
+
3
+ desc "Run all specs"
4
+ Spec::Rake::SpecTask.new do |t|
5
+ t.spec_opts = %w(--format specdoc --color)
6
+ end
7
+
8
+ task :default => :spec
9
+
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'sinatra'
3
+
4
+ get '/' do
5
+ "Hello world!"
6
+ end
@@ -0,0 +1,12 @@
1
+ require 'application'
2
+
3
+ <% unless options.heroku? %>
4
+ root_dir = File.dirname(__FILE__)
5
+
6
+ set :environment, ENV['RACK_ENV'].to_sym
7
+ set :root, root_dir
8
+ set :app_file, File.join(root_dir, 'application.rb')
9
+ disable :run
10
+ <% end %>
11
+
12
+ run Sinatra::Application
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Sinatra::Application do
4
+ context "responding to GET /" do
5
+ it "should return status code 200" do
6
+ get '/'
7
+ last_response.status.should == 200
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ require File.join(File.dirname(__FILE__), '..', 'application.rb')
2
+
3
+ require 'spec'
4
+ require 'rack/test'
5
+
6
+ Spec::Runner.configure do |config|
7
+ config.include Rack::Test::Methods
8
+ end
9
+
10
+ def app
11
+ Sinatra::Application
12
+ end
@@ -0,0 +1,55 @@
1
+ require 'spec_helper'
2
+ require 'helper_methods'
3
+
4
+ describe Showtime::Generator do
5
+ include HelperMethods
6
+
7
+ context "with empty arguments" do
8
+ before(:each) { invoke! }
9
+
10
+ it "creates the app on the working directory" do
11
+ inside(sandbox) { verify_expected_files! }
12
+ end
13
+ end
14
+
15
+ context "with a given project name" do
16
+ before(:each) do
17
+ @path = invoke!("my_awesome_app")
18
+ end
19
+
20
+ it "creates the app on the given directory" do
21
+ inside(@path) { verify_expected_files! }
22
+ end
23
+ end
24
+
25
+ context "with the --heroku option" do
26
+ before(:each) do
27
+ @path = invoke!("some_heroku_app", "--heroku")
28
+ end
29
+
30
+ it "creates the .gems file for deployment" do
31
+ inside(@path) do
32
+ verify_expected_files!
33
+ File.exists?(".gems").should be_true
34
+ end
35
+ end
36
+ end
37
+
38
+ def invoke!(path = nil,*args)
39
+ args = ([path] + args).compact
40
+ ARGV.replace(args)
41
+
42
+ inside(sandbox) do
43
+ silenced(:stdout) { Showtime::Generator.start }
44
+ end
45
+ path ? File.join(sandbox, path) : sandbox
46
+ end
47
+
48
+ def verify_expected_files!
49
+ %W(application.rb Rakefile config.ru spec/spec_helper.rb spec/application_spec.rb).each do |file|
50
+ File.exists?(file).should be_true
51
+ end
52
+ end
53
+
54
+ end
55
+
@@ -0,0 +1,21 @@
1
+ module HelperMethods
2
+
3
+ # Stealed from http://github.com/wycats/thor/blob/master/spec/spec_helper.rb#L32
4
+ def silenced(stream)
5
+ begin
6
+ stream = stream.to_s
7
+ eval "$#{stream} = StringIO.new"
8
+ yield
9
+ result = eval("$#{stream}").string
10
+ ensure
11
+ eval("$#{stream} = #{stream.upcase}")
12
+ end
13
+
14
+ result
15
+ end
16
+
17
+ def inside(path)
18
+ FileUtils.cd(path) { yield }
19
+ end
20
+
21
+ end
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'showtime'
3
+ require 'fileutils'
4
+ require 'stringio'
5
+
6
+ Spec::Runner.configure do |config|
7
+
8
+ def sandbox
9
+ "./output/showtime"
10
+ end
11
+
12
+ FileUtils.rm_rf(sandbox)
13
+ FileUtils.mkdir_p(sandbox)
14
+ end
metadata ADDED
@@ -0,0 +1,119 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: showtime
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Lucas Mazza
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-21 00:00:00 -03:00
19
+ default_executable: showtime
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 1
32
+ - 3
33
+ - 0
34
+ version: 1.3.0
35
+ type: :development
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: thor
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - "="
44
+ - !ruby/object:Gem::Version
45
+ hash: 59
46
+ segments:
47
+ - 0
48
+ - 13
49
+ - 8
50
+ version: 0.13.8
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: Application generator for simple Sinatra apps.
54
+ email: luc4smazza@gmail.com
55
+ executables:
56
+ - showtime
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - LICENSE
61
+ - README.markdown
62
+ - TODO
63
+ files:
64
+ - .gitignore
65
+ - LICENSE
66
+ - README.markdown
67
+ - Rakefile
68
+ - TODO
69
+ - VERSION
70
+ - bin/showtime
71
+ - lib/showtime.rb
72
+ - lib/showtime/generator.rb
73
+ - lib/showtime/templates/.gems
74
+ - lib/showtime/templates/Rakefile
75
+ - lib/showtime/templates/application.rb
76
+ - lib/showtime/templates/config.ru
77
+ - lib/showtime/templates/spec/application_spec.rb
78
+ - lib/showtime/templates/spec/spec_helper.rb
79
+ - spec/generator_spec.rb
80
+ - spec/helper_methods.rb
81
+ - spec/spec_helper.rb
82
+ has_rdoc: true
83
+ homepage: http://github.com/lucasmazza/showtime
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options:
88
+ - --charset=UTF-8
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ requirements: []
110
+
111
+ rubyforge_project:
112
+ rubygems_version: 1.3.7
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: Simple Sinatra generator
116
+ test_files:
117
+ - spec/generator_spec.rb
118
+ - spec/helper_methods.rb
119
+ - spec/spec_helper.rb