cuba-template-generator 1.0.0 → 1.2.2
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 -3
- data/LICENSE +1 -1
- data/Rakefile +1 -1
- data/cuba-template-generator.gemspec +1 -1
- data/lib/cuba/generator.rb +18 -6
- data/lib/cuba/generator/cli.rb +1 -2
- data/lib/cuba/generator/version.rb +1 -1
- data/lib/cuba/templates/.gitignore.erb +54 -0
- data/lib/cuba/templates/api.erb +11 -3
- data/lib/cuba/templates/app.erb +13 -3
- data/lib/cuba/templates/blog.erb +12 -3
- data/spec/cuba_template_generator_spec.rb +30 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8816fc0aadd2bc0c2d2ad93d8c0b65fe14a7f9d6
|
4
|
+
data.tar.gz: 9068a16ea7fa2374e904212c40bb1cf524f69f00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b48e8304d038787624c2a4811298bc794dd1c990e7cc07a0affe1104db506dbfa01631c057646f18a8186da6b84c06a99752fbac0d7b8993ba596e806c2ee128
|
7
|
+
data.tar.gz: db22de4fb9eaddeff8f59ccc877aecb0661a946abff75ee2a3da03e5a533a66ee060dbc76c2d6c392d44fb70b084ed5e947f280779af7ab699842af9e645b77c
|
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/Rakefile
CHANGED
@@ -3,7 +3,7 @@ require 'rspec/core/rake_task'
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec) do |task|
|
6
|
-
task.rspec_opts = ['--color', '--format
|
6
|
+
task.rspec_opts = ['--color', '--format documentation', '--order random']
|
7
7
|
at_exit do
|
8
8
|
FileUtils.remove_entry_secure('app')
|
9
9
|
FileUtils.remove_entry_secure('api')
|
@@ -22,5 +22,5 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
24
|
spec.add_dependency 'cuba', '~> 3.4.0'
|
25
|
-
spec.add_runtime_dependency 'commander', '~> 4.
|
25
|
+
spec.add_runtime_dependency 'commander', '~> 4.4.0'
|
26
26
|
end
|
data/lib/cuba/generator.rb
CHANGED
@@ -13,6 +13,8 @@ module Cuba
|
|
13
13
|
create_dir
|
14
14
|
create_config_file
|
15
15
|
create_cuba_file
|
16
|
+
create_gemfile
|
17
|
+
create_gitignore
|
16
18
|
puts "Created your Cuba #{@type} at /#{@project_name} directory. Rock on!"
|
17
19
|
end
|
18
20
|
|
@@ -32,22 +34,28 @@ module Cuba
|
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
37
|
+
def create_gemfile
|
38
|
+
File.open("./#{@project_name}/Gemfile", 'w+') do |file|
|
39
|
+
file.write setup_gemfile
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def create_gitignore
|
44
|
+
File.open("./#{@project_name}/.gitignore", 'w+') do |file|
|
45
|
+
file.write setup_gitignore
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
35
49
|
def create_postgres_file
|
36
50
|
File.open("./#{@project_name}/postgres.rb", 'w+') do |file|
|
37
51
|
file.write setup_postgres
|
38
52
|
end
|
39
|
-
File.open("./#{@project_name}/Gemfile", 'w+') do |file|
|
40
|
-
file.write setup_gemfile
|
41
|
-
end
|
42
53
|
end
|
43
54
|
|
44
55
|
def create_sqlite_file
|
45
56
|
File.open("./#{@project_name}/sqlite.rb", 'w+') do |file|
|
46
57
|
file.write setup_sqlite
|
47
58
|
end
|
48
|
-
File.open("./#{@project_name}/Gemfile", 'w+') do |file|
|
49
|
-
file.write setup_gemfile
|
50
|
-
end
|
51
59
|
end
|
52
60
|
|
53
61
|
private
|
@@ -78,6 +86,10 @@ module Cuba
|
|
78
86
|
create_template 'gemfile'
|
79
87
|
end
|
80
88
|
|
89
|
+
def setup_gitignore
|
90
|
+
create_template '.gitignore'
|
91
|
+
end
|
92
|
+
|
81
93
|
def create_template(name)
|
82
94
|
template = File.read File.join(APPROOT, 'templates/', "#{name}.erb")
|
83
95
|
erb(template, project_name: @project_name)
|
data/lib/cuba/generator/cli.rb
CHANGED
@@ -25,11 +25,10 @@ module Cuba
|
|
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
|
28
|
+
elsif options.type(:blog)
|
29
29
|
generator = Cuba::Generator.new(ARGV[1], :blog)
|
30
30
|
generator.create_postgres_file if options.database == 'postgresql'
|
31
31
|
generator.create_sqlite_file if options.database == 'sqlite'
|
32
|
-
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<%=
|
2
|
+
<<-TEMPLATE
|
3
|
+
*.gem
|
4
|
+
*.rbc
|
5
|
+
/.config
|
6
|
+
/coverage/
|
7
|
+
/InstalledFiles
|
8
|
+
/pkg/
|
9
|
+
/spec/reports/
|
10
|
+
/spec/examples.txt
|
11
|
+
/test/tmp/
|
12
|
+
/test/version_tmp/
|
13
|
+
/tmp/
|
14
|
+
/db/
|
15
|
+
# Used by dotenv library to load environment variables.
|
16
|
+
# .env
|
17
|
+
|
18
|
+
## Specific to RubyMotion:
|
19
|
+
.dat*
|
20
|
+
.repl_history
|
21
|
+
build/
|
22
|
+
*.bridgesupport
|
23
|
+
build-iPhoneOS/
|
24
|
+
build-iPhoneSimulator/
|
25
|
+
|
26
|
+
## Specific to RubyMotion (use of CocoaPods):
|
27
|
+
#
|
28
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
29
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
30
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
31
|
+
#
|
32
|
+
# vendor/Pods/
|
33
|
+
|
34
|
+
## Documentation cache and generated files:
|
35
|
+
/.yardoc/
|
36
|
+
/_yardoc/
|
37
|
+
/doc/
|
38
|
+
/rdoc/
|
39
|
+
|
40
|
+
## Environment normalization:
|
41
|
+
/.bundle/
|
42
|
+
/vendor/bundle
|
43
|
+
/lib/bundler/man/
|
44
|
+
|
45
|
+
# for a library or gem, you might want to ignore these files since the code is
|
46
|
+
# intended to run in multiple environments; otherwise, check them in:
|
47
|
+
# Gemfile.lock
|
48
|
+
# .ruby-version
|
49
|
+
# .ruby-gemset
|
50
|
+
|
51
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
52
|
+
.rvmrc
|
53
|
+
TEMPLATE
|
54
|
+
%>
|
data/lib/cuba/templates/api.erb
CHANGED
@@ -4,12 +4,20 @@ require 'cuba'
|
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
# If you need extra protection.
|
7
|
-
# require '
|
8
|
-
# Cuba.
|
9
|
-
# Cuba.use Rack::Protection::RemoteReferrer
|
7
|
+
# require 'cuba/safe'
|
8
|
+
# Cuba.plugin Cuba::Safe
|
10
9
|
|
11
10
|
# To launch just type: 'rackup' in your console
|
12
11
|
Cuba.define do
|
12
|
+
# Uncomment if you want to use cuba/safe
|
13
|
+
# on csrf.unsafe? do
|
14
|
+
# csrf.reset!
|
15
|
+
|
16
|
+
# res.status = 403
|
17
|
+
# res.write("Not authorized")
|
18
|
+
|
19
|
+
# halt(res.finish)
|
20
|
+
# end
|
13
21
|
on get do
|
14
22
|
|
15
23
|
on root do
|
data/lib/cuba/templates/app.erb
CHANGED
@@ -3,10 +3,11 @@
|
|
3
3
|
require 'cuba'
|
4
4
|
|
5
5
|
# If you need extra protection.
|
6
|
-
# require '
|
6
|
+
# require 'cuba/safe'
|
7
|
+
# Cuba.plugin Cuba::Safe
|
8
|
+
|
9
|
+
|
7
10
|
# Cuba.use Rack::Session::Cookie, secret: Random.new_seed.to_s
|
8
|
-
# Cuba.use Rack::Protection
|
9
|
-
# Cuba.use Rack::Protection::RemoteReferrer
|
10
11
|
|
11
12
|
# Cuba includes a plugin called Cuba::Render that provides a couple of helper methods for rendering templates.
|
12
13
|
# require "cuba/render"
|
@@ -27,6 +28,15 @@ require 'cuba'
|
|
27
28
|
|
28
29
|
# To launch just type: 'rackup' in your console
|
29
30
|
Cuba.define do
|
31
|
+
# Uncomment if you want to use cuba/safe
|
32
|
+
# on csrf.unsafe? do
|
33
|
+
# csrf.reset!
|
34
|
+
|
35
|
+
# res.status = 403
|
36
|
+
# res.write("Not authorized")
|
37
|
+
|
38
|
+
# halt(res.finish)
|
39
|
+
# end
|
30
40
|
on get do
|
31
41
|
|
32
42
|
on root do
|
data/lib/cuba/templates/blog.erb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
require 'cuba'
|
4
4
|
|
5
5
|
# If you need extra protection.
|
6
|
-
# require '
|
6
|
+
# require 'cuba/safe'
|
7
|
+
# Cuba.plugin Cuba::Safe
|
8
|
+
|
7
9
|
# Cuba.use Rack::Session::Cookie, secret: Random.new_seed.to_s
|
8
|
-
# Cuba.use Rack::Protection
|
9
|
-
# Cuba.use Rack::Protection::RemoteReferrer
|
10
10
|
|
11
11
|
# Cuba includes a plugin called Cuba::Render that provides a couple of helper methods for rendering templates.
|
12
12
|
# require "cuba/render"
|
@@ -27,6 +27,15 @@ require 'cuba'
|
|
27
27
|
|
28
28
|
# To launch just type: 'rackup' in your console
|
29
29
|
Cuba.define do
|
30
|
+
# Uncomment if you want to use cuba/safe
|
31
|
+
# on csrf.unsafe? do
|
32
|
+
# csrf.reset!
|
33
|
+
|
34
|
+
# res.status = 403
|
35
|
+
# res.write("Not authorized")
|
36
|
+
|
37
|
+
# halt(res.finish)
|
38
|
+
# end
|
30
39
|
on get do
|
31
40
|
on root do
|
32
41
|
res.write "Hello #{project_name}"
|
@@ -17,6 +17,16 @@ describe 'create a api', Cuba::Generator do
|
|
17
17
|
expect(File).to receive(:open).with('./api/api.rb', 'w+')
|
18
18
|
subject_api.create_cuba_file
|
19
19
|
end
|
20
|
+
|
21
|
+
it 'create_gemfile' do
|
22
|
+
expect(File).to receive(:open).with('./api/Gemfile', 'w+')
|
23
|
+
subject_api.create_gemfile
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'create_gitignore' do
|
27
|
+
expect(File).to receive(:open).with('./api/.gitignore', 'w+')
|
28
|
+
subject_api.create_gitignore
|
29
|
+
end
|
20
30
|
end
|
21
31
|
|
22
32
|
describe 'create a app', Cuba::Generator do
|
@@ -36,6 +46,16 @@ describe 'create a app', Cuba::Generator do
|
|
36
46
|
expect(File).to receive(:open).with('./app/app.rb', 'w+')
|
37
47
|
subject_app.create_cuba_file
|
38
48
|
end
|
49
|
+
|
50
|
+
it 'create_gemfile' do
|
51
|
+
expect(File).to receive(:open).with('./app/Gemfile', 'w+')
|
52
|
+
subject_app.create_gemfile
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'create_gitignore' do
|
56
|
+
expect(File).to receive(:open).with('./app/.gitignore', 'w+')
|
57
|
+
subject_app.create_gitignore
|
58
|
+
end
|
39
59
|
end
|
40
60
|
|
41
61
|
describe 'create a blog', Cuba::Generator do
|
@@ -55,4 +75,14 @@ describe 'create a blog', Cuba::Generator do
|
|
55
75
|
expect(File).to receive(:open).with('./blog/blog.rb', 'w+')
|
56
76
|
subject_blog.create_cuba_file
|
57
77
|
end
|
78
|
+
|
79
|
+
it 'create_gemfile' do
|
80
|
+
expect(File).to receive(:open).with('./blog/Gemfile', 'w+')
|
81
|
+
subject_blog.create_gemfile
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'create_gitignore' do
|
85
|
+
expect(File).to receive(:open).with('./blog/.gitignore', 'w+')
|
86
|
+
subject_blog.create_gitignore
|
87
|
+
end
|
58
88
|
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: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Derek Viera
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.
|
75
|
+
version: 4.4.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.
|
82
|
+
version: 4.4.0
|
83
83
|
description: Helps create cuba projects through a minimalist generator.
|
84
84
|
email:
|
85
85
|
- ma.dmviera01@gmail.com
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- lib/cuba/generator.rb
|
100
100
|
- lib/cuba/generator/cli.rb
|
101
101
|
- lib/cuba/generator/version.rb
|
102
|
+
- lib/cuba/templates/.gitignore.erb
|
102
103
|
- lib/cuba/templates/api.erb
|
103
104
|
- lib/cuba/templates/app.erb
|
104
105
|
- lib/cuba/templates/blog.erb
|