rails_app 0.6.0 → 0.7.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
  SHA256:
3
- metadata.gz: 82dcc08138eb02ce0aafb95ddd5ac1122f2ed79d4510262c3991bc8c2a5eaeb4
4
- data.tar.gz: 47207c80b368ed13984db09d55f437332c9ea97d64d105582f6ef4b95ca27cf7
3
+ metadata.gz: 534816163e2b9fc2c353d1a2afb4568c8bd9b3355b46fcbe1b132b83cb89acad
4
+ data.tar.gz: e2e50fd1ebe97b1981da6713e49cc7595c8f11c58bb600b67e7b99088a745252
5
5
  SHA512:
6
- metadata.gz: a12f159b7870cc8036d68fa1547de18420292166df000b4e8f72f4d78bff6207020081f264602afe0e9da164dc37d6a25ab0d094b6c577ddcad09c4000a99772
7
- data.tar.gz: 8bd93c9bec6c3b2542d58d288b93e57c55f3c87e68d0a3f82fdabf0cc377c83efa3afac28a806b262ee54f245cf7276fe11de122ecfb0adda77e83fb0dcaa26c
6
+ metadata.gz: d5242d9c1382772a58599ab08658745d6eac76a12c78ef2b83395af317a777abd022885028c5f664087882a4b6fed1331b831a0cc5dec9bd760746b5268ceb05
7
+ data.tar.gz: b3dcfc4ecbe21b2c96435606cb44bd7867f1de8d8da66075d50b9852db7d294580639434fdbef7f2fe4e81f72dcad879a5c336eeb5cf5a7ba1ea3b513a8fde16
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0](https://github.com/eclectic-coding/rails_app/tree/0.7.0) (2024-04-04)
4
+
5
+ [Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.6.0...0.7.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - handle optional CLI ARGV [\#21](https://github.com/eclectic-coding/rails_app/issues/21)
10
+ - Add user option to select other styling systems [\#2](https://github.com/eclectic-coding/rails_app/issues/2)
11
+ - Handle optional cli argv [\#22](https://github.com/eclectic-coding/rails_app/pull/22) ([eclectic-coding](https://github.com/eclectic-coding))
12
+
3
13
  ## [0.6.0](https://github.com/eclectic-coding/rails_app/tree/0.6.0) (2024-04-04)
4
14
 
5
15
  [Full Changelog](https://github.com/eclectic-coding/rails_app/compare/0.5.0...0.6.0)
data/README.md CHANGED
@@ -31,7 +31,28 @@ Also, you can select your database of choice:
31
31
 
32
32
  The template will then create a new Rails application with the selected options.
33
33
 
34
- ### Testing
34
+ ### Optional CLI Syntax
35
+
36
+ There is an additional syntax, available starting with release `v. 0.7.0`, which allows you to use `rails_app` very similarly to the `rails new` command:
37
+
38
+ ```bash
39
+ rails_app new my_app -a propshaft --css bootstrap -d postgresql
40
+ ```
41
+ I few things to note:
42
+ - the `app_name` must be first, just like with `rails new`
43
+ - the following arguments and flags must be separated by a space `-a propshaft`. Since, the parser ignores the flag and checks for the specific keywords only, you technically can use the follow: `rails_app my_app propshaft bootstrap postgresql`.
44
+
45
+ If you use this syntax, the template will not prompt you the application name, and subsequent options will be preselected for you.
46
+
47
+ Right not this syntax only supports the following options:
48
+ - app name
49
+ - assets pipeline
50
+ - styling
51
+ - database
52
+
53
+ More options will be added in future releases.
54
+
55
+ ## Testing
35
56
  The template includes RSpec for testing, which includes pre configured:
36
57
  - FactoryBot
37
58
  - Faker
data/bin/rails_app CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require "rails_app"
4
4
 
5
- RailsApp::App.rails_app
5
+ RailsApp::App.rails_app(ARGV)
data/lib/rails_app/cli.rb CHANGED
@@ -4,11 +4,14 @@ require "tty-prompt"
4
4
 
5
5
  module RailsApp
6
6
  class CLI
7
- def self.start
7
+ def self.start(args)
8
8
  prompt = TTY::Prompt.new
9
9
 
10
- app_name = prompt.ask("What is the name of your application?", required: true)
11
- assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets])
10
+ options_data = OptionsData.new(args)
11
+
12
+ app_name = options_data.app_name || prompt.ask("What is the name of your application?", required: true)
13
+
14
+ assets = prompt.select("How would you like to manage assets?", %w[propshaft sprockets], default: options_data.default_assets)
12
15
  styling_choices = [
13
16
  {name: "Bootstrap", value: "bootstrap"},
14
17
  {name: "Tailwind CSS", value: "tailwind"},
@@ -16,8 +19,13 @@ module RailsApp
16
19
  {name: "PostCSS", value: "postcss"},
17
20
  {name: "SASS", value: "sass"}
18
21
  ]
19
- styling = prompt.select("How would you like to manage styling?", styling_choices)
20
- database = prompt.select("Which database would you like to use?", %w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc])
22
+ styling = prompt.select("How would you like to manage styling?", styling_choices, default: options_data.default_styling)
23
+
24
+ database = prompt.select("Which database would you like to use?",
25
+ %w[postgresql sqlite3 mysql trilogy oracle sqlserver jdbcmysql jdbcsqlite3 jdbcpostgresql jdbc],
26
+ default: options_data.default_database)
27
+
28
+ # save configuration
21
29
 
22
30
  Command.new(app_name: app_name, assets: assets, styling: styling, database: database).run
23
31
  end
@@ -0,0 +1,57 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RailsApp
4
+ class OptionsData
5
+ attr_reader :options
6
+
7
+ def initialize(args)
8
+ @options = args.flat_map { |arg| arg.split(" ") }
9
+ end
10
+
11
+ def app_name
12
+ @options[0]
13
+ end
14
+
15
+ def default_assets
16
+ @options.include?("sprockets") ? "sprockets" : "propshaft"
17
+ end
18
+
19
+ def default_styling
20
+ if @options.include?("tailwind")
21
+ "tailwind"
22
+ elsif @options.include?("bulma")
23
+ "bulma"
24
+ elsif @options.include?("postcss")
25
+ "postcss"
26
+ elsif @options.include?("sass")
27
+ "sass"
28
+ elsif @options.include?("bootstrap")
29
+ "bootstrap"
30
+ end
31
+ end
32
+
33
+ def default_database
34
+ if @options.include?("postgresql")
35
+ "postgresql"
36
+ elsif @options.include?("mysql")
37
+ "mysql"
38
+ elsif @options.include?("trilogy")
39
+ "trilogy"
40
+ elsif @options.include?("oracle")
41
+ "oracle"
42
+ elsif @options.include?("sqlserver")
43
+ "sqlserver"
44
+ elsif @options.include?("jdbcmysql")
45
+ "jdbcmysql"
46
+ elsif @options.include?("jdbcsqlite3")
47
+ "jdbcsqlite3"
48
+ elsif @options.include?("jdbcpostgresql")
49
+ "jdbcpostgresql"
50
+ elsif @options.include?("jdbc")
51
+ "jdbc"
52
+ else
53
+ "sqlite3"
54
+ end
55
+ end
56
+ end
57
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module RailsApp
4
4
  class App
5
- def self.rails_app
6
- RailsApp::CLI.start
5
+ def self.rails_app(args)
6
+ RailsApp::CLI.start(args)
7
7
  end
8
8
  end
9
9
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RailsApp
4
- VERSION = "0.6.0"
4
+ VERSION = "0.7.0"
5
5
  end
data/lib/rails_app.rb CHANGED
@@ -6,5 +6,6 @@ module RailsApp
6
6
  autoload :App, "rails_app/rails_app"
7
7
  autoload :CLI, "rails_app/cli"
8
8
  autoload :Command, "rails_app/command"
9
+ autoload :OptionsData, "rails_app/options_data"
9
10
  autoload :Error, "rails_app/error"
10
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_app
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chuck Smith
@@ -85,6 +85,7 @@ files:
85
85
  - lib/rails_app/cli.rb
86
86
  - lib/rails_app/command.rb
87
87
  - lib/rails_app/error.rb
88
+ - lib/rails_app/options_data.rb
88
89
  - lib/rails_app/rails_app.rb
89
90
  - lib/rails_app/template/.rspec
90
91
  - lib/rails_app/template/.rubocop.yml