cuba-generator 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -5
- data/lib/cuba/generator/cli.rb +5 -2
- data/lib/cuba/generator/version.rb +1 -1
- data/lib/cuba/generator.rb +26 -6
- data/lib/cuba/templates/db.erb +22 -0
- data/lib/cuba/templates/gemfile.erb +11 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 12eb0c60bfc006bd14d7f8937e28f15dde444c4a
|
4
|
+
data.tar.gz: c11128134f0c716dbd85959cd9157f02ab6740eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeaa6cb72593544d964be28ba024d5a067b40bf8e95f17d18d8810b65c92eee072d3051566a169494d5a4e6e076c5c79622925d92e8210023d4f6d95355659b6
|
7
|
+
data.tar.gz: 5c580137e357bd3759c165c534396d4d7d7113c58319ecbd13b91c5b36f43abd09748adeabfd05dd7da679ba0557e3ec2be3cdd2cf33a8aa370a75b87373675a
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/cuba-generator.svg)](http://badge.fury.io/rb/cuba-generator)
|
1
2
|
# cuba-generator
|
2
3
|
|
3
4
|
cuba-generator is a generator to help creating Cuba projects.
|
@@ -6,16 +7,21 @@ cuba-generator is a generator to help creating Cuba projects.
|
|
6
7
|
|
7
8
|
## Installation
|
8
9
|
|
9
|
-
|
10
|
+
gem install cuba-generator
|
10
11
|
|
11
12
|
## Usage
|
12
13
|
|
13
|
-
|
14
|
+
cuba new [projectName] [options]
|
14
15
|
|
15
|
-
|
16
|
+
Additionally you can specify the type of your app via ***--type*** . E.g to generate an API starting point.
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
cuba new [projectName] --type api
|
19
|
+
|
20
|
+
To generate an application with a Postgresql configuration setup use ***-database*** option (via Datamapper)
|
21
|
+
|
22
|
+
cuba new [projectName] --database postgresql
|
23
|
+
|
24
|
+
By default ***--type*** is 'app'.
|
19
25
|
|
20
26
|
## Contributing
|
21
27
|
|
data/lib/cuba/generator/cli.rb
CHANGED
@@ -15,11 +15,14 @@ module Cuba
|
|
15
15
|
c.syntax = 'cuba new [options]'
|
16
16
|
c.description = 'Creates a new Cuba app'
|
17
17
|
c.option '--type STRING', String, 'Creates an app with preferred type'
|
18
|
+
c.option '--database STRING', String, 'Setups a database configuration with DataMapper'
|
18
19
|
c.action do |args, options|
|
19
20
|
if options.type
|
20
|
-
Cuba::Generator.new(ARGV[1], options.type)
|
21
|
+
generator = Cuba::Generator.new(ARGV[1], options.type)
|
22
|
+
generator.create_database_file if options.database == 'postgresql'
|
21
23
|
else
|
22
|
-
Cuba::Generator.new(ARGV[1], :app)
|
24
|
+
generator = Cuba::Generator.new(ARGV[1], :app)
|
25
|
+
generator.create_database_file if options.database == 'postgresql'
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
data/lib/cuba/generator.rb
CHANGED
@@ -32,20 +32,40 @@ module Cuba
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def create_database_file
|
36
|
+
File.open("./#{@project_name}/database.rb", 'w+') do |file|
|
37
|
+
file.write setup_database
|
38
|
+
end
|
39
|
+
File.open("./#{@project_name}/Gemfile", 'w+') do |file|
|
40
|
+
file.write setup_gemfile
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
35
44
|
private
|
36
45
|
|
37
46
|
def setup_cuba
|
38
|
-
|
39
|
-
|
47
|
+
if @type.to_sym == :app
|
48
|
+
create_template 'app'
|
40
49
|
elsif @type.to_sym == :api
|
41
|
-
|
50
|
+
create_template 'api'
|
42
51
|
end
|
43
|
-
erb(path, {project_name: @project_name})
|
44
52
|
end
|
45
53
|
|
46
54
|
def setup_config
|
47
|
-
|
48
|
-
|
55
|
+
create_template 'rack_config'
|
56
|
+
end
|
57
|
+
|
58
|
+
def setup_database
|
59
|
+
create_template 'db'
|
60
|
+
end
|
61
|
+
|
62
|
+
def setup_gemfile
|
63
|
+
create_template 'gemfile'
|
64
|
+
end
|
65
|
+
|
66
|
+
def create_template(name)
|
67
|
+
template = File.read File.join(APPROOT, 'templates/', "#{name}.erb")
|
68
|
+
erb(template, {project_name: @project_name})
|
49
69
|
end
|
50
70
|
|
51
71
|
def erb(template, vars)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<%=
|
2
|
+
<<-TEMPLATE
|
3
|
+
|
4
|
+
require 'data_mapper'
|
5
|
+
|
6
|
+
DataMapper.setup(:default, 'postgres://username@localhost/db_name')
|
7
|
+
|
8
|
+
# Here's an example User model
|
9
|
+
# class User
|
10
|
+
# include DataMapper::Resource
|
11
|
+
#
|
12
|
+
# property :id, Serial # An auto-increment integer key
|
13
|
+
# property :email, String # A varchar type string, for short strings
|
14
|
+
# property :created_at, DateTime # A DateTime, for any date you might like.
|
15
|
+
# property :updated_at, DateTime
|
16
|
+
# end
|
17
|
+
|
18
|
+
DataMapper.finalize
|
19
|
+
DataMapper.auto_upgrade!
|
20
|
+
|
21
|
+
TEMPLATE
|
22
|
+
%>
|
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.6
|
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-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -101,6 +101,8 @@ 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/db.erb
|
105
|
+
- lib/cuba/templates/gemfile.erb
|
104
106
|
- lib/cuba/templates/rack_config.erb
|
105
107
|
- spec/cuba_generator_spec.rb
|
106
108
|
homepage: ''
|