sinatra-template 1.2.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/sinatra/commands/app_destroyer_command.rb +15 -21
- data/lib/sinatra/commands/app_generator_command.rb +10 -22
- data/lib/sinatra/commands/command.rb +22 -0
- data/lib/sinatra/commands/console_command.rb +1 -1
- data/lib/sinatra/commands/env_command.rb +1 -1
- data/lib/sinatra/commands/model_destroyer_command.rb +2 -15
- data/lib/sinatra/commands/model_generator_command.rb +4 -9
- data/lib/sinatra/commands/name_command.rb +1 -1
- data/lib/sinatra/commands/new_project_generator_command.rb +19 -5
- data/lib/sinatra/commands/start_command.rb +2 -2
- data/lib/sinatra/template/version.rb +1 -1
- data/template_app/Gemfile +1 -0
- data/template_app/Gemfile.lock +14 -0
- data/template_app/apps/views/template_app/layout.erb +2 -0
- data/template_app/assets/javascripts/application.js.coffee +1 -0
- data/template_app/assets/javascripts/template_app.js.coffee +0 -0
- data/template_app/assets/stylesheets/template_app.css.scss +0 -0
- metadata +3 -1
@@ -8,34 +8,28 @@ module Sinatra
|
|
8
8
|
def self.help
|
9
9
|
"app_name"
|
10
10
|
end
|
11
|
-
|
12
|
-
def initialize(*args)
|
13
|
-
super
|
14
|
-
@app_dir = File.expand_path(pwd)
|
15
|
-
end
|
16
11
|
|
17
12
|
def classified
|
18
13
|
"#{self.name.classify}App"
|
19
14
|
end
|
20
15
|
|
21
16
|
def call
|
22
|
-
path =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
path
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
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
|
37
31
|
|
38
|
-
path =
|
32
|
+
path = app_path("config.ru")
|
39
33
|
old = File.read(path)
|
40
34
|
File.open(path, "w") do |file|
|
41
35
|
map = <<-EOF
|
@@ -9,11 +9,6 @@ module Sinatra
|
|
9
9
|
"app_name"
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(*args)
|
13
|
-
super
|
14
|
-
@app_dir = File.expand_path(pwd)
|
15
|
-
end
|
16
|
-
|
17
12
|
def classified
|
18
13
|
"#{self.name.classify}App"
|
19
14
|
end
|
@@ -21,18 +16,24 @@ module Sinatra
|
|
21
16
|
def call
|
22
17
|
# mkdir self.underscored, verbose: true
|
23
18
|
%w{apps spec/apps}.each do |dir|
|
24
|
-
Dir[
|
19
|
+
Dir[template_path("**", "*")].each do |f|
|
25
20
|
if File.directory?(f)
|
26
|
-
mkdir_p clean_string(f), verbose: true
|
21
|
+
FileUtils.mkdir_p clean_string(f), verbose: true
|
27
22
|
else
|
28
|
-
mkdir_p clean_string(File.dirname(f)), verbose: true
|
23
|
+
FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
|
29
24
|
File.open(clean_string(f), 'w') do |file|
|
30
25
|
file.puts clean_string(File.read(f))
|
31
26
|
end
|
32
27
|
end
|
33
28
|
end
|
34
29
|
end
|
35
|
-
File.open(
|
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|
|
36
37
|
file.puts <<-EOF
|
37
38
|
map "/#{self.underscored}" do
|
38
39
|
run #{self.classified}
|
@@ -40,19 +41,6 @@ module Sinatra
|
|
40
41
|
EOF
|
41
42
|
end
|
42
43
|
|
43
|
-
path = File.expand_path(File.join(@app_dir, "spec", "apps", "#{self.underscored}_spec.rb"))
|
44
|
-
mkdir_p File.dirname(path), verbose: true
|
45
|
-
File.open(path, 'w') do |file|
|
46
|
-
file.puts <<-EOF
|
47
|
-
require 'spec_helper'
|
48
|
-
|
49
|
-
describe #{self.classified} do
|
50
|
-
|
51
|
-
it "does something"
|
52
|
-
|
53
|
-
end
|
54
|
-
EOF
|
55
|
-
end
|
56
44
|
end
|
57
45
|
|
58
46
|
end
|
@@ -23,5 +23,27 @@ module Sinatra
|
|
23
23
|
system command
|
24
24
|
end
|
25
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(Sinatra.template_dir, *path))
|
46
|
+
end
|
47
|
+
|
26
48
|
end
|
27
49
|
end
|
@@ -8,23 +8,10 @@ module Sinatra
|
|
8
8
|
def self.help
|
9
9
|
"model_name"
|
10
10
|
end
|
11
|
-
|
12
|
-
def initialize(*args)
|
13
|
-
super
|
14
|
-
@app_dir = File.expand_path(pwd)
|
15
|
-
end
|
16
11
|
|
17
12
|
def call
|
18
|
-
|
19
|
-
|
20
|
-
rm path, verbose: true
|
21
|
-
rescue Errno::ENOENT => e
|
22
|
-
end
|
23
|
-
path = File.expand_path(File.join(@app_dir, "spec", "models", "#{self.underscored}_spec.rb"))
|
24
|
-
begin
|
25
|
-
rm path, verbose: true
|
26
|
-
rescue Errno::ENOENT => e
|
27
|
-
end
|
13
|
+
rm app_path("models", "#{self.underscored}.rb")
|
14
|
+
rm app_path("spec", "models", "#{self.underscored}_spec.rb")
|
28
15
|
end
|
29
16
|
|
30
17
|
end
|
@@ -9,14 +9,9 @@ module Sinatra
|
|
9
9
|
"model_name"
|
10
10
|
end
|
11
11
|
|
12
|
-
def initialize(*args)
|
13
|
-
super
|
14
|
-
@app_dir = File.expand_path(pwd)
|
15
|
-
end
|
16
|
-
|
17
12
|
def call
|
18
|
-
path =
|
19
|
-
mkdir_p File.dirname(path), verbose: true
|
13
|
+
path = app_path("models", "#{self.underscored}.rb")
|
14
|
+
FileUtils.mkdir_p File.dirname(path), verbose: true
|
20
15
|
File.open(path, 'w') do |file|
|
21
16
|
file.puts <<-EOF
|
22
17
|
class #{self.classified}
|
@@ -27,8 +22,8 @@ module Sinatra
|
|
27
22
|
EOF
|
28
23
|
end
|
29
24
|
|
30
|
-
path =
|
31
|
-
mkdir_p File.dirname(path), verbose: true
|
25
|
+
path = app_path("spec", "models", "#{self.underscored}_spec.rb")
|
26
|
+
FileUtils.mkdir_p File.dirname(path), verbose: true
|
32
27
|
File.open(path, 'w') do |file|
|
33
28
|
file.puts <<-EOF
|
34
29
|
require 'spec_helper'
|
@@ -1,6 +1,5 @@
|
|
1
1
|
module Sinatra
|
2
2
|
class NameCommand < Sinatra::Command
|
3
|
-
include FileUtils
|
4
3
|
|
5
4
|
attr_accessor :args, :name
|
6
5
|
|
@@ -19,6 +18,7 @@ module Sinatra
|
|
19
18
|
def initialize(args)
|
20
19
|
self.args = args
|
21
20
|
self.name = ARGV[1]
|
21
|
+
@app_dir = File.expand_path(FileUtils.pwd)
|
22
22
|
end
|
23
23
|
|
24
24
|
def clean_string(f)
|
@@ -11,7 +11,7 @@ module Sinatra
|
|
11
11
|
|
12
12
|
def initialize(*args)
|
13
13
|
super
|
14
|
-
@app_dir = File.expand_path(File.join(pwd, self.underscored))
|
14
|
+
@app_dir = File.expand_path(File.join(FileUtils.pwd, self.underscored))
|
15
15
|
end
|
16
16
|
|
17
17
|
def classified
|
@@ -19,17 +19,31 @@ module Sinatra
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def call
|
22
|
-
mkdir self.underscored, verbose: true
|
23
|
-
Dir[
|
22
|
+
FileUtils.mkdir self.underscored, verbose: true
|
23
|
+
Dir[template_path("**", "*")].each do |f|
|
24
24
|
if File.directory?(f)
|
25
|
-
mkdir_p clean_string(f), verbose: true
|
25
|
+
FileUtils.mkdir_p clean_string(f), verbose: true
|
26
26
|
else
|
27
|
-
mkdir_p clean_string(File.dirname(f)), verbose: true
|
27
|
+
FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
|
28
28
|
File.open(clean_string(f), 'w') do |file|
|
29
29
|
file.puts clean_string(File.read(f))
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
33
|
+
File.open(app_path(".gitignore"), "w") do |f|
|
34
|
+
f.puts File.read(template_path(".gitignore"))
|
35
|
+
end
|
36
|
+
Dir[app_path("**", "*")].each do |file|
|
37
|
+
if File.directory?(file)
|
38
|
+
if Dir[File.join(file, "**", "*")].empty?
|
39
|
+
File.open(File.join(file, ".git-keep"), 'w') {|f| f.puts ""}
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
FileUtils.cd app_path
|
44
|
+
system "git init"
|
45
|
+
system "git add ."
|
46
|
+
system "git commit -a -m 'Initial Commit'"
|
33
47
|
end
|
34
48
|
|
35
49
|
end
|
@@ -10,11 +10,11 @@ module Sinatra
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call
|
13
|
-
path =
|
13
|
+
path = app_path("Procfile.#{self.env}")
|
14
14
|
if File.exists?(path)
|
15
15
|
cmd "bundle exec foreman start -f #{path}"
|
16
16
|
else
|
17
|
-
path =
|
17
|
+
path = app_path("Procfile")
|
18
18
|
cmd "bundle exec foreman start -f #{path}"
|
19
19
|
end
|
20
20
|
end
|
data/template_app/Gemfile
CHANGED
data/template_app/Gemfile.lock
CHANGED
@@ -13,12 +13,18 @@ GEM
|
|
13
13
|
i18n (~> 0.6)
|
14
14
|
multi_json (~> 1.0)
|
15
15
|
builder (3.0.4)
|
16
|
+
coderay (1.0.8)
|
16
17
|
coffee-script (2.2.0)
|
17
18
|
coffee-script-source
|
18
19
|
execjs
|
19
20
|
coffee-script-source (1.4.0)
|
20
21
|
daemons (1.1.9)
|
21
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)
|
22
28
|
eventmachine (1.0.0)
|
23
29
|
execjs (1.4.0)
|
24
30
|
multi_json (~> 1.0)
|
@@ -26,6 +32,7 @@ GEM
|
|
26
32
|
thor (>= 0.13.6)
|
27
33
|
hike (1.2.1)
|
28
34
|
i18n (0.6.1)
|
35
|
+
method_source (0.8.1)
|
29
36
|
mongoid (3.0.15)
|
30
37
|
activemodel (~> 3.1)
|
31
38
|
moped (~> 1.1)
|
@@ -34,6 +41,10 @@ GEM
|
|
34
41
|
moped (1.3.1)
|
35
42
|
multi_json (1.5.0)
|
36
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)
|
37
48
|
rack (1.4.1)
|
38
49
|
rack-protection (1.3.2)
|
39
50
|
rack
|
@@ -54,6 +65,7 @@ GEM
|
|
54
65
|
rack (~> 1.3, >= 1.3.6)
|
55
66
|
rack-protection (~> 1.2)
|
56
67
|
tilt (~> 1.3, >= 1.3.3)
|
68
|
+
slop (3.3.3)
|
57
69
|
sprockets (2.2.2)
|
58
70
|
hike (~> 1.2)
|
59
71
|
multi_json (~> 1.0)
|
@@ -73,8 +85,10 @@ PLATFORMS
|
|
73
85
|
DEPENDENCIES
|
74
86
|
activesupport
|
75
87
|
coffee-script
|
88
|
+
eco
|
76
89
|
foreman
|
77
90
|
mongoid
|
91
|
+
pry
|
78
92
|
rack-test
|
79
93
|
rspec
|
80
94
|
sass
|
@@ -8,8 +8,10 @@
|
|
8
8
|
<meta name="author" content="">
|
9
9
|
|
10
10
|
<script src='/assets/application.js'></script>
|
11
|
+
<script src='/assets/template_app.js'></script>
|
11
12
|
<%= bootstrap_assets %>
|
12
13
|
<link href="/assets/application.css" rel="stylesheet">
|
14
|
+
<link href="/assets/template_app.css" rel="stylesheet">
|
13
15
|
|
14
16
|
<!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
|
15
17
|
<!--[if lt IE 9]>
|
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra-template
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -69,7 +69,9 @@ files:
|
|
69
69
|
- template_app/apps/views/template_app/index.erb
|
70
70
|
- template_app/apps/views/template_app/layout.erb
|
71
71
|
- template_app/assets/javascripts/application.js.coffee
|
72
|
+
- template_app/assets/javascripts/template_app.js.coffee
|
72
73
|
- template_app/assets/stylesheets/application.css.scss
|
74
|
+
- template_app/assets/stylesheets/template_app.css.scss
|
73
75
|
- template_app/assets/templates/.git-keep
|
74
76
|
- template_app/config.ru
|
75
77
|
- template_app/models/.git-keep
|