cuba-generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/.travis.yml +6 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +22 -0
- data/README.md +26 -0
- data/Rakefile +8 -0
- data/bin/cuba +12 -0
- data/cuba-generator.gemspec +25 -0
- data/lib/cuba/generator/version.rb +5 -0
- data/lib/cuba/generator.rb +46 -0
- data/lib/cuba/templates/app.erb +39 -0
- data/lib/cuba/templates/rack_config.erb +6 -0
- data/spec/cuba_generator_spec.rb +20 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fd8c8be4e69d98f5b6299927e26fc0c9202611b4
|
4
|
+
data.tar.gz: 2caa9d92ae816b8060a2c2c274543861375ab290
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f4ddb3ff10bab1580857f02139b5406072ffb79d83efd2f8128eed408be2c3b0a90914fe531130c78cc2c586710271717e9ad3e00850f078b582717ec561f9b6
|
7
|
+
data.tar.gz: 3b3f6fdfd1c82ea5e1fd676e436cd35deb5db9923dc135231670d1b951d783a7b32c0adcd4f78e045d051f1a983f96f1ff4e1b3db2c3f89b461c6153097e5902
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Serdar Doğruyol
|
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,26 @@
|
|
1
|
+
# cuba-generator
|
2
|
+
|
3
|
+
cuba-generator is a generator to help creating Cuba projects.
|
4
|
+
|
5
|
+
[Cuba](https://github.com/soveran/cuba) is a micro-framework for Ruby based on Rack.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
$ gem install cuba-generator
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
$ cuba new [projectName]
|
14
|
+
|
15
|
+
This will create your cuba project with its 2 files:
|
16
|
+
|
17
|
+
* The config.ru to ```rackup```your project.
|
18
|
+
* The projectname.rb file that contains your project config and routes.
|
19
|
+
|
20
|
+
## Contributing
|
21
|
+
|
22
|
+
1. Fork it ( https://github.com/Sdogruyol/cuba-generator/fork )
|
23
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
24
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
25
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
26
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/cuba
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "cuba/generator"
|
4
|
+
|
5
|
+
if ARGV.length == 2 && ARGV[0] == 'new'
|
6
|
+
project = Cuba::Generator.new(ARGV[1])
|
7
|
+
project.create_dir
|
8
|
+
project.create_cuba_file
|
9
|
+
project.create_config_file
|
10
|
+
else
|
11
|
+
puts "cuba new <projectName>"
|
12
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cuba/generator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'cuba-generator'
|
8
|
+
spec.version = Cuba::Generator::VERSION
|
9
|
+
spec.authors = ['Serdar Dogruyol']
|
10
|
+
spec.email = ['dogruyolserdar@gmail.com']
|
11
|
+
spec.summary = %q{Generator for Cuba framework.}
|
12
|
+
spec.description = %q{Helps create cuba projects through a minimalist generator.}
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
|
+
spec.add_runtime_dependency 'cuba', '~> 3.3.0'
|
25
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'cuba/generator/version'
|
2
|
+
require 'securerandom'
|
3
|
+
require 'erb'
|
4
|
+
require 'ostruct'
|
5
|
+
|
6
|
+
module Cuba
|
7
|
+
class Generator
|
8
|
+
APPROOT = File.expand_path(File.dirname(__FILE__))
|
9
|
+
|
10
|
+
def initialize(name)
|
11
|
+
@project_name = name.downcase
|
12
|
+
end
|
13
|
+
|
14
|
+
def create_dir
|
15
|
+
Dir.mkdir(@project_name)
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_config_file
|
19
|
+
File.open("./#{@project_name}/config.ru", 'w+') do |file|
|
20
|
+
file.write setup_config
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def create_cuba_file
|
25
|
+
File.open("./#{@project_name}/#{@project_name}.rb", 'w+') do |file|
|
26
|
+
file.write setup_cuba
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def setup_cuba
|
33
|
+
path = File.read File.join(APPROOT, './templates/app.erb')
|
34
|
+
erb(path, {project_name: @project_name})
|
35
|
+
end
|
36
|
+
|
37
|
+
def setup_config
|
38
|
+
path = File.read File.join(APPROOT, './templates/rack_config.erb')
|
39
|
+
erb(path, {project_name: @project_name})
|
40
|
+
end
|
41
|
+
|
42
|
+
def erb(template, vars)
|
43
|
+
ERB.new(template).result(OpenStruct.new(vars).instance_eval { binding })
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%= <<-TEMPLATE.gsub /^\s+/, ""
|
2
|
+
require 'cuba'
|
3
|
+
|
4
|
+
# If you need extra protection.
|
5
|
+
# require 'rack/protection'
|
6
|
+
# Cuba.use Rack::Protection
|
7
|
+
# Cuba.use Rack::Protection::RemoteReferrer
|
8
|
+
|
9
|
+
Cuba.use Rack::Session::Cookie, :secret => "#{SecureRandom.base64(64)}"
|
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
|
+
# require 'slim'
|
18
|
+
# Cuba.settings[:render][:template_engine] = 'slim'
|
19
|
+
|
20
|
+
# Cuba.settings[:render][:template_engine] = "slim"
|
21
|
+
# Cuba.settings[:render][:views] = "./views/admin/"
|
22
|
+
# Cuba.settings[:render][:layout] = "admin"
|
23
|
+
|
24
|
+
# To launch just type: 'rackup' in your console
|
25
|
+
Cuba.define do
|
26
|
+
on get do
|
27
|
+
on "#{project_name}" do
|
28
|
+
on root do
|
29
|
+
res.write 'Hello world!'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
on root do
|
34
|
+
res.redirect "/#{project_name}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
TEMPLATE
|
39
|
+
%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'cuba/generator'
|
2
|
+
|
3
|
+
describe Cuba::Generator do
|
4
|
+
subject { Cuba::Generator.new('myProject') }
|
5
|
+
|
6
|
+
it 'create_dir' do
|
7
|
+
expect(Dir).to receive(:mkdir)
|
8
|
+
subject.create_dir
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'create_config_file' do
|
12
|
+
expect(File).to receive(:open).with('./myproject/config.ru', 'w+')
|
13
|
+
subject.create_config_file
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'create_cuba_file' do
|
17
|
+
expect(File).to receive(:open).with('./myproject/myproject.rb', 'w+')
|
18
|
+
subject.create_cuba_file
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cuba-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Serdar Dogruyol
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.1.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.1.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: cuba
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.3.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 3.3.0
|
69
|
+
description: Helps create cuba projects through a minimalist generator.
|
70
|
+
email:
|
71
|
+
- dogruyolserdar@gmail.com
|
72
|
+
executables:
|
73
|
+
- cuba
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/cuba
|
84
|
+
- cuba-generator.gemspec
|
85
|
+
- lib/cuba/generator.rb
|
86
|
+
- lib/cuba/generator/version.rb
|
87
|
+
- lib/cuba/templates/app.erb
|
88
|
+
- lib/cuba/templates/rack_config.erb
|
89
|
+
- spec/cuba_generator_spec.rb
|
90
|
+
homepage: ''
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.5
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Generator for Cuba framework.
|
114
|
+
test_files:
|
115
|
+
- spec/cuba_generator_spec.rb
|