grape-cli 0.1.1 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd81b306d13395df9ad5fd3c82fb32b25af518ee
4
- data.tar.gz: 890a1af3e6180889f8a5ca03870fe7c42d5705b9
3
+ metadata.gz: f72edec9b0eb49d6d32b848ff753fc08443c4536
4
+ data.tar.gz: 79d74b6f370aebf1bc58ce2123aaceda7824867a
5
5
  SHA512:
6
- metadata.gz: 4fcfc2eabad8cb59d7db08792f472304a2695a1fc120e57d209fd367b06e2056f8262291afa082cc413261ff7da4c3afb4ad032254cef9c1cd3029eeac5ebbfe
7
- data.tar.gz: 9e0f6e163c2677a68c1c0b1cc8ac79e3543a6dcd1362aaeea62e8214808da9b87215cfe658d301b6a0e73912b544edb717556cc143cc962e5df563fd116861ec
6
+ metadata.gz: 56f6ad6ff9e9fb0688c62094d49f3dd0054e345e1482d0c9d111e76a1160aa3e7d28d6e05c6e67bb5296b687226af86f0caacd94407c67ac5ade354e59292a93
7
+ data.tar.gz: 49039535f78e4472878ce3c6b3267947dd4914f9e6de6c3b6f76b04ac67beac7f48adfc408f84d9865e96dd76cca2af9d6844b63614d0f22e8b04c4c9fc3d944
data/lib/grape/cli/new.rb CHANGED
@@ -7,18 +7,21 @@ class GrapeCli < Thor
7
7
  desc "new APP_NAME", "Create a new Grape application"
8
8
 
9
9
  method_option :work_dir, default: Dir.pwd
10
+ method_option :database, aliases: 'd', default: 'postgres'
10
11
 
11
12
  def self.source_root
12
13
  File.dirname(__FILE__)
13
14
  end
14
15
 
15
16
  def new(app_name)
16
- application_template_path = File.join(GrapeCli.source_root, 'template/application')
17
- destination_path = File.join(options[:work_dir], app_name)
18
- config = create_config(app_name)
17
+ template_path = File.join(GrapeCli.source_root, 'template')
18
+ application_template_path = File.join(template_path, 'application')
19
+ destination_path = File.join(options[:work_dir], app_name)
20
+ config = create_config(app_name)
19
21
 
20
22
  directory(application_template_path, destination_path, config)
21
-
23
+ template(File.join(template_path, 'database', "#{options[:database]}.yml.tt"),
24
+ File.join(destination_path, 'config', 'database.yml'))
22
25
  inside destination_path do
23
26
  run(ApplicationFactory.instance.command_generator.bundle_install, config)
24
27
  end
@@ -29,8 +32,18 @@ class GrapeCli < Thor
29
32
  def create_config(app_name)
30
33
  {
31
34
  app_name: app_name,
32
- verbose: ApplicationFactory.instance.verbose_output,
33
- class_name: ClassNameGenerator.new(app_name).generate
35
+ class_name: ClassNameGenerator.new(app_name).generate,
36
+ database: options[:database],
37
+ database_gem: database_gem(options[:database]),
38
+ verbose: ApplicationFactory.instance.verbose_output
34
39
  }
35
40
  end
41
+
42
+
43
+ def database_gem(database)
44
+ {
45
+ postgres: 'pg',
46
+ sqlite: 'sqlite3'
47
+ }[database.to_sym]
48
+ end
36
49
  end
@@ -1,6 +1,6 @@
1
1
  source 'http://rubygems.org'
2
2
 
3
- gem 'pg'
3
+ gem '<%= config[:database_gem] %>'
4
4
 
5
5
  gem 'grape', '~> 0.13.0'
6
6
 
@@ -0,0 +1,25 @@
1
+ # SQLite version 3.x
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem 'sqlite3'
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ pool: 5
10
+ timeout: 5000
11
+
12
+ development:
13
+ <<: *default
14
+ database: db/development.sqlite3
15
+
16
+ # Warning: The database defined as "test" will be erased and
17
+ # re-generated from your development database when you run "rake".
18
+ # Do not set this db to the same as development or production.
19
+ test:
20
+ <<: *default
21
+ database: db/test.sqlite3
22
+
23
+ production:
24
+ <<: *default
25
+ database: db/production.sqlite3
@@ -1,5 +1,5 @@
1
1
  module Grape
2
2
  module Cli
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - wswidzinski
@@ -123,15 +123,16 @@ files:
123
123
  - lib/grape/cli/console.rb
124
124
  - lib/grape/cli/new.rb
125
125
  - lib/grape/cli/server.rb
126
- - lib/grape/cli/template/application/Gemfile
126
+ - lib/grape/cli/template/application/Gemfile.tt
127
127
  - lib/grape/cli/template/application/Rakefile.tt
128
128
  - lib/grape/cli/template/application/app/api.rb.tt
129
129
  - lib/grape/cli/template/application/app/resources/hello_world.rb.tt
130
130
  - lib/grape/cli/template/application/config.ru.tt
131
131
  - lib/grape/cli/template/application/config/application.rb
132
132
  - lib/grape/cli/template/application/config/boot.rb
133
- - lib/grape/cli/template/application/config/database.yml.tt
134
133
  - lib/grape/cli/template/application/config/environment.rb
134
+ - lib/grape/cli/template/database/postgres.yml.tt
135
+ - lib/grape/cli/template/database/sqlite.yml.tt
135
136
  - lib/grape/cli/version.rb
136
137
  - lib/grape/command_generator.rb
137
138
  homepage: http://github.com/elpassion/grape-cli