cuba-template-generator 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -2
- data/LICENSE +1 -0
- data/README.md +1 -0
- data/Rakefile +4 -2
- data/lib/cuba/generator.rb +5 -3
- data/lib/cuba/generator/cli.rb +9 -4
- data/lib/cuba/generator/version.rb +1 -1
- data/lib/cuba/templates/app.erb +7 -2
- data/lib/cuba/templates/blog.erb +45 -0
- data/lib/cuba/templates/gemfile.erb +1 -1
- data/spec/cuba_template_generator_spec.rb +45 -7
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 650f62d9020467a88143d09ae14b6958356a2400
|
4
|
+
data.tar.gz: 5d94af7bf10b9e0a31565a832a58195aa43a2d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08c5710aafe27e991c25984af90c4fbe0f81874f7345359b4b8b4e74f1c327621a723bd52cfdccd0400df40fe48f0d8151d2f65465770d540ed05cffe0c85aa2'
|
7
|
+
data.tar.gz: 060c8fc02cf5913c305e0eca9d783f9b0049f023b4fe14d3edf3f3dc897347eacfac54a2c83c52bef92bb318189ff39d1bd0dc0ae89816ff877e57703298af89
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -5,8 +5,10 @@ require 'fileutils'
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
6
6
|
task.rspec_opts = ['--color', '--format progress', '--order random']
|
7
7
|
at_exit do
|
8
|
-
|
8
|
+
FileUtils.remove_entry_secure('app')
|
9
|
+
FileUtils.remove_entry_secure('api')
|
10
|
+
FileUtils.remove_entry_secure('blog')
|
9
11
|
end
|
10
12
|
end
|
11
13
|
|
12
|
-
task :
|
14
|
+
task default: :spec
|
data/lib/cuba/generator.rb
CHANGED
@@ -40,7 +40,7 @@ module Cuba
|
|
40
40
|
file.write setup_gemfile
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def create_sqlite_file
|
45
45
|
File.open("./#{@project_name}/sqlite.rb", 'w+') do |file|
|
46
46
|
file.write setup_sqlite
|
@@ -57,6 +57,8 @@ module Cuba
|
|
57
57
|
create_template 'app'
|
58
58
|
elsif @type.to_sym == :api
|
59
59
|
create_template 'api'
|
60
|
+
elsif @type.to_sym == :blog
|
61
|
+
create_template 'blog'
|
60
62
|
end
|
61
63
|
end
|
62
64
|
|
@@ -67,7 +69,7 @@ module Cuba
|
|
67
69
|
def setup_postgres
|
68
70
|
create_template 'postgres'
|
69
71
|
end
|
70
|
-
|
72
|
+
|
71
73
|
def setup_sqlite
|
72
74
|
create_template 'sqlite'
|
73
75
|
end
|
@@ -78,7 +80,7 @@ module Cuba
|
|
78
80
|
|
79
81
|
def create_template(name)
|
80
82
|
template = File.read File.join(APPROOT, 'templates/', "#{name}.erb")
|
81
|
-
erb(template,
|
83
|
+
erb(template, project_name: @project_name)
|
82
84
|
end
|
83
85
|
|
84
86
|
def erb(template, vars)
|
data/lib/cuba/generator/cli.rb
CHANGED
@@ -16,15 +16,20 @@ module Cuba
|
|
16
16
|
c.description = 'Creates a new Cuba app'
|
17
17
|
c.option '--type STRING', String, 'Creates an app with preferred type'
|
18
18
|
c.option '--database STRING', String, 'Setups a database configuration with DataMapper'
|
19
|
-
c.action do |
|
20
|
-
if options.type
|
19
|
+
c.action do |_args, options|
|
20
|
+
if options.type(:api)
|
21
21
|
generator = Cuba::Generator.new(ARGV[1], options.type)
|
22
22
|
generator.create_postgres_file if options.database == 'postgresql'
|
23
|
-
|
24
|
-
|
23
|
+
generator.create_sqlite_file if options.database == 'sqlite'
|
24
|
+
elsif options.type(:app)
|
25
25
|
generator = Cuba::Generator.new(ARGV[1], :app)
|
26
26
|
generator.create_postgres_file if options.database == 'postgresql'
|
27
27
|
generator.create_sqlite_file if options.database == 'sqlite'
|
28
|
+
elsif option.type(:blog)
|
29
|
+
generator = Cuba::Generator.new(ARGV[1], :blog)
|
30
|
+
generator.create_postgres_file if options.database == 'postgresql'
|
31
|
+
generator.create_sqlite_file if options.database == 'sqlite'
|
32
|
+
|
28
33
|
end
|
29
34
|
end
|
30
35
|
end
|
data/lib/cuba/templates/app.erb
CHANGED
@@ -2,10 +2,9 @@
|
|
2
2
|
<<-TEMPLATE
|
3
3
|
require 'cuba'
|
4
4
|
|
5
|
-
Cuba.use Rack::Session::Cookie, :secret => "#{SecureRandom.base64(64)}"
|
6
|
-
|
7
5
|
# If you need extra protection.
|
8
6
|
# require 'rack/protection'
|
7
|
+
# Cuba.use Rack::Session::Cookie, secret: Random.new_seed.to_s
|
9
8
|
# Cuba.use Rack::Protection
|
10
9
|
# Cuba.use Rack::Protection::RemoteReferrer
|
11
10
|
|
@@ -20,6 +19,12 @@ Cuba.use Rack::Session::Cookie, :secret => "#{SecureRandom.base64(64)}"
|
|
20
19
|
# Cuba.settings[:render][:template_engine] = "erb"
|
21
20
|
# Cuba.settings[:render][:views] = "./views"
|
22
21
|
|
22
|
+
# If you need static assets just create the folder public and subfolders /css /imgs /js
|
23
|
+
# depending on your needs within the project folder then uncomment the ones you created.
|
24
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/css"]
|
25
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/imgs"]
|
26
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/js"]
|
27
|
+
|
23
28
|
# To launch just type: 'rackup' in your console
|
24
29
|
Cuba.define do
|
25
30
|
on get do
|
@@ -0,0 +1,45 @@
|
|
1
|
+
<%=
|
2
|
+
<<-TEMPLATE
|
3
|
+
require 'cuba'
|
4
|
+
|
5
|
+
# If you need extra protection.
|
6
|
+
# require 'rack/protection'
|
7
|
+
# Cuba.use Rack::Session::Cookie, secret: Random.new_seed.to_s
|
8
|
+
# Cuba.use Rack::Protection
|
9
|
+
# Cuba.use Rack::Protection::RemoteReferrer
|
10
|
+
|
11
|
+
# Cuba includes a plugin called Cuba::Render that provides a couple of helper methods for rendering templates.
|
12
|
+
# require "cuba/render"
|
13
|
+
# Cuba.plugin(Cuba::Render)
|
14
|
+
|
15
|
+
# This plugin uses Tilt, which serves as an interface to a bunch of different Ruby template engines
|
16
|
+
# (ERB, Haml, Sass, CoffeeScript, etc.), so you can use the template engine of your choice.
|
17
|
+
|
18
|
+
# require 'erb'
|
19
|
+
# Cuba.settings[:render][:template_engine] = "erb"
|
20
|
+
# Cuba.settings[:render][:views] = "./views"
|
21
|
+
|
22
|
+
# If you need static assets just create the folder public and subfolders /css /imgs /js
|
23
|
+
# depending on your needs within the project folder then uncomment the ones you created.
|
24
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/css"]
|
25
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/imgs"]
|
26
|
+
# Cuba.use Rack::Static, root: "public", urls: ["/js"]
|
27
|
+
|
28
|
+
# To launch just type: 'rackup' in your console
|
29
|
+
Cuba.define do
|
30
|
+
on get do
|
31
|
+
on root do
|
32
|
+
res.write "Hello #{project_name}"
|
33
|
+
end
|
34
|
+
on 'article/:y/:m/:d/:title' do |y, m, d, title|
|
35
|
+
# Put your markdown files within a directory called articles
|
36
|
+
# With the naming conversion of year-month-day-title.md
|
37
|
+
markdown = File.read("./articles/1999-12-31-happynewyear.md")
|
38
|
+
@article_page = Kramdown::Document.new(markdown).to_html
|
39
|
+
res.write (@article_page)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
TEMPLATE
|
45
|
+
%>
|
@@ -1,20 +1,58 @@
|
|
1
1
|
require 'cuba/generator'
|
2
2
|
|
3
|
-
describe Cuba::Generator do
|
4
|
-
|
3
|
+
describe 'create a api', Cuba::Generator do
|
4
|
+
subject_api = Cuba::Generator.new('api', 'api')
|
5
5
|
|
6
6
|
it 'create_dir' do
|
7
7
|
expect(Dir).to receive(:mkdir)
|
8
|
-
|
8
|
+
subject_api.create_dir
|
9
9
|
end
|
10
10
|
|
11
11
|
it 'create_config_file' do
|
12
|
-
expect(File).to receive(:open).with('./
|
13
|
-
|
12
|
+
expect(File).to receive(:open).with('./api/config.ru', 'w+')
|
13
|
+
subject_api.create_config_file
|
14
14
|
end
|
15
15
|
|
16
16
|
it 'create_cuba_file' do
|
17
|
-
expect(File).to receive(:open).with('./
|
18
|
-
|
17
|
+
expect(File).to receive(:open).with('./api/api.rb', 'w+')
|
18
|
+
subject_api.create_cuba_file
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe 'create a app', Cuba::Generator do
|
23
|
+
subject_app = Cuba::Generator.new('app', 'app')
|
24
|
+
|
25
|
+
it 'create_dir' do
|
26
|
+
expect(Dir).to receive(:mkdir)
|
27
|
+
subject_app.create_dir
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'create_config_file' do
|
31
|
+
expect(File).to receive(:open).with('./app/config.ru', 'w+')
|
32
|
+
subject_app.create_config_file
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'create_cuba_file' do
|
36
|
+
expect(File).to receive(:open).with('./app/app.rb', 'w+')
|
37
|
+
subject_app.create_cuba_file
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe 'create a blog', Cuba::Generator do
|
42
|
+
subject_blog = Cuba::Generator.new('blog', 'blog')
|
43
|
+
|
44
|
+
it 'create_dir' do
|
45
|
+
expect(Dir).to receive(:mkdir)
|
46
|
+
subject_blog.create_dir
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'create_config_file' do
|
50
|
+
expect(File).to receive(:open).with('./blog/config.ru', 'w+')
|
51
|
+
subject_blog.create_config_file
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'create_cuba_file' do
|
55
|
+
expect(File).to receive(:open).with('./blog/blog.rb', 'w+')
|
56
|
+
subject_blog.create_cuba_file
|
19
57
|
end
|
20
58
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba-template-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Viera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/cuba/generator/version.rb
|
102
102
|
- lib/cuba/templates/api.erb
|
103
103
|
- lib/cuba/templates/app.erb
|
104
|
+
- lib/cuba/templates/blog.erb
|
104
105
|
- lib/cuba/templates/gemfile.erb
|
105
106
|
- lib/cuba/templates/postgres.erb
|
106
107
|
- lib/cuba/templates/rack_config.erb
|
@@ -126,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
126
127
|
version: '0'
|
127
128
|
requirements: []
|
128
129
|
rubyforge_project:
|
129
|
-
rubygems_version: 2.
|
130
|
+
rubygems_version: 2.6.11
|
130
131
|
signing_key:
|
131
132
|
specification_version: 4
|
132
133
|
summary: Application Generator for Cuba framework.
|