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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 35954643d0459816829c12ad1c058c65e62ea909
4
- data.tar.gz: 4f70c3e2c88c69c729e4351afab487f16799d551
3
+ metadata.gz: 650f62d9020467a88143d09ae14b6958356a2400
4
+ data.tar.gz: 5d94af7bf10b9e0a31565a832a58195aa43a2d3b
5
5
  SHA512:
6
- metadata.gz: 82c9e0432a812eb4d991d7ba50317db2e5da7f8d4bba42132387965e66c13bb9d516eb7f62afda280daa459b38b87125a3c7dc52f306e00607c598f4185badf0
7
- data.tar.gz: ead308e1a2587e352f74c592d6944dc7a38ca151e7d1af5a732c7fc315125a6eef4a6c9ec9301a75d591dc41f43d81a6afe07e2ca5180f6d815dd105c9d2b3ef
6
+ metadata.gz: '08c5710aafe27e991c25984af90c4fbe0f81874f7345359b4b8b4e74f1c327621a723bd52cfdccd0400df40fe48f0d8151d2f65465770d540ed05cffe0c85aa2'
7
+ data.tar.gz: 060c8fc02cf5913c305e0eca9d783f9b0049f023b4fe14d3edf3f3dc897347eacfac54a2c83c52bef92bb318189ff39d1bd0dc0ae89816ff877e57703298af89
data/.travis.yml CHANGED
@@ -1,6 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - "2.1.4"
5
- - "jruby"
4
+ - 2.2.7
5
+ - 2.3.4
6
+ - 2.4.1
6
7
  script: 'bundle exec rake'
data/LICENSE CHANGED
@@ -1,3 +1,4 @@
1
+ Copyright (c) 2015 Serdar Doğruyol
1
2
  Copyright (c) 2016 Derek Viera
2
3
 
3
4
  MIT License
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
 
2
2
  # cuba-template-generator
3
+ [![Build Status](https://travis-ci.org/rangeroob/cuba-template-generator.svg?branch=dev)](https://travis-ci.org/rangeroob/cuba-template-generator)
3
4
 
4
5
  cuba-template-generator is a generator to help creating Cuba projects.
5
6
 
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
- FileUtils.remove_entry_secure('myproject')
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 :default => :spec
14
+ task default: :spec
@@ -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, {project_name: @project_name})
83
+ erb(template, project_name: @project_name)
82
84
  end
83
85
 
84
86
  def erb(template, vars)
@@ -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 |args, options|
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
- generartor.create_sqlite_file if options.database == 'sqlite'
24
- else
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
@@ -1,5 +1,5 @@
1
1
  module Cuba
2
2
  class Generator
3
- VERSION = "0.1.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
@@ -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
+ %>
@@ -11,6 +11,6 @@ gem 'cuba'
11
11
  # postgresql dependencies
12
12
  # gem 'pg'
13
13
  # sqlite dependencies
14
- #gem 'sqlite3'
14
+ # gem 'sqlite3'
15
15
  TEMPLATE
16
16
  %>
@@ -1,20 +1,58 @@
1
1
  require 'cuba/generator'
2
2
 
3
- describe Cuba::Generator do
4
- subject = Cuba::Generator.new('myProject','app')
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
- subject.create_dir
8
+ subject_api.create_dir
9
9
  end
10
10
 
11
11
  it 'create_config_file' do
12
- expect(File).to receive(:open).with('./myproject/config.ru', 'w+')
13
- subject.create_config_file
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('./myproject/myproject.rb', 'w+')
18
- subject.create_cuba_file
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: 0.1.0
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: 2016-12-13 00:00:00.000000000 Z
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.4.5.1
130
+ rubygems_version: 2.6.11
130
131
  signing_key:
131
132
  specification_version: 4
132
133
  summary: Application Generator for Cuba framework.