chinstrap 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ vendor/ruby
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in chinstrap.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Brandon Weiss
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,25 @@
1
+ # Chinstrap
2
+
3
+ TL;DR `rails new` for Sinatra.
4
+
5
+ Manually building out the skeleton for larger, well-organized Sinatra apps sucks. There's no reason it shouldn't be as simple as `chinstrap new APP_NAME`.
6
+
7
+ ## Installation
8
+
9
+ $ gem install chinstrap
10
+
11
+ ## Usage
12
+
13
+ $ chinstrap new APP_NAME
14
+
15
+ ## Credits
16
+
17
+ Most of the credit goes to the creators of Thor, and other projects (Bundler, Foreman, etc.) that use it for skeleton generation so I could see the best patterns to use.
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
@@ -0,0 +1,3 @@
1
+ #! /usr/bin/env rake
2
+
3
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require "chinstrap"
6
+
7
+ Chinstrap::CLI.start
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path("../lib/chinstrap/version", __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Brandon Weiss"]
6
+ gem.email = ["brandon@anti-pattern.com"]
7
+ gem.description = %q{Manually building out the skeleton for larger, well-organized Sinatra apps sucks. There's no reason it shouldn't be as simple as 'chinstrap new APP_NAME'.}
8
+ gem.summary = %q{'rails new' for Sinatra}
9
+ gem.homepage = "http://github.com/brandonweiss/chinstrap"
10
+
11
+ gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
12
+ gem.files = `git ls-files`.split("\n")
13
+ gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
14
+ gem.name = "chinstrap"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Chinstrap::VERSION
17
+
18
+ gem.add_dependency "thor", "~> 0.14.6"
19
+ end
@@ -0,0 +1,45 @@
1
+ require "chinstrap/version"
2
+ require "thor"
3
+
4
+ module Chinstrap
5
+ class CLI < Thor
6
+
7
+ include Thor::Actions
8
+
9
+ desc "new [APP_NAME]", "Create a new skeleton for a Sinatra application named [APP_NAME]"
10
+
11
+ def new(name)
12
+ name = name.chomp("/")
13
+ target = File.join(Dir.pwd, name)
14
+
15
+ constant_name = name.split('_').map{ |p| p[0..0].upcase + p[1..-1] }.join
16
+ constant_name = constant_name.split('-').map{ |q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
17
+
18
+ options = {
19
+ name: name,
20
+ constant_name: constant_name
21
+ }
22
+
23
+ empty_directory target
24
+
25
+ empty_directory File.join(target, "app/models")
26
+ template File.join("app/routes/main.rb"), File.join(target, "app/routes/main.rb"), options
27
+ empty_directory File.join(target, "app/views")
28
+ template File.join("app/app.rb"), File.join(target, "app/#{name}.rb"), options
29
+ template File.join("config/environment.rb"), File.join(target, "config/environment.rb"), options
30
+ empty_directory File.join(target, "lib")
31
+ template File.join("test/test_helper.rb"), File.join(target, "test/test_helper.rb"), options
32
+ empty_directory File.join(target, "tmp")
33
+ empty_directory File.join(target, "vendor")
34
+ template File.join("gitignore"), File.join(target, ".gitignore"), options
35
+ template File.join("config.ru"), File.join(target, "config.ru"), options
36
+ template File.join("Gemfile"), File.join(target, "Gemfile"), options
37
+ template File.join("Rakefile"), File.join(target, "Rakefile"), options
38
+ end
39
+
40
+ def self.source_root
41
+ File.expand_path(File.join(File.dirname(__FILE__), "chinstrap/templates"))
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "sinatra", "~> 1.3.2"
4
+
5
+ group :test do
6
+ gem "turn"
7
+ gem "minitest"
8
+ end
9
+
10
+ group :development, :test do
11
+ gem "ruby-debug19", require: "ruby-debug"
12
+ end
@@ -0,0 +1,8 @@
1
+ require "rake/testtask"
2
+
3
+ task :default => :test
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.pattern = "test/**/*_test.rb"
7
+ t.verbose = false
8
+ end
@@ -0,0 +1,7 @@
1
+ class <%= config[:constant_name] %> < Sinatra::Base
2
+
3
+ enable :sessions
4
+
5
+ end
6
+
7
+ require "./routes/main"
@@ -0,0 +1,7 @@
1
+ class <%= config[:constant_name] %> < Sinatra::Base
2
+
3
+ get "/" do
4
+ "Hello world!"
5
+ end
6
+
7
+ end
@@ -0,0 +1,6 @@
1
+ require "./config/environment"
2
+ require "./app/<%= config[:name] %>"
3
+
4
+ map "/" do
5
+ run <%= config[:constant_name] %>
6
+ end
@@ -0,0 +1,5 @@
1
+ ENV["RACK_ENV"] ||= "development"
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+ Bundler.require(:default, ENV["RACK_ENV"].to_sym)
@@ -0,0 +1,2 @@
1
+ .bundle/
2
+ vendor/ruby
@@ -0,0 +1 @@
1
+ ENV["RACK_ENV"] = "test"
@@ -0,0 +1,3 @@
1
+ module Chinstrap
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chinstrap
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Brandon Weiss
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-02-22 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thor
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: 0.14.6
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: Manually building out the skeleton for larger, well-organized Sinatra apps sucks. There's no reason it shouldn't be as simple as 'chinstrap new APP_NAME'.
27
+ email:
28
+ - brandon@anti-pattern.com
29
+ executables:
30
+ - chinstrap
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - .gitignore
37
+ - Gemfile
38
+ - LICENSE
39
+ - README.md
40
+ - Rakefile
41
+ - bin/chinstrap
42
+ - chinstrap.gemspec
43
+ - lib/chinstrap.rb
44
+ - lib/chinstrap/templates/Gemfile
45
+ - lib/chinstrap/templates/Rakefile
46
+ - lib/chinstrap/templates/app/app.rb
47
+ - lib/chinstrap/templates/app/routes/main.rb
48
+ - lib/chinstrap/templates/config.ru
49
+ - lib/chinstrap/templates/config/environment.rb
50
+ - lib/chinstrap/templates/gitignore
51
+ - lib/chinstrap/templates/test/test_helper.rb
52
+ - lib/chinstrap/version.rb
53
+ homepage: http://github.com/brandonweiss/chinstrap
54
+ licenses: []
55
+
56
+ post_install_message:
57
+ rdoc_options: []
58
+
59
+ require_paths:
60
+ - lib
61
+ required_ruby_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ requirements: []
74
+
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.17
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: "'rails new' for Sinatra"
80
+ test_files: []
81
+