cuba-generator 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/bin/cuba +6 -6
- data/cuba-generator.gemspec +3 -2
- data/lib/cuba/generator/cli.rb +29 -0
- data/lib/cuba/generator/version.rb +1 -1
- data/lib/cuba/generator.rb +9 -4
- data/lib/cuba/templates/api.erb +24 -0
- data/lib/cuba/templates/app.erb +1 -4
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a24fdbf4bf0d88e6cc34b511f106b4d09cf7952
|
4
|
+
data.tar.gz: eac6e9a26964284e52de58fe65c24e37286c1160
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 557625f97ed98ea6f9f5e4462b78b153f2ee1b6de5ac280b7a3b4a171ed9e5025ac7c0b3645a372071b2bf352c12dfd5c85c8a3b05907937cd8164cb8e966a4b
|
7
|
+
data.tar.gz: 10a464aaba4eb0d3264a643e0b5122ae7a33dedab4970a887902dc7fd0e69d5c59feb7b0ce3f8b76a7801f26e4fb38cb737ba4cf2c8f8a87863b96150107ba0e
|
data/.gitignore
CHANGED
data/bin/cuba
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
#!/usr/bin/env ruby
|
4
|
+
|
5
|
+
# encoding: utf-8
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
puts "cuba new <projectName>"
|
9
|
-
end
|
7
|
+
$LOAD_PATH.unshift(File.dirname(File.realpath(__FILE__)) + '/../lib')
|
8
|
+
require 'cuba/generator/cli'
|
9
|
+
Cuba::Cli.new.run
|
data/cuba-generator.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Cuba::Generator::VERSION
|
9
9
|
spec.authors = ['Serdar Dogruyol']
|
10
10
|
spec.email = ['dogruyolserdar@gmail.com']
|
11
|
-
spec.summary = %q{Generator for Cuba framework.}
|
11
|
+
spec.summary = %q{Application Generator for Cuba framework.}
|
12
12
|
spec.description = %q{Helps create cuba projects through a minimalist generator.}
|
13
13
|
spec.homepage = ''
|
14
14
|
spec.license = 'MIT'
|
@@ -21,5 +21,6 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
22
22
|
spec.add_development_dependency 'rake', '~> 10.0'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
24
|
-
spec.
|
24
|
+
spec.add_dependency 'cuba', '~> 3.3.0'
|
25
|
+
spec.add_runtime_dependency 'commander', '~> 4.3.0'
|
25
26
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'commander'
|
2
|
+
require_relative 'version'
|
3
|
+
require_relative '../generator'
|
4
|
+
|
5
|
+
module Cuba
|
6
|
+
class Cli
|
7
|
+
include Commander::Methods
|
8
|
+
|
9
|
+
def run
|
10
|
+
program :name, 'cuba'
|
11
|
+
program :version, Cuba::Generator::VERSION
|
12
|
+
program :description, 'Application Generator for Cuba framework.'
|
13
|
+
|
14
|
+
command :new do |c|
|
15
|
+
c.syntax = 'cuba new [options]'
|
16
|
+
c.description = 'Creates a new Cuba app'
|
17
|
+
c.option '--type STRING', String, 'Creates an app with preferred type'
|
18
|
+
c.action do |args, options|
|
19
|
+
if options.type
|
20
|
+
Cuba::Generator.new(ARGV[1], options.type)
|
21
|
+
else
|
22
|
+
Cuba::Generator.new(ARGV[1], :app)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
run!
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/cuba/generator.rb
CHANGED
@@ -7,12 +7,13 @@ module Cuba
|
|
7
7
|
class Generator
|
8
8
|
APPROOT = File.expand_path(File.dirname(__FILE__))
|
9
9
|
|
10
|
-
def initialize(name)
|
10
|
+
def initialize(name, type)
|
11
11
|
@project_name = name.downcase
|
12
|
+
@type = type
|
12
13
|
create_dir
|
13
14
|
create_config_file
|
14
15
|
create_cuba_file
|
15
|
-
puts "Created your Cuba
|
16
|
+
puts "Created your Cuba #{@type} at /#{@project_name} directory. Rock on!"
|
16
17
|
end
|
17
18
|
|
18
19
|
def create_dir
|
@@ -34,8 +35,12 @@ module Cuba
|
|
34
35
|
private
|
35
36
|
|
36
37
|
def setup_cuba
|
37
|
-
path =
|
38
|
-
|
38
|
+
path = if @type.to_sym == :app
|
39
|
+
File.read File.join(APPROOT, './templates/app.erb')
|
40
|
+
elsif @type.to_sym == :api
|
41
|
+
File.read File.join(APPROOT, './templates/api.erb')
|
42
|
+
end
|
43
|
+
erb(path, {project_name: @project_name})
|
39
44
|
end
|
40
45
|
|
41
46
|
def setup_config
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<%=
|
2
|
+
<<-TEMPLATE
|
3
|
+
require 'cuba'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
# If you need extra protection.
|
7
|
+
# require 'rack/protection'
|
8
|
+
# Cuba.use Rack::Protection
|
9
|
+
# Cuba.use Rack::Protection::RemoteReferrer
|
10
|
+
|
11
|
+
# To launch just type: 'rackup' in your console
|
12
|
+
Cuba.define do
|
13
|
+
on get do
|
14
|
+
|
15
|
+
on root do
|
16
|
+
data = { first_name: 'Hello', last_name: 'World' }
|
17
|
+
res.headers["Content-Type"] = "application/json; charset=utf-8"
|
18
|
+
res.write data.to_json
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
23
|
+
TEMPLATE
|
24
|
+
%>
|
data/lib/cuba/templates/app.erb
CHANGED
@@ -23,12 +23,9 @@ Cuba.use Rack::Session::Cookie, :secret => "#{SecureRandom.base64(64)}"
|
|
23
23
|
# To launch just type: 'rackup' in your console
|
24
24
|
Cuba.define do
|
25
25
|
on get do
|
26
|
-
on "#{project_name}" do
|
27
|
-
res.write 'Hello world!'
|
28
|
-
end
|
29
26
|
|
30
27
|
on root do
|
31
|
-
res.
|
28
|
+
res.write "Hello #{project_name}"
|
32
29
|
end
|
33
30
|
|
34
31
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cuba-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Serdar Dogruyol
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: commander
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.3.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.3.0
|
69
83
|
description: Helps create cuba projects through a minimalist generator.
|
70
84
|
email:
|
71
85
|
- dogruyolserdar@gmail.com
|
@@ -83,7 +97,9 @@ files:
|
|
83
97
|
- bin/cuba
|
84
98
|
- cuba-generator.gemspec
|
85
99
|
- lib/cuba/generator.rb
|
100
|
+
- lib/cuba/generator/cli.rb
|
86
101
|
- lib/cuba/generator/version.rb
|
102
|
+
- lib/cuba/templates/api.erb
|
87
103
|
- lib/cuba/templates/app.erb
|
88
104
|
- lib/cuba/templates/rack_config.erb
|
89
105
|
- spec/cuba_generator_spec.rb
|
@@ -110,6 +126,6 @@ rubyforge_project:
|
|
110
126
|
rubygems_version: 2.4.5
|
111
127
|
signing_key:
|
112
128
|
specification_version: 4
|
113
|
-
summary: Generator for Cuba framework.
|
129
|
+
summary: Application Generator for Cuba framework.
|
114
130
|
test_files:
|
115
131
|
- spec/cuba_generator_spec.rb
|