deano 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +21 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +89 -0
  6. data/Rakefile +1 -0
  7. data/bin/deano +19 -0
  8. data/deano.gemspec +22 -0
  9. data/lib/deano/commands/app_destroyer_command.rb +45 -0
  10. data/lib/deano/commands/app_generator_command.rb +47 -0
  11. data/lib/deano/commands/command.rb +49 -0
  12. data/lib/deano/commands/console_command.rb +18 -0
  13. data/lib/deano/commands/env_command.rb +19 -0
  14. data/lib/deano/commands/model_destroyer_command.rb +18 -0
  15. data/lib/deano/commands/model_generator_command.rb +41 -0
  16. data/lib/deano/commands/name_command.rb +29 -0
  17. data/lib/deano/commands/new_project_generator_command.rb +52 -0
  18. data/lib/deano/commands/start_command.rb +23 -0
  19. data/lib/deano/commands.rb +6 -0
  20. data/lib/deano/deano.rb +4 -0
  21. data/lib/deano/version.rb +3 -0
  22. data/template_app/.gitignore +21 -0
  23. data/template_app/Gemfile +18 -0
  24. data/template_app/Gemfile.lock +99 -0
  25. data/template_app/Procfile +1 -0
  26. data/template_app/Procfile.development +1 -0
  27. data/template_app/Rakefile +3 -0
  28. data/template_app/apps/template_app.rb +10 -0
  29. data/template_app/apps/views/template_app/index.erb +1 -0
  30. data/template_app/apps/views/template_app/layout.erb +51 -0
  31. data/template_app/assets/javascripts/application.js.coffee +8 -0
  32. data/template_app/assets/javascripts/template_app.js.coffee +0 -0
  33. data/template_app/assets/stylesheets/application.css.scss +3 -0
  34. data/template_app/assets/stylesheets/template_app.css.scss +0 -0
  35. data/template_app/assets/templates/.git-keep +0 -0
  36. data/template_app/config.ru +19 -0
  37. data/template_app/models/.git-keep +0 -0
  38. data/template_app/mongoid.yml +28 -0
  39. data/template_app/public/.git-keep +0 -0
  40. data/template_app/setup.rb +19 -0
  41. data/template_app/spec/apps/template_app_spec.rb +15 -0
  42. data/template_app/spec/spec_helper.rb +10 -0
  43. data/template_app/vendor/assets/javascripts/backbone.js +42 -0
  44. data/template_app/vendor/assets/javascripts/jquery.js +2 -0
  45. data/template_app/vendor/assets/javascripts/json2.js +486 -0
  46. data/template_app/vendor/assets/javascripts/underscore.js +1 -0
  47. data/template_app/vendor/assets/stylesheets/.git-keep +0 -0
  48. metadata +110 -0
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ *.log
2
+ .DS_Store
3
+ doc
4
+ tmp
5
+ pkg
6
+ *.gem
7
+ *.pid
8
+ coverage
9
+ coverage.data
10
+ build/*
11
+ *.pbxuser
12
+ *.mode1v3
13
+ .svn
14
+ profile
15
+ .console_history
16
+ .sass-cache/*
17
+ .rake_tasks~
18
+ *.log.lck
19
+ solr/
20
+ .jhw-cache/
21
+ jhw.*
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format specdoc
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in deano.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Mark Bates
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.
data/README.md ADDED
@@ -0,0 +1,89 @@
1
+ # Deano::Template
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'deano'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install deano
18
+
19
+ ## Generating a New Project
20
+
21
+ ```bash
22
+ $ deano new awesome_app
23
+ $ cd awesome_app
24
+ $ bundle
25
+ $ deano start
26
+ ```
27
+
28
+ ## Testing
29
+
30
+ ```bash
31
+ $ cd awesome_app
32
+ $ rake
33
+ ```
34
+
35
+ ## Starting
36
+
37
+ ```bash
38
+ $ cd awesome_app
39
+ $ deano start [environment]
40
+ ```
41
+
42
+ ## Console
43
+
44
+ ```bash
45
+ $ cd awesome_app
46
+ $ deano console [environment]
47
+ ```
48
+
49
+ ## Generating a New App
50
+
51
+ ```bash
52
+ $ cd awesome_app
53
+ $ deano generate:app foo_app
54
+ ```
55
+
56
+ ### Destroying a New App
57
+
58
+ ```bash
59
+ $ cd awesome_app
60
+ $ deano destroy:app foo_app
61
+ ```
62
+
63
+ ## Generating a New Model
64
+
65
+ ```bash
66
+ $ cd awesome_app
67
+ $ deano generate:model user
68
+ ```
69
+
70
+ ### Destroying a New Model
71
+
72
+ ```bash
73
+ $ cd awesome_app
74
+ $ deano destroy:model user
75
+ ```
76
+
77
+ ## Help
78
+
79
+ ```bash
80
+ $ deano help
81
+ ```
82
+
83
+ ## Contributing
84
+
85
+ 1. Fork it
86
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
87
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
88
+ 4. Push to the branch (`git push origin my-new-feature`)
89
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/deano ADDED
@@ -0,0 +1,19 @@
1
+ require 'active_support/core_ext'
2
+ require 'fileutils'
3
+
4
+ $:.unshift File.expand_path(File.join("..", "lib", "deano"), File.dirname(__FILE__))
5
+ require 'commands'
6
+
7
+ command = ARGV[0]
8
+
9
+ Deano::Command.commands.each do |klass|
10
+ if klass.command == command
11
+ klass.new(ARGV).call
12
+ exit(0)
13
+ end
14
+ end
15
+ Deano::Command.commands.each do |klass|
16
+ if klass.respond_to?(:help)
17
+ puts "deano #{klass.command} #{klass.help}"
18
+ end
19
+ end
data/deano.gemspec ADDED
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'deano/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "deano"
8
+ gem.version = Deano::VERSION
9
+ gem.authors = ["Mark Bates"]
10
+ gem.email = ["mark@markbates.com"]
11
+ gem.description = %q{A starter template and generators for Sinatra}
12
+ gem.summary = %q{A starter template and generators for Sinatra}
13
+ gem.homepage = ""
14
+ gem.license = "MIT"
15
+
16
+ gem.files = `git ls-files`.split($/)
17
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_development_dependency "rake"
22
+ end
@@ -0,0 +1,45 @@
1
+ module Deano
2
+ class AppDestroyer < Deano::NameCommand
3
+
4
+ def self.command
5
+ "destroy:app"
6
+ end
7
+
8
+ def self.help
9
+ "app_name"
10
+ end
11
+
12
+ def classified
13
+ "#{self.name.classify}App"
14
+ end
15
+
16
+ def call
17
+ path = app_path("apps", "#{self.underscored}.rb")
18
+ rm path
19
+
20
+ path = app_path("apps", "views", self.underscored)
21
+ rm_r path
22
+
23
+ path = app_path("spec", "apps", "#{self.underscored}_spec.rb")
24
+ rm path
25
+
26
+ path = app_path("assets", "javascripts", "#{self.underscored}.js.coffee")
27
+ rm path
28
+
29
+ path = app_path("assets", "stylesheets", "#{self.underscored}.css.scss")
30
+ rm path
31
+
32
+ path = app_path("config.ru")
33
+ old = File.read(path)
34
+ File.open(path, "w") do |file|
35
+ map = <<-EOF
36
+ map "/#{self.underscored}" do
37
+ run #{self.classified}
38
+ end
39
+ EOF
40
+ file.puts old.gsub(map, "")
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,47 @@
1
+ module Deano
2
+ class AppGenerator < Deano::NameCommand
3
+
4
+ def self.command
5
+ "generate:app"
6
+ end
7
+
8
+ def self.help
9
+ "app_name"
10
+ end
11
+
12
+ def classified
13
+ "#{self.name.classify}App"
14
+ end
15
+
16
+ def call
17
+ # mkdir self.underscored, verbose: true
18
+ %w{apps spec/apps}.each do |dir|
19
+ Dir[template_path("**", "*")].each do |f|
20
+ if File.directory?(f)
21
+ FileUtils.mkdir_p clean_string(f), verbose: true
22
+ else
23
+ FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
24
+ File.open(clean_string(f), 'w') do |file|
25
+ file.puts clean_string(File.read(f))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ File.open(app_path("assets", "javascripts", "#{self.underscored}.js.coffee"), 'w') do |file|
31
+ file.puts ""
32
+ end
33
+ File.open(app_path("assets", "stylesheets", "#{self.underscored}.css.scss"), 'w') do |file|
34
+ file.puts ""
35
+ end
36
+ File.open(app_path("config.ru"), "a") do |file|
37
+ file.puts <<-EOF
38
+ map "/#{self.underscored}" do
39
+ run #{self.classified}
40
+ end
41
+ EOF
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,49 @@
1
+ module Deano
2
+
3
+ def self.template_dir
4
+ File.expand_path(File.join("..", "..", "..", "template_app"), File.dirname(__FILE__))
5
+ end
6
+
7
+ class Command
8
+
9
+ def self.command
10
+ nil
11
+ end
12
+
13
+ def self.commands
14
+ @commands ||= []
15
+ end
16
+
17
+ def self.inherited(klass)
18
+ self.commands << klass
19
+ end
20
+
21
+ def cmd(command)
22
+ puts command
23
+ system command
24
+ end
25
+
26
+ def rm(path)
27
+ begin
28
+ FileUtils.rm path, verbose: true
29
+ rescue Errno::ENOENT => e
30
+ end
31
+ end
32
+
33
+ def rm_r(path)
34
+ begin
35
+ FileUtils.rm_r path, verbose: true
36
+ rescue Errno::ENOENT => e
37
+ end
38
+ end
39
+
40
+ def app_path(*path)
41
+ File.expand_path(File.join(@app_dir, *path))
42
+ end
43
+
44
+ def template_path(*path)
45
+ File.expand_path(File.join(Deano.template_dir, *path))
46
+ end
47
+
48
+ end
49
+ end
@@ -0,0 +1,18 @@
1
+ module Deano
2
+ class ConsoleCommand < Deano::EnvCommand
3
+
4
+ def self.command
5
+ "console"
6
+ end
7
+
8
+ def self.help
9
+ "[environment]\t\t# default: development"
10
+ end
11
+
12
+ def call
13
+ path = app_path("setup.rb")
14
+ cmd "pry -r #{path}"
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module Deano
2
+ class EnvCommand < Deano::Command
3
+ include FileUtils
4
+
5
+ attr_accessor :args, :env
6
+
7
+ def self.inherited(klass)
8
+ Command.inherited(klass)
9
+ end
10
+
11
+ def initialize(args)
12
+ self.args = args
13
+ @app_dir = File.expand_path(FileUtils.pwd)
14
+ self.env = args[1] || "development"
15
+ ENV["RACK_ENV"] = self.env
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module Deano
2
+ class ModelDestroyer < Deano::NameCommand
3
+
4
+ def self.command
5
+ "destroy:model"
6
+ end
7
+
8
+ def self.help
9
+ "model_name"
10
+ end
11
+
12
+ def call
13
+ rm app_path("models", "#{self.underscored}.rb")
14
+ rm app_path("spec", "models", "#{self.underscored}_spec.rb")
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module Deano
2
+ class ModelGenerator < Deano::NameCommand
3
+
4
+ def self.command
5
+ "generate:model"
6
+ end
7
+
8
+ def self.help
9
+ "model_name"
10
+ end
11
+
12
+ def call
13
+ path = app_path("models", "#{self.underscored}.rb")
14
+ FileUtils.mkdir_p File.dirname(path), verbose: true
15
+ File.open(path, 'w') do |file|
16
+ file.puts <<-EOF
17
+ class #{self.classified}
18
+ include Mongoid::Document
19
+ include Mongoid::Timestamps
20
+
21
+ end
22
+ EOF
23
+ end
24
+
25
+ path = app_path("spec", "models", "#{self.underscored}_spec.rb")
26
+ FileUtils.mkdir_p File.dirname(path), verbose: true
27
+ File.open(path, 'w') do |file|
28
+ file.puts <<-EOF
29
+ require 'spec_helper'
30
+
31
+ describe #{self.classified} do
32
+
33
+ it "does something"
34
+
35
+ end
36
+ EOF
37
+ end
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,29 @@
1
+ module Deano
2
+ class NameCommand < Deano::Command
3
+
4
+ attr_accessor :args, :name
5
+
6
+ def self.inherited(klass)
7
+ Command.inherited(klass)
8
+ end
9
+
10
+ def underscored
11
+ self.name.underscore
12
+ end
13
+
14
+ def classified
15
+ self.name.classify
16
+ end
17
+
18
+ def initialize(args)
19
+ self.args = args
20
+ self.name = ARGV[1]
21
+ @app_dir = File.expand_path(FileUtils.pwd)
22
+ end
23
+
24
+ def clean_string(f)
25
+ f.gsub(Deano.template_dir, @app_dir).gsub("template_app", self.underscored).gsub("TemplateApp", self.classified)
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,52 @@
1
+ module Deano
2
+ class NewProjectGenerator < Deano::NameCommand
3
+
4
+ def self.command
5
+ "new"
6
+ end
7
+
8
+ def self.help
9
+ "name"
10
+ end
11
+
12
+ def initialize(*args)
13
+ super
14
+ @app_dir = File.expand_path(File.join(FileUtils.pwd, self.underscored))
15
+ end
16
+
17
+ def classified
18
+ "#{self.name.classify}App"
19
+ end
20
+
21
+ def call
22
+ FileUtils.mkdir self.underscored, verbose: true
23
+ Dir[template_path("**", "*")].each do |f|
24
+ if File.directory?(f)
25
+ FileUtils.mkdir_p clean_string(f), verbose: true
26
+ else
27
+ FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
28
+ File.open(clean_string(f), 'w') do |file|
29
+ file.puts clean_string(File.read(f))
30
+ end
31
+ end
32
+ end
33
+ File.open(app_path(".gitignore"), "w") do |f|
34
+ f.puts File.read(template_path(".gitignore"))
35
+ end
36
+ rm app_path("Gemfile.lock")
37
+ Dir[app_path("**", "*")].each do |file|
38
+ if File.directory?(file)
39
+ if Dir[File.join(file, "**", "*")].empty?
40
+ File.open(File.join(file, ".git-keep"), 'w') {|f| f.puts ""}
41
+ end
42
+ end
43
+ end
44
+ FileUtils.cd app_path
45
+ system "bundle"
46
+ system "git init"
47
+ system "git add ."
48
+ system "git commit -a -m 'Initial Commit'"
49
+ end
50
+
51
+ end
52
+ end
@@ -0,0 +1,23 @@
1
+ module Deano
2
+ class StartCommand < Deano::EnvCommand
3
+
4
+ def self.command
5
+ "start"
6
+ end
7
+
8
+ def self.help
9
+ "[environment]\t\t# default: development"
10
+ end
11
+
12
+ def call
13
+ path = app_path("Procfile.#{self.env}")
14
+ if File.exists?(path)
15
+ cmd "bundle exec foreman start -f #{path}"
16
+ else
17
+ path = app_path("Procfile")
18
+ cmd "bundle exec foreman start -f #{path}"
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,6 @@
1
+ require 'commands/command'
2
+ %w{name env new_project_generator start console
3
+ app_generator app_destroyer model_generator
4
+ model_destroyer}.each do |file|
5
+ require "commands/#{file}_command"
6
+ end
@@ -0,0 +1,4 @@
1
+ require "deano/version"
2
+
3
+ module Deano
4
+ end
@@ -0,0 +1,3 @@
1
+ module Deano
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,21 @@
1
+ *.log
2
+ .DS_Store
3
+ doc
4
+ tmp
5
+ pkg
6
+ *.gem
7
+ *.pid
8
+ coverage
9
+ coverage.data
10
+ build/*
11
+ *.pbxuser
12
+ *.mode1v3
13
+ .svn
14
+ profile
15
+ .console_history
16
+ .sass-cache/*
17
+ .rake_tasks~
18
+ *.log.lck
19
+ solr/
20
+ .jhw-cache/
21
+ jhw.*
@@ -0,0 +1,18 @@
1
+ gem 'thin'
2
+ gem 'sass'
3
+ gem 'coffee-script'
4
+ gem 'sinatra'
5
+ gem "sinatra-twitter-bootstrap", github: "mifo/sinatra-twitter-bootstrap"
6
+ gem 'sprockets'
7
+ gem 'shotgun'
8
+ gem 'foreman'
9
+ gem 'mongoid'
10
+ gem 'activesupport'
11
+ gem 'eco'
12
+ gem 'deano'
13
+
14
+ group :development, :test do
15
+ gem 'rack-test'
16
+ gem 'rspec'
17
+ gem 'pry'
18
+ end
@@ -0,0 +1,99 @@
1
+ GIT
2
+ remote: git://github.com/mifo/sinatra-twitter-bootstrap.git
3
+ revision: 6433f8c6cb429ee1f2d3ed5d17617b99201632ca
4
+ specs:
5
+ sinatra-twitter-bootstrap (2.2.2)
6
+
7
+ GEM
8
+ specs:
9
+ activemodel (3.2.9)
10
+ activesupport (= 3.2.9)
11
+ builder (~> 3.0.0)
12
+ activesupport (3.2.9)
13
+ i18n (~> 0.6)
14
+ multi_json (~> 1.0)
15
+ builder (3.0.4)
16
+ coderay (1.0.8)
17
+ coffee-script (2.2.0)
18
+ coffee-script-source
19
+ execjs
20
+ coffee-script-source (1.4.0)
21
+ daemons (1.1.9)
22
+ diff-lcs (1.1.3)
23
+ eco (1.0.0)
24
+ coffee-script
25
+ eco-source
26
+ execjs
27
+ eco-source (1.1.0.rc.1)
28
+ eventmachine (1.0.0)
29
+ execjs (1.4.0)
30
+ multi_json (~> 1.0)
31
+ foreman (0.60.2)
32
+ thor (>= 0.13.6)
33
+ hike (1.2.1)
34
+ i18n (0.6.1)
35
+ method_source (0.8.1)
36
+ mongoid (3.0.15)
37
+ activemodel (~> 3.1)
38
+ moped (~> 1.1)
39
+ origin (~> 1.0)
40
+ tzinfo (~> 0.3.22)
41
+ moped (1.3.1)
42
+ multi_json (1.5.0)
43
+ origin (1.0.11)
44
+ pry (0.9.10)
45
+ coderay (~> 1.0.5)
46
+ method_source (~> 0.8)
47
+ slop (~> 3.3.1)
48
+ rack (1.4.1)
49
+ rack-protection (1.3.2)
50
+ rack
51
+ rack-test (0.6.2)
52
+ rack (>= 1.0)
53
+ rspec (2.12.0)
54
+ rspec-core (~> 2.12.0)
55
+ rspec-expectations (~> 2.12.0)
56
+ rspec-mocks (~> 2.12.0)
57
+ rspec-core (2.12.2)
58
+ rspec-expectations (2.12.1)
59
+ diff-lcs (~> 1.1.3)
60
+ rspec-mocks (2.12.1)
61
+ sass (3.2.4)
62
+ shotgun (0.9)
63
+ rack (>= 1.0)
64
+ sinatra (1.3.3)
65
+ rack (~> 1.3, >= 1.3.6)
66
+ rack-protection (~> 1.2)
67
+ tilt (~> 1.3, >= 1.3.3)
68
+ slop (3.3.3)
69
+ sprockets (2.2.2)
70
+ hike (~> 1.2)
71
+ multi_json (~> 1.0)
72
+ rack (~> 1.0)
73
+ tilt (~> 1.1, != 1.3.0)
74
+ thin (1.5.0)
75
+ daemons (>= 1.0.9)
76
+ eventmachine (>= 0.12.6)
77
+ rack (>= 1.0.0)
78
+ thor (0.16.0)
79
+ tilt (1.3.3)
80
+ tzinfo (0.3.35)
81
+
82
+ PLATFORMS
83
+ ruby
84
+
85
+ DEPENDENCIES
86
+ activesupport
87
+ coffee-script
88
+ eco
89
+ foreman
90
+ mongoid
91
+ pry
92
+ rack-test
93
+ rspec
94
+ sass
95
+ shotgun
96
+ sinatra
97
+ sinatra-twitter-bootstrap!
98
+ sprockets
99
+ thin