corneal 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a2cdf2bb2fadeaf207dbc3d518e4cac9d50cce12
4
+ data.tar.gz: 0300feb8335b16ab9dbe68df41294fed4e30278e
5
+ SHA512:
6
+ metadata.gz: d66d8e5d54bfd7e0c031e00f4d57b84e5181da06221bb00c115bc15ab589d0b2cf57a5f7e57f5ddbb5aaaf2c51fd4779dbf2ce02d3e0e0c2c524b928a881573c
7
+ data.tar.gz: 68909f65ce61e1374628b895bb67f070c8b5a19f6990d8e62adadda8887844c9e73196d14ef9e306f86a10574f6544e31b6d37b0287f5f90512e08b0c5b8ee0a
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org/'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem "rake", "~> 10.0"
7
+ gem "fakefs", "~> 0.4"
8
+ end
@@ -0,0 +1,23 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ hazel (0.0.8)
5
+ thor (~> 0.18)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ fakefs (0.4.3)
11
+ minitest (5.2.0)
12
+ rake (10.1.1)
13
+ thor (0.18.1)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ bundler (~> 1.5.1)
20
+ fakefs (~> 0.4)
21
+ hazel!
22
+ minitest (~> 5.2)
23
+ rake (~> 10.0)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2016 Brian Emory
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,104 @@
1
+ ![Corneal](http://thebrianemory.github.io/corneal/images/corneal-small.png)
2
+
3
+ ## Why this exists
4
+
5
+ When I was creating my first major Sinatra project, [Cook This Way](https://github.com/thebrianemory/cook-this-way), while doing [Learn Verified](https://learn.co/with/thebrianemory), I was looking for a way to build a Sinatra skeleton similar to running
6
+
7
+ rails new app-name
8
+
9
+ [Hazel](https://github.com/c7/hazel) was the closest thing I could find and this gem is based largely off of it. While it did provide a pretty good initial setup, I still had to tweak some things. The views were sitting in the root directory while I wanted them to reside in an app folder along with my models and controllers. There was also no environment.rb in the config folder as I had become accustom to having.
10
+
11
+ I also wanted to create a gem for future Learn students so they could easily get started building their projects. Although built with them in mind, this can get you off and running with any Sinatra app.
12
+
13
+ Install the gem, run `corneal app-name`, run `bundle`, and you're all set! You can start up your server with `shotgun` and verify everything is working. It is as simple as that.
14
+
15
+ It uses a file structure similar to what you would see with Rails.
16
+
17
+ Directory structure:
18
+ ```
19
+ ├── config.ru
20
+ ├── Gemfile
21
+ ├── Gemfile.lock
22
+ ├── Rakefile
23
+ ├── README
24
+ ├── app
25
+ │ ├── controllers
26
+ │ │ └── application_controller.rb
27
+ │ ├── models
28
+ │ └── views
29
+ │ ├── layout.erb
30
+ │ └── welcome.erb
31
+ ├── config
32
+ │ ├── initializers
33
+ │ └── environment.rb
34
+ ├── db
35
+ │ ├── development.sqlite
36
+ │ ├── schema.rb
37
+ │ └── test.sqlite
38
+ ├── lib
39
+ │ └── .gitkeep
40
+ └── public
41
+ | ├── images
42
+ | ├── javascripts
43
+ | └── stylesheets
44
+ | └── main.css
45
+ └── spec
46
+ ├── application_controller_spec.rb
47
+ └── spec_helper.rb
48
+ ```
49
+
50
+
51
+ ## Installation
52
+
53
+ gem install corneal
54
+
55
+ ## Configuration
56
+
57
+ * `--rvm` Create .ruby-version (ruby-2.1.0) and .ruby-gemset
58
+ * `--bundle` Run bundle after generating the app
59
+ * `--git` Initialize a Git repository
60
+
61
+ ## Example
62
+
63
+ To generate your app
64
+
65
+ corneal app-name
66
+
67
+ After Corneal is done generating an app, you can `cd` into your apps
68
+ directory and `shotgun`
69
+
70
+ cd app-name; shotgun
71
+
72
+ Visit [http://localhost:9393/](http://localhost:9393/) to verify your app is running.
73
+
74
+ You can verify by running the included test
75
+
76
+ rspec
77
+
78
+
79
+ ## Contributing
80
+
81
+ Bug reports and pull requests are welcome on GitHub at https://github.com/thebrianemory/corneal This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
82
+
83
+ ## License
84
+
85
+ Copyright (c) 2016 Brian Emory
86
+
87
+ Permission is hereby granted, free of charge, to any person obtaining
88
+ a copy of this software and associated documentation files (the
89
+ "Software"), to deal in the Software without restriction, including
90
+ without limitation the rights to use, copy, modify, merge, publish,
91
+ distribute, sublicense, and/or sell copies of the Software, and to
92
+ permit persons to whom the Software is furnished to do so, subject to
93
+ the following conditions:
94
+
95
+ The above copyright notice and this permission notice shall be
96
+ included in all copies or substantial portions of the Software.
97
+
98
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
99
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
100
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
101
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
102
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
103
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
104
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,11 @@
1
+ # encoding: utf-8
2
+
3
+ require "rake/testtask"
4
+ require "bundler/gem_tasks"
5
+
6
+ Rake::TestTask.new(:spec) do |test|
7
+ test.libs << 'lib' << 'spec'
8
+ test.pattern = 'spec/**/*_spec.rb'
9
+ end
10
+
11
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), "..", "lib")))
3
+
4
+ require "corneal/cli"
5
+
6
+ Corneal::CLI.start
@@ -0,0 +1,129 @@
1
+ # encoding: UTF-8
2
+
3
+ require "extensions/string"
4
+ require "thor/group"
5
+
6
+ module Corneal
7
+ class CLI < Thor::Group
8
+ include Thor::Actions
9
+
10
+ desc "Creates a new Sinatra application"
11
+ argument :name, :type => :string, :desc => "The name of the new application"
12
+ class_option :capistrano, :type => :boolean, :desc => "Include Capistrano configuration"
13
+ class_option :database, :aliases => "-d", :default => "", :desc => "The type of database to use"
14
+ class_option :redis, :type => :boolean, :desc => "Include Redis configuration"
15
+ class_option :rvm, :type => :boolean, :desc => "Create .ruby-version (ruby-2.1.0) and .ruby-gemset"
16
+ class_option :bundle, :type => :boolean, :desc => "Run bundle after generating the app"
17
+ class_option :git, :type => :boolean, :desc => "Initialize a Git repository"
18
+
19
+ # Creates instance variables from options passed to corneal.
20
+ def setup
21
+ @app_path = name.directory_name
22
+ @name = name.file_name
23
+
24
+ options.each do |key, value|
25
+ instance_variable_set "@#{key.to_s}".to_sym, value
26
+ end
27
+ end
28
+
29
+ def self.source_root
30
+ File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "templates"))
31
+ end
32
+
33
+ # Create empty directories
34
+ def create_empty_directories
35
+ %w{config/initializers lib spec}.each do |dir|
36
+ empty_directory File.join(@app_path, dir)
37
+ end
38
+
39
+ empty_directory File.join(@app_path, 'db/migrate') unless @database.empty?
40
+
41
+ create_file File.join(@app_path, "lib", ".gitkeep")
42
+ template "config/environment.rb", File.join(@app_path, "config/environment.rb")
43
+ end
44
+
45
+ def create_public_directory
46
+ %w{public/stylesheets public/javascripts public/images}.each do |dir|
47
+ directory dir, File.join(@app_path, dir)
48
+ end
49
+
50
+ template "public/favicon.ico", File.join(@app_path, "public/favicon.ico")
51
+ end
52
+
53
+ def create_app_directory
54
+ %w{app/controllers app/models app/views}.each do |dir|
55
+ directory dir, File.join(@app_path, dir)
56
+ end
57
+ end
58
+
59
+ def create_app_spec
60
+ template "spec/application_controller_spec.rb", File.join(@app_path, "spec/application_controller_spec.rb")
61
+ end
62
+
63
+ def create_spec_helper
64
+ template "spec/spec_helper.rb", File.join(@app_path, "spec/spec_helper.rb")
65
+ end
66
+
67
+ def create_config
68
+ template "config.ru", File.join(@app_path, "config.ru")
69
+ end
70
+
71
+ def create_gemfile
72
+ template "Gemfile", File.join(@app_path, "Gemfile")
73
+ end
74
+
75
+ def create_rakefile
76
+ template "Rakefile", File.join(@app_path, "Rakefile")
77
+ end
78
+
79
+ def create_readme
80
+ copy_file "README.md", File.join(@app_path, "README.md")
81
+ end
82
+
83
+ def create_db_config
84
+ template("config/db.yml", File.join(@app_path, "config/db.yml")) unless @database.empty?
85
+ end
86
+
87
+ def create_database_initializer
88
+ template("config/initializers/database.rb", File.join(@app_path, "config/initializers/database.rb")) unless @database.empty?
89
+ end
90
+
91
+ def create_redis_config
92
+ copy_file("config/redis.yml", File.join(@app_path, "config/redis.yml")) if @redis
93
+ end
94
+
95
+ def create_redis_initializer
96
+ template("config/initializers/redis.rb", File.join(@app_path, "config/initializers/redis.rb")) if @redis
97
+ end
98
+
99
+ def create_capistrano_config
100
+ if @capistrano
101
+ inside(@app_path) do
102
+ run('cap install')
103
+ end
104
+ end
105
+ end
106
+
107
+ def create_rvm_gemset
108
+ if @rvm
109
+ create_file(File.join(@app_path, '.ruby-version'), 'ruby-2.1.0')
110
+ create_file(File.join(@app_path, '.ruby-gemset'), @app_path)
111
+
112
+ @bundle = false
113
+ puts "You need to run 'bundle install' manually."
114
+ end
115
+ end
116
+
117
+ def initialize_git_repo
118
+ inside(@app_path) do
119
+ run('git init .') if @git
120
+ end
121
+ end
122
+
123
+ def install_dependencies
124
+ inside(@app_path) do
125
+ run('bundle') if @bundle
126
+ end
127
+ end
128
+ end
129
+ end
@@ -0,0 +1,9 @@
1
+ module Corneal
2
+ module VERSION
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ TINY = 0
6
+
7
+ STRING = [MAJOR, MINOR, TINY].join('.')
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ module Corneal
2
+ module Extensions
3
+ module String
4
+ def camel_case
5
+ return self.gsub(/^./) { |l| l.capitalize } if !match(/[_-]/)
6
+ altered_self = self.downcase.capitalize
7
+ altered_self.scan(/[_-][a-zA-Z]/).each do |match|
8
+ altered_self.gsub!(match, match[1].upcase)
9
+ end
10
+
11
+ altered_self
12
+ end
13
+
14
+ def camel_case!
15
+ self.replace camel_case
16
+ end
17
+
18
+ def directory_name
19
+ self.downcase.gsub(/[^a-z|\-|\_]/, '')
20
+ end
21
+
22
+ def file_name
23
+ self.gsub(/[\-| ]/, '_').
24
+ gsub(/([A-Z]+|[A-Z][a-z])/) { |x| "_#{x}" }.
25
+ sub(/^_/, "").
26
+ gsub(/_{2,}+/, "_").
27
+ downcase
28
+ end
29
+
30
+ def file_name!
31
+ self.replace file_name
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ String.send(:include, Corneal::Extensions::String)
@@ -0,0 +1,20 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'sinatra'
4
+ gem 'activerecord', :require => 'active_record'
5
+ gem 'sinatra-activerecord', :require => 'sinatra/activerecord'
6
+ gem 'rake'
7
+ gem 'require_all'
8
+ gem 'sqlite3'
9
+ gem 'thin'
10
+ gem 'shotgun'
11
+ gem 'pry'
12
+ gem 'bcrypt'
13
+ gem "tux"
14
+
15
+ group :test do
16
+ gem 'rspec'
17
+ gem 'capybara'
18
+ gem 'rack-test'
19
+ gem 'database_cleaner', git: 'https://github.com/bmabey/database_cleaner.git'
20
+ end
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,4 @@
1
+ ENV["SINATRA_ENV"] ||= "development"
2
+
3
+ require_relative './config/environment'
4
+ require 'sinatra/activerecord/rake'
@@ -0,0 +1,14 @@
1
+ require './config/environment'
2
+
3
+ class ApplicationController < Sinatra::Base
4
+
5
+ configure do
6
+ set :public_folder, 'public'
7
+ set :views, 'app/views'
8
+ end
9
+
10
+ get "/" do
11
+ erb :welcome
12
+ end
13
+
14
+ end
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
3
+ <!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
4
+ <!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
5
+ <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6
+ <head>
7
+ <meta charset="utf-8" />
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1" />
9
+
10
+ <title><%= @name.camel_case %></title>
11
+
12
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
13
+
14
+ <link rel="stylesheet" href="/stylesheets/main.css" />
15
+ </head>
16
+ <body>
17
+ <div class="wrapper">
18
+
19
+ <%%= yield %>
20
+
21
+ <footer class="branding">
22
+ <small>&copy; <%= Time.now.year %> <strong><%= @name.camel_case %></strong></small>
23
+ </footer>
24
+ </div>
25
+
26
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
27
+ <!--[if lt IE 7]>
28
+ <script src="//ajax.googleapis.com/ajax/libs/chrome-frame/1.0.2/CFInstall.min.js"></script>
29
+ <script>window.attachEvent("onload",function(){CFInstall.check({mode:"overlay"})})</script>
30
+ <![endif]-->
31
+ </body>
@@ -0,0 +1,23 @@
1
+ <div class="container">
2
+ <header><img src="images/corneal-small.png" class="img-responsive main-image"></header>
3
+ <div class="col-md-8 col-md-offset-2">
4
+ <h2>Sinatra Template Default Page</h2>
5
+
6
+ <div class="content">
7
+ <p>Welcome to the Sinatra Template! If you're seeing this page, then everything is working
8
+ as expected. To get started, delete this file (<code>app/views/welcome.erb)</code> and begin adding
9
+ your own actions to <code>application_controller.rb</code>. For more information, see the <a href="https://github.com/thebrianemory/corneal">README</a>.</p>
10
+ </div>
11
+
12
+ <div class="sidebar">
13
+ <h3>Environment</h3>
14
+ <ul>
15
+ <li><b>Ruby:</b> <%= RUBY_VERSION %></li>
16
+ <li><b>Environment:</b> <%= ENV["RACK_ENV"] %></li>
17
+ <li><b>Server:</b> <%= @env["SERVER_SOFTWARE"] %></li>
18
+ <li><b>Port:</b> <%= @env["SERVER_PORT"] %></li>
19
+ </ul>
20
+ </div>
21
+
22
+ </div>
23
+ </div>
@@ -0,0 +1,7 @@
1
+ require './config/environment'
2
+
3
+ if ActiveRecord::Migrator.needs_migration?
4
+ raise 'Migrations are pending. Run `rake db:migrate` to resolve the issue.'
5
+ end
6
+
7
+ run ApplicationController
@@ -0,0 +1,35 @@
1
+ # Sequel Database Configuration
2
+ <% if @database == "sqlite" %>
3
+ development: "sqlite://db/development.sqlite3"
4
+ test: "sqlite://db/test.sqlite3"
5
+ production: "sqlite://db/production.sqlite3"
6
+ <% elsif @database == "postgres" %>
7
+ development: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_development"
8
+ test: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_test"
9
+ production: "postgres://<%= `whoami`.chop %>@localhost/<%= @name %>_production"
10
+ <% elsif @database == "mysql" %>
11
+ development: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_development"
12
+ test: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_test"
13
+ production: "mysql2://<%= `whoami`.chop %>@localhost/<%= @name %>_production"
14
+ <% elsif @database == "mongo" %>
15
+ development:
16
+ host: localhost
17
+ port: 27017
18
+ database: <%= @name %>_development
19
+ username:
20
+ password:
21
+
22
+ test:
23
+ host: localhost
24
+ port: 27017
25
+ database: <%= @name %>_test
26
+ username:
27
+ password:
28
+
29
+ production:
30
+ host: localhost
31
+ port: 27017
32
+ database: <%= @name %>_production
33
+ username:
34
+ password:
35
+ <% end %>
@@ -0,0 +1,11 @@
1
+ ENV['SINATRA_ENV'] ||= "development"
2
+
3
+ require 'bundler/setup'
4
+ Bundler.require(:default, ENV['SINATRA_ENV'])
5
+
6
+ ActiveRecord::Base.establish_connection(
7
+ :adapter => "sqlite3",
8
+ :database => "db/#{ENV['SINATRA_ENV']}.sqlite"
9
+ )
10
+
11
+ require_all 'app'
@@ -0,0 +1,11 @@
1
+ <% unless @database.empty? -%>
2
+ require "yaml"
3
+ settings = YAML::load_file("config/db.yml")
4
+ <% if @database != 'mongo' -%>
5
+ # Sequel Configuration
6
+ require "sequel"
7
+ DB = Sequel.connect(settings[ENV['RACK_ENV']])
8
+ <% else -%>
9
+ # MongoDB Configuration
10
+ <% end -%>
11
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ require "yaml"
2
+
3
+ # Redis Configuration
4
+ unless ENV['RACK_ENV'] == 'test'
5
+ redis_settings = YAML::load_file("config/redis.yml")
6
+ REDIS = Redis.new(redis_settings[ENV['RACK_ENV']])
7
+ end
@@ -0,0 +1,14 @@
1
+ development:
2
+ host: localhost
3
+ port: 6387
4
+ password:
5
+
6
+ test:
7
+ host: localhost
8
+ port: 6387
9
+ password:
10
+
11
+ production:
12
+ host: localhost
13
+ port: 6387
14
+ password:
File without changes
@@ -0,0 +1,115 @@
1
+ @media screen {
2
+ /* --- Reset Styles --- */
3
+ * {
4
+ list-style: none;
5
+ margin: 0;
6
+ padding: 0;
7
+ }
8
+
9
+ html, body {
10
+ height: 100%;
11
+ width: 100%;
12
+ }
13
+
14
+ /* --- Welcome Page Styles --- */
15
+ body {
16
+ background-color: lightblue;
17
+ color: #333;
18
+ font-family: Sans-Serif;
19
+ line-height: 18px;
20
+ }
21
+
22
+ .wrapper {
23
+ background: #fff;
24
+ -moz-box-shadow: 0 0 10px rgba(0,0,0,.3);
25
+ -webkit-box-shadow: 0 0 10px rgba(0,0,0,.3);
26
+ box-shadow: 0 0 10px rgba(0,0,0,.3);
27
+ margin: 16px auto;
28
+ max-width: 960px;
29
+ padding: 2.25%; /* 18px / 800px */
30
+ width: 85%;
31
+ }
32
+
33
+ h1 {
34
+ font-size: 36px;
35
+ line-height: 54px;
36
+ }
37
+
38
+ h2 {
39
+ border-bottom: 2px solid #ccc;
40
+ font-size: 24px;
41
+ line-height: 36px;
42
+ margin-bottom: 16px;
43
+ }
44
+
45
+ h3 {
46
+ font-size: 18px;
47
+ line-height: 36px;
48
+ }
49
+
50
+ p {
51
+ margin-bottom: 18px;
52
+ }
53
+
54
+ .main {
55
+ overflow: hidden;
56
+ }
57
+
58
+ .content {
59
+ float: left;
60
+ width: 60%; /* 480px / 800px */
61
+ }
62
+
63
+ .sidebar {
64
+ background: #eee;
65
+ border: 1px solid #ccc;
66
+ float: right;
67
+ padding: 2.08333333333%; /* 5px / 240px */
68
+ width: 30%; /* 240px / 800px */
69
+ }
70
+
71
+ .sidebar ul {
72
+ font-size: 14px;
73
+ }
74
+
75
+ .branding {
76
+ clear: both;
77
+ }
78
+
79
+ footer.branding {
80
+ border-top: 2px solid #ccc;
81
+ margin-top: 20px;
82
+ padding-top: 20px;
83
+ }
84
+ }
85
+
86
+ @media screen and (max-width: 600px) {
87
+ .wrapper {
88
+ -moz-box-shadow: none;
89
+ -webkit-box-shadow: none;
90
+ box-shadow: none;
91
+ width: auto;
92
+ }
93
+
94
+ .content, .sidebar {
95
+ float: none;
96
+ width: 100%;
97
+ }
98
+
99
+ .sidebar {
100
+ background: transparent;
101
+ border: none;
102
+ border-top: 2px solid #ccc;
103
+ padding: 0;
104
+ }
105
+
106
+ h1 {
107
+ font-size: 24px;
108
+ line-height: 36px;
109
+ }
110
+
111
+ h2 {
112
+ font-size: 18px;
113
+ line-height: 24px;
114
+ }
115
+ }
@@ -0,0 +1,13 @@
1
+ require_relative "spec_helper"
2
+
3
+ def app
4
+ ApplicationController
5
+ end
6
+
7
+ describe ApplicationController do
8
+ it "responds with a welcome message" do
9
+ get '/'
10
+ expect(last_response.status).to eq(200)
11
+ expect(last_response.body).to include("Welcome to the Sinatra Template!")
12
+ end
13
+ end
@@ -0,0 +1,36 @@
1
+ ENV["SINATRA_ENV"] = "test"
2
+
3
+ require_relative '../config/environment'
4
+ require 'rack/test'
5
+ require 'capybara/rspec'
6
+ require 'capybara/dsl'
7
+
8
+ if ActiveRecord::Migrator.needs_migration?
9
+ raise 'Migrations are pending. Run `rake db:migrate SINATRA_ENV=test` to resolve the issue.'
10
+ end
11
+
12
+ ActiveRecord::Base.logger = nil
13
+
14
+ RSpec.configure do |config|
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+ config.include Rack::Test::Methods
18
+ config.include Capybara::DSL
19
+ DatabaseCleaner.strategy = :truncation
20
+
21
+ config.before do
22
+ DatabaseCleaner.clean
23
+ end
24
+
25
+ config.after do
26
+ DatabaseCleaner.clean
27
+ end
28
+
29
+ config.order = 'default'
30
+ end
31
+
32
+ def app
33
+ Rack::Builder.parse_file('config.ru').first
34
+ end
35
+
36
+ Capybara.app = app
@@ -0,0 +1,15 @@
1
+ require 'fakefs'
2
+ require_relative "../spec_helper"
3
+ require_relative "../../lib/corneal/cli"
4
+
5
+ describe Corneal::VERSION do
6
+ subject { Corneal::CLI }
7
+
8
+ describe "source_root" do
9
+ it "should return with a full path" do
10
+ pwd = File.dirname(__FILE__)
11
+ template_path = pwd.sub 'spec/corneal', 'lib/templates'
12
+ subject.source_root.must_equal template_path
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ require_relative "../spec_helper"
2
+ require_relative "../../lib/corneal/version"
3
+
4
+ describe Corneal::VERSION do
5
+ subject { Corneal::VERSION }
6
+
7
+ let(:major) { subject::MAJOR }
8
+ let(:minor) { subject::MINOR }
9
+ let(:tiny) { subject::TINY }
10
+ let(:string) { subject::STRING }
11
+
12
+ it "should have a major version" do
13
+ major.must_be_kind_of Fixnum
14
+ end
15
+
16
+ it "should have a minor version" do
17
+ minor.must_be_kind_of Fixnum
18
+ end
19
+
20
+ it "should have a tiny version" do
21
+ tiny.must_be_kind_of Fixnum
22
+ end
23
+
24
+ it "should have a string representation of the version number" do
25
+ string.must_equal "#{major}.#{minor}.#{tiny}"
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'minitest/autorun'
@@ -0,0 +1,53 @@
1
+ require_relative "spec_helper"
2
+ require_relative "../lib/extensions/string.rb"
3
+
4
+ describe String do
5
+ it "should ignore an already camel cased string" do
6
+ "MyApp".camel_case.must_equal "MyApp"
7
+ end
8
+
9
+ it "should capitalize an all lower case string" do
10
+ "myapp".camel_case.must_equal "Myapp"
11
+ end
12
+
13
+ it "should camel case a lower case string with underscores" do
14
+ "my_app".camel_case.must_equal "MyApp"
15
+ end
16
+
17
+ it "should camel case a lower case string with hyphens" do
18
+ "my-app".camel_case.must_equal "MyApp"
19
+ end
20
+
21
+ it "should camel case an uppercase string with underscores" do
22
+ "MY_APP".camel_case.must_equal "MyApp"
23
+ end
24
+
25
+ it "should camel case an uppercase string with hyphens" do
26
+ "MY-APP".camel_case.must_equal "MyApp"
27
+ end
28
+
29
+ it "should camel case a string with a hyphen preceding a capital letter" do
30
+ "my_App".camel_case.must_equal "MyApp"
31
+ end
32
+
33
+ it "should underscore a camel cased string" do
34
+ "MyApp".file_name.must_equal "my_app"
35
+ end
36
+
37
+ it "should underscore a hypenated string" do
38
+ "my-app".file_name.must_equal "my_app"
39
+ end
40
+
41
+ it "should ignore an already underscored string" do
42
+ "my_app".file_name.must_equal "my_app"
43
+ end
44
+
45
+ it "should_underscore_a_string_with_a_hyphen_preceding_a_capital_letter" do
46
+ "my_App".file_name.must_equal "my_app"
47
+ end
48
+
49
+ it "should allow dashes in directory names, but not in filenames" do
50
+ "my-App".directory_name.must_equal "my-app"
51
+ "my-App".file_name.must_equal "my_app"
52
+ end
53
+ end
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: corneal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brian Emory
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.18'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.18'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.5'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.5.1
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.5'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.5.1
47
+ - !ruby/object:Gem::Dependency
48
+ name: minitest
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '5.2'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '5.2'
61
+ description: Corneal allows you to easily start building your Sinatra projects.
62
+ email: the@brianemory.com
63
+ executables:
64
+ - corneal
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - bin/corneal
74
+ - lib/corneal/cli.rb
75
+ - lib/corneal/version.rb
76
+ - lib/extensions/string.rb
77
+ - lib/templates/Gemfile
78
+ - lib/templates/README.md
79
+ - lib/templates/Rakefile
80
+ - lib/templates/app/controllers/application_controller.rb
81
+ - lib/templates/app/views/layout.erb.tt
82
+ - lib/templates/app/views/welcome.erb
83
+ - lib/templates/config.ru
84
+ - lib/templates/config/db.yml
85
+ - lib/templates/config/environment.rb
86
+ - lib/templates/config/initializers/database.rb
87
+ - lib/templates/config/initializers/redis.rb
88
+ - lib/templates/config/redis.yml
89
+ - lib/templates/public/favicon.ico
90
+ - lib/templates/public/images/.gitkeep
91
+ - lib/templates/public/images/corneal-small.png
92
+ - lib/templates/public/javascripts/.gitkeep
93
+ - lib/templates/public/stylesheets/main.css
94
+ - lib/templates/spec/application_controller_spec.rb
95
+ - lib/templates/spec/spec_helper.rb
96
+ - spec/corneal/cli_spec.rb
97
+ - spec/corneal/version_spec.rb
98
+ - spec/spec_helper.rb
99
+ - spec/string_extension_spec.rb
100
+ homepage: http://thebrianemory.github.io/corneal/
101
+ licenses:
102
+ - MIT
103
+ metadata: {}
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ requirements: []
119
+ rubyforge_project:
120
+ rubygems_version: 2.6.4
121
+ signing_key:
122
+ specification_version: 4
123
+ summary: A Sinatra app generator.
124
+ test_files: []