opening_act 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.rubocop.yml +5 -0
  4. data/.rubocop_todo.yml +27 -0
  5. data/.travis.yml +5 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +81 -0
  9. data/Rakefile +10 -0
  10. data/bin/console +14 -0
  11. data/bin/setup +8 -0
  12. data/exe/opening +15 -0
  13. data/lib/opening_act.rb +88 -0
  14. data/lib/opening_act/input.rb +36 -0
  15. data/lib/opening_act/output.rb +47 -0
  16. data/lib/opening_act/template.rb +51 -0
  17. data/lib/opening_act/templates/Gemfile_Spec +17 -0
  18. data/lib/opening_act/templates/Gemfile_Test +18 -0
  19. data/lib/opening_act/templates/LICENSE.txt +21 -0
  20. data/lib/opening_act/templates/Procfile +1 -0
  21. data/lib/opening_act/templates/README.md +0 -0
  22. data/lib/opening_act/templates/Rakefile_Spec +24 -0
  23. data/lib/opening_act/templates/Rakefile_Test +10 -0
  24. data/lib/opening_act/templates/config.ru +6 -0
  25. data/lib/opening_act/templates/environment.rb +14 -0
  26. data/lib/opening_act/templates/new_app.rb +21 -0
  27. data/lib/opening_act/templates/public/javascript/script.js +1 -0
  28. data/lib/opening_act/templates/public/stylesheets/main.css +3 -0
  29. data/lib/opening_act/templates/public/stylesheets/reset.css +22 -0
  30. data/lib/opening_act/templates/spec/new_app_spec.rb +22 -0
  31. data/lib/opening_act/templates/spec/spec_helper.rb +16 -0
  32. data/lib/opening_act/templates/test/new_app_test.rb +8 -0
  33. data/lib/opening_act/templates/test/test_helper.rb +8 -0
  34. data/lib/opening_act/templates/views/index.erb +19 -0
  35. data/lib/opening_act/templates/views/layout.erb +17 -0
  36. data/lib/opening_act/verify.rb +21 -0
  37. data/lib/opening_act/version.rb +3 -0
  38. data/opening_act.gemspec +30 -0
  39. metadata +153 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: de8be920d961e4fc34ac938126a33f1cd1496671
4
+ data.tar.gz: ec97dbfa038170682bd306cdcb3d8749d295898b
5
+ SHA512:
6
+ metadata.gz: a795dc6af4c47feaf455585c740ab80003b99230b3edaf8b9c8ce8304021bbca455df0186ff61e891843e9d6574c9eb23dc6dc11e514ef6bd58e71b39a14fc85
7
+ data.tar.gz: c29473dd2e5b1e1d16eca850c880c6857d1e6099c83aa6f4dd21469aad87d63b4e06308abf4553c8e7d9a1a1047b92c5c0318ba8a187bc688ef0eb411a798de5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,5 @@
1
+ # Inherit style from another configuration
2
+ inherit_from: .rubocop_todo.yml
3
+
4
+ Style/TrailingWhitespace:
5
+ Enabled: true
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,27 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-04-08 20:45:53 -0400 using RuboCop version 0.48.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 7
10
+ Metrics/AbcSize:
11
+ Max: 28
12
+
13
+ # Offense count: 1
14
+ # Configuration parameters: CountComments.
15
+ Metrics/ClassLength:
16
+ Max: 219
17
+
18
+ # Offense count: 13
19
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
20
+ # URISchemes: http, https
21
+ Metrics/LineLength:
22
+ Max: 129
23
+
24
+ # Offense count: 2
25
+ # Configuration parameters: CountComments.
26
+ Metrics/MethodLength:
27
+ Max: 11
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+ before_install: gem install bundler -v 1.14.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in opening_act.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Sun-Li Beatteay
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,81 @@
1
+ # OpeningAct
2
+
3
+ Do you use Sinatra often? Are you tired of creating the same boilerplate files every time and haven't had the time to automate your system yet? Well then this is the gem for you. OpeningAct creates the template files you need for your Sinatra application so you can start developing in moments.
4
+
5
+ OpeningAct was inspired by Bundler's gem template and Rails. The template files were partially inspired by [zapnap's sinatra template](https://github.com/zapnap/sinatra-template).
6
+
7
+ ## Installation
8
+
9
+ To install OpeningAct, you just need to run this command on your machine:
10
+
11
+ $ gem install opening_act
12
+
13
+ ## Usage
14
+
15
+ Once you install OpeningAct on your machine, you will have access to the executable `opening`. To create your sinatra template, just run it on your command line:
16
+
17
+ $ opening
18
+
19
+ OpeningAct will prompt you to provide a name for your project and your preferred test framework (Rspec or Minitest).
20
+
21
+ You can also pass in a name and a test type (as a flag):
22
+
23
+ $ opening sample -minitest
24
+
25
+ OR
26
+
27
+ $ opening -minitest sample
28
+
29
+ It will create a project directory with all your starter files:
30
+
31
+ ```
32
+ ├── .git
33
+ ├── Gemfile
34
+ ├── Gemfile.lock
35
+ ├── LICENSE.txt
36
+ ├── Procfile
37
+ ├── README.md
38
+ ├── Rakefile
39
+ ├── config.ru
40
+ ├── environment.rb
41
+ ├── public
42
+ │   ├── javascript
43
+ │   │   └── script.js
44
+ │   └── stylesheets
45
+ │   ├── main.css
46
+ │   └── reset.css
47
+ ├── sample.rb
48
+ ├── test
49
+ │   ├── sample_test.rb
50
+ │   └── test_helper.rb
51
+ └── views
52
+ ├── index.erb
53
+ └── layout.erb
54
+
55
+ 5 directories, 17 files
56
+ ```
57
+
58
+ Once OpeningAct has run, you're ready for development. Just run
59
+
60
+ $ ruby your_app_name.rb
61
+
62
+ OR
63
+
64
+ $ heroku local web
65
+
66
+ to see your Sinatra application.
67
+
68
+ ## Development
69
+
70
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
71
+
72
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
73
+
74
+ ## Contributing
75
+
76
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sunny-b/opening_act.
77
+
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'opening_act'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/opening ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/opening_act.rb'
3
+
4
+ def flag?(item)
5
+ item[0] == '-'
6
+ end
7
+
8
+ def test?(item)
9
+ item.match(/(minitest|rspec)/)
10
+ end
11
+
12
+ test_type = ARGV.find { |item| flag?(item) && test?(item) }
13
+ project_name = ARGV.reject { |item| flag?(item) }.first
14
+
15
+ OpeningAct.perform(project_name, test_type)
@@ -0,0 +1,88 @@
1
+ require_relative 'opening_act/version.rb'
2
+ require_relative 'opening_act/input.rb'
3
+ require_relative 'opening_act/output.rb'
4
+ require_relative 'opening_act/template.rb'
5
+ require_relative 'opening_act/verify.rb'
6
+ require 'fileutils'
7
+
8
+ # Main class for OpeningAct
9
+ class OpeningAct
10
+ extend Inputable
11
+ extend Outputable
12
+ extend Verifiable
13
+
14
+ def self.perform(name, test_name)
15
+ return leave_the_stage unless play_on?
16
+
17
+ setup(name, test_name)
18
+ add_overwrite_rename_or_quit while directory_exists?
19
+ take_the_stage
20
+ create_project_files
21
+ curtain_call
22
+ end
23
+
24
+ private_class_method
25
+
26
+ def self.add_overwrite_rename_or_quit
27
+ directory_exists_commands
28
+ command = command_input
29
+ determine_action(command)
30
+ end
31
+
32
+ def self.correct_test_name?(test_type)
33
+ %w[minitest rspec].include?(test_type[1..-1])
34
+ end
35
+
36
+ def self.create_project_files
37
+ template.create
38
+ template.remove_extra_files
39
+ template.rename_files
40
+ template.initiate_project
41
+ end
42
+
43
+ def self.determine_action(command)
44
+ case command
45
+ when 'add' then add_confirmation
46
+ when 'overwrite' then overwrite_existing_dir
47
+ when 'rename' then rename_project
48
+ when 'quit' || 'q' then leave_the_stage
49
+ else 'no command'
50
+ end
51
+ end
52
+
53
+ def self.directory_exists?
54
+ Dir.exist? name
55
+ end
56
+
57
+ def self.flag?(test_type)
58
+ test_type[0] == '-'
59
+ end
60
+
61
+ def self.overwrite_existing_dir
62
+ FileUtils.rm_rf(template.name)
63
+
64
+ overwrite_confirmation
65
+ end
66
+
67
+ def self.play_on?
68
+ new_git_confirmation
69
+
70
+ !%w[quit q].include?(user_input.downcase)
71
+ end
72
+
73
+ def self.rename_project
74
+ template.name = project_name_input
75
+ rename_confirmation
76
+ end
77
+
78
+ def self.setup(project_name, test_type)
79
+ project_name = project_name_input unless valid_name?(project_name)
80
+ test_type = test_type_input unless valid_test?(test_type)
81
+
82
+ @template = Template.new(project_name, test_type)
83
+ end
84
+
85
+ class << self
86
+ attr_reader :template
87
+ end
88
+ end
@@ -0,0 +1,36 @@
1
+ # Module containing method for user inputs
2
+ module Inputable
3
+ def command_input
4
+ appropriate_commands = %w[add overwrite q quit rename]
5
+
6
+ loop do
7
+ command = user_input.downcase
8
+ return command if appropriate_commands.include? command
9
+ puts '> Invalid entry. Please enter ADD/OVERWRITE/QUIT/RENAME'
10
+ end
11
+ end
12
+
13
+ def project_name_input
14
+ loop do
15
+ puts '> What do you want to name your project?'
16
+ project_name = user_input
17
+
18
+ return project_name if valid_name?(project_name)
19
+ puts '> Invalid characters. Please try again'
20
+ end
21
+ end
22
+
23
+ def test_type_input
24
+ loop do
25
+ puts '> Do you prefer rspec or minitest?'
26
+ test_type = '-' + user_input.downcase
27
+
28
+ return test_type if valid_test? test_type
29
+ puts '> Invalid entry.'
30
+ end
31
+ end
32
+
33
+ def user_input
34
+ $stdin.gets.chomp
35
+ end
36
+ end
@@ -0,0 +1,47 @@
1
+ # Module containing methods that only output text
2
+ module Outputable
3
+ def curtain_call
4
+ puts
5
+ puts '> The Opening Act has performed.'
6
+ puts "> Your project folder '#{template.name}' was created."
7
+ puts "> You're now ready for the main event."
8
+ end
9
+
10
+ def leave_the_stage
11
+ puts '> The Opening Act was forced to leave the stage early.'
12
+ puts '> Your project folder was not created.'
13
+ end
14
+
15
+ def directory_exists_commands
16
+ puts '> It appears another directory by this name already exists.'
17
+ puts '> Do you wish to:'
18
+ puts ' ADD to it'
19
+ puts ' OVERWRITE it'
20
+ puts ' RENAME your project'
21
+ puts ' QUIT this program'
22
+ end
23
+
24
+ def take_the_stage
25
+ puts '> The Opening Act has begun to play. This may take a moment.'
26
+ end
27
+
28
+ def add_confirmation
29
+ puts "> Files will be added to existing directory '#{template.name}'."
30
+ puts
31
+ end
32
+
33
+ def overwrite_confirmation
34
+ puts "> '#{template.name}' will be overwritten."
35
+ puts
36
+ end
37
+
38
+ def rename_confirmation
39
+ puts "> Your project has been renamed to '#{template.name}'."
40
+ end
41
+
42
+ def new_git_confirmation
43
+ puts '> Running this command will initiate a git project.'
44
+ puts "> Make sure you aren't running this inside another git project."
45
+ puts '> Type QUIT if you wish to stop. Otherwise, click Enter.'
46
+ end
47
+ end
@@ -0,0 +1,51 @@
1
+ # Class for template and boilerplate files
2
+ class Template
3
+ attr_reader :test_type
4
+ attr_accessor :name
5
+
6
+ PROJECT_TEMPLATE = File.expand_path('../templates', __FILE__)
7
+
8
+ def initialize(name, type)
9
+ @name = name
10
+ @test_type = type[1..-1]
11
+ end
12
+
13
+ def create
14
+ FileUtils.copy_entry PROJECT_TEMPLATE, name
15
+ end
16
+
17
+ def initiate_project
18
+ Dir.chdir name do
19
+ `git init`
20
+ `bundle install`
21
+ end
22
+ end
23
+
24
+ def rename_files
25
+ File.rename("#{name}/new_app.rb", "#{name}/#{name}.rb")
26
+
27
+ case test_type
28
+ when 'minitest'
29
+ File.rename("#{name}/test/new_app_test.rb", "#{name}/test/#{name}_test.rb")
30
+ when 'rspec'
31
+ File.rename("#{name}/spec/new_app_spec.rb", "#{name}/spec/#{name}_spec.rb")
32
+ end
33
+
34
+ remove_test_suffix
35
+ end
36
+
37
+ def remove_extra_files
38
+ other_test_type = test_type == 'rspec' ? 'test' : 'spec'
39
+
40
+ FileUtils.rm_rf("#{name}/#{other_test_type}")
41
+ FileUtils.rm Dir.glob("#{name}/*_#{other_test_type}")
42
+ end
43
+
44
+ private
45
+
46
+ def remove_test_suffix
47
+ Dir.glob("#{name}/*_*").each do |file|
48
+ File.rename(file, file[0..-6])
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ gem 'sinatra'
5
+ gem 'sinatra-contrib'
6
+ gem 'erubis'
7
+ gem 'rack'
8
+ gem 'rspec'
9
+
10
+ group :production do
11
+ gem "puma"
12
+ end
13
+
14
+ group :development do
15
+ gem 'pry'
16
+ gem 'rubocop'
17
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+ source "https://rubygems.org"
3
+
4
+ gem 'sinatra'
5
+ gem 'sinatra-contrib'
6
+ gem 'erubis'
7
+ gem 'rack'
8
+ gem 'minitest'
9
+ gem 'minitest-reporters'
10
+
11
+ group :production do
12
+ gem "puma"
13
+ end
14
+
15
+ group :development do
16
+ gem 'pry'
17
+ gem 'rubocop'
18
+ end
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) THIS_YEAR TODO: YOUR_NAME
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1 @@
1
+ web: bundle exec rackup -p $PORT
File without changes
@@ -0,0 +1,24 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+ require 'dotenv/tasks'
5
+
6
+ task :default => :test
7
+ task :test => :spec
8
+
9
+ if !defined?(RSpec)
10
+ puts "spec targets require RSpec"
11
+ else
12
+ desc "Run all examples"
13
+ RSpec::Core::RakeTask.new(:spec) do |t|
14
+ t.pattern = Dir['spec/**/*_spec.rb']
15
+ end
16
+ end
17
+
18
+ task :environment => :dotenv do
19
+ require File.join(File.dirname(__FILE__), 'environment')
20
+ end
21
+
22
+ task :console do
23
+ ruby 'script/console'
24
+ end
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
@@ -0,0 +1,6 @@
1
+ Dir.glob('*.rb') { |file| require_relative file }
2
+
3
+ set :run, false
4
+ set :environment, :production
5
+
6
+ run Sinatra::Application
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'sinatra' unless defined?(Sinatra)
4
+
5
+ configure do
6
+ SiteConfig = OpenStruct.new(
7
+ title: 'Your Application Name',
8
+ author: 'Your Name',
9
+ url_base: 'http://localhost:4567/'
10
+ )
11
+
12
+ $LOAD_PATH.unshift("#{File.dirname(__FILE__)}/lib")
13
+ Dir.glob("#{File.dirname(__FILE__)}/lib/*.rb") { |lib| require File.basename(lib, '.*') }
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'bundler/setup'
2
+ require 'sinatra'
3
+ require 'tilt/erubis'
4
+ require 'rack'
5
+ require 'date'
6
+ require File.join(File.dirname(__FILE__), 'environment')
7
+
8
+ configure(:development) do
9
+ require 'sinatra/reloader'
10
+ require 'pry'
11
+ also_reload 'lib/sequel_persistence.rb' if development?
12
+ end
13
+
14
+ helpers do
15
+ # add your helpers here
16
+ end
17
+
18
+ # index page
19
+ get '/' do
20
+ erb :index
21
+ end
@@ -0,0 +1 @@
1
+ // JavaScript goes here...
@@ -0,0 +1,3 @@
1
+ /*
2
+ CSS goes here...
3
+ */
@@ -0,0 +1,22 @@
1
+ /*
2
+ ----------------------------------------
3
+ Tantek Celik's Whitepsace Reset
4
+ Author: Tantek Celik, Shane Riley
5
+ Version: (CC) 2010 Some Rights Reserved - http://creativecommons.org/licenses/by/2.0
6
+ Description: Resets default styling of common browsers to a common base
7
+ ----------------------------------------
8
+ */
9
+
10
+ ul,ol { list-style: none; }
11
+ h1,h2,h3,h4,h5,h6,pre,code { font-size: 1em; }
12
+ ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset,input,dl,dt,dd, figure, figcaption {
13
+ margin: 0;
14
+ padding: 0; }
15
+ a img,:link img,:visited img, fieldset { border: none; }
16
+ address { font-style: normal; }
17
+ header, section, article, nav, footer, hgroup, details, summary, figure, main { display: block; }
18
+ mark {
19
+ color: inherit;
20
+ background: transparent; }
21
+ abbr { border: none; }
22
+ summary::-webkit-details-marker { display: none; }
@@ -0,0 +1,22 @@
1
+ require "#{File.dirname(__FILE__)}/spec_helper"
2
+
3
+ describe 'main application' do
4
+ include Rack::Test::Methods
5
+
6
+ def app
7
+ Sinatra::Application.new
8
+ end
9
+
10
+ it 'shows the default index page' do
11
+ get '/'
12
+ expect(last_response).to be_ok
13
+ end
14
+
15
+ it 'does something useful' do
16
+ expect(false).to eq(true)
17
+ end
18
+
19
+ it 'should have more specs' do
20
+ expect(false).to eq(true)
21
+ end
22
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup(:default, :test)
4
+ require 'sinatra'
5
+ require 'rspec'
6
+ require 'rack/test'
7
+
8
+ # set test environment
9
+ Sinatra::Base.set :environment, :test
10
+ Sinatra::Base.set :run, false
11
+ Sinatra::Base.set :raise_errors, true
12
+ Sinatra::Base.set :logging, false
13
+
14
+ Dir.glob(File.expand_path('../*.rb', __FILE__)).each do |file|
15
+ require file
16
+ end
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ # Tests for Sinatra app
4
+ class NewApp < Minitest::Test
5
+ def test_something_cool
6
+ assert false
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ Dir.glob(File.expand_path('../*.rb', __FILE__)).each do |file|
3
+ require file
4
+ end
5
+
6
+ require 'minitest/autorun'
7
+ require 'minitest/reporters'
8
+ Minitest::Reporters.use!
@@ -0,0 +1,19 @@
1
+ <style>
2
+ img {
3
+ width: 100%;
4
+ }
5
+
6
+ h1 {
7
+ font-family: Helvetica, sans-serif;
8
+ font-size: 4.5em;
9
+ color: white;
10
+ position: absolute;
11
+ top: 5%;
12
+ width: 100%;
13
+ text-align: center;
14
+
15
+ }
16
+ </style>
17
+
18
+ <img src="http://static.buzznet.com/uploads/2013/03/orig-21185018.jpg"></img>
19
+ <h1>The Opening Act Welcomes You.<br>Happy Programming!</h1>
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= @title || SiteConfig.title %></title>
5
+ <link href="/stylesheets/reset.css" rel="stylesheet" type="text/css"></link>
6
+ <link href="/stylesheets/main.css" rel="stylesheet" type="text/css"></link>
7
+ </head>
8
+ <body>
9
+
10
+ <%= yield %>
11
+
12
+ <script src="script.js"></script>
13
+ <footer>
14
+ <p>&copy; <%= Date.today.year %> <%= SiteConfig.author %></p>
15
+ </footer>
16
+ </body>
17
+ </html>
@@ -0,0 +1,21 @@
1
+ # Module that contains validating methods for project name and test type
2
+ module Verifiable
3
+ def valid_characters?(project_name)
4
+ !%r{[\#%&{}\\<>*?\/ $!'":@+`|=]}.match(project_name)
5
+ end
6
+
7
+ def valid_initial_character?(project_name)
8
+ !/[ .\-_]/.match(project_name[0])
9
+ end
10
+
11
+ def valid_name?(project_name)
12
+ !project_name.nil? &&
13
+ valid_characters?(project_name) &&
14
+ valid_initial_character?(project_name) &&
15
+ project_name.length < 31
16
+ end
17
+
18
+ def valid_test?(test_type)
19
+ !test_type.nil? && correct_test_name?(test_type) && flag?(test_type)
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ class OpeningAct
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+
3
+ lib = File.expand_path('../lib', __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'opening_act/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'opening_act'
9
+ spec.version = OpeningAct::VERSION
10
+ spec.authors = ['Sun-Li Beatteay']
11
+ spec.email = ['sjbeatteay@gmail.com']
12
+
13
+ spec.summary = 'A tool that creates the Sinatra development environment for you.'
14
+ spec.description = "A gem that auto generates all the files, folders and tests you'll need to start you Sinatra application."
15
+ spec.homepage = 'https://github.com/sunny-b/opening_act'
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = 'exe'
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ['lib']
24
+
25
+ spec.add_development_dependency 'bundler', '~> 1.14'
26
+ spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'minitest', '~> 5.0'
28
+ spec.add_development_dependency 'minitest-reporters'
29
+ spec.add_development_dependency 'rspec'
30
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opening_act
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sun-Li Beatteay
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.14'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.14'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest-reporters
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: A gem that auto generates all the files, folders and tests you'll need
84
+ to start you Sinatra application.
85
+ email:
86
+ - sjbeatteay@gmail.com
87
+ executables:
88
+ - opening
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - ".gitignore"
93
+ - ".rubocop.yml"
94
+ - ".rubocop_todo.yml"
95
+ - ".travis.yml"
96
+ - Gemfile
97
+ - LICENSE.txt
98
+ - README.md
99
+ - Rakefile
100
+ - bin/console
101
+ - bin/setup
102
+ - exe/opening
103
+ - lib/opening_act.rb
104
+ - lib/opening_act/input.rb
105
+ - lib/opening_act/output.rb
106
+ - lib/opening_act/template.rb
107
+ - lib/opening_act/templates/Gemfile_Spec
108
+ - lib/opening_act/templates/Gemfile_Test
109
+ - lib/opening_act/templates/LICENSE.txt
110
+ - lib/opening_act/templates/Procfile
111
+ - lib/opening_act/templates/README.md
112
+ - lib/opening_act/templates/Rakefile_Spec
113
+ - lib/opening_act/templates/Rakefile_Test
114
+ - lib/opening_act/templates/config.ru
115
+ - lib/opening_act/templates/environment.rb
116
+ - lib/opening_act/templates/new_app.rb
117
+ - lib/opening_act/templates/public/javascript/script.js
118
+ - lib/opening_act/templates/public/stylesheets/main.css
119
+ - lib/opening_act/templates/public/stylesheets/reset.css
120
+ - lib/opening_act/templates/spec/new_app_spec.rb
121
+ - lib/opening_act/templates/spec/spec_helper.rb
122
+ - lib/opening_act/templates/test/new_app_test.rb
123
+ - lib/opening_act/templates/test/test_helper.rb
124
+ - lib/opening_act/templates/views/index.erb
125
+ - lib/opening_act/templates/views/layout.erb
126
+ - lib/opening_act/verify.rb
127
+ - lib/opening_act/version.rb
128
+ - opening_act.gemspec
129
+ homepage: https://github.com/sunny-b/opening_act
130
+ licenses:
131
+ - MIT
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.6.8
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: A tool that creates the Sinatra development environment for you.
153
+ test_files: []