Class: Roda::Project::Context
- Inherits:
-
Object
- Object
- Roda::Project::Context
- Includes:
- Helpers::Ids
- Defined in:
- lib/roda/project/context.rb
Defined Under Namespace
Classes: InvalidValue
Constant Summary collapse
- VALID_PROJECT_NAME_REGEX =
/^[a-zA-Z][a-zA-Z0-9_]*$/
Instance Attribute Summary collapse
-
#base ⇒ Object
Returns the value of attribute base.
-
#database ⇒ Object
Returns the value of attribute database.
-
#database_type ⇒ Object
Returns the value of attribute database_type.
-
#db_gem ⇒ Object
readonly
Returns the value of attribute db_gem.
-
#dev_db_url ⇒ Object
readonly
Returns the value of attribute dev_db_url.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#rodauth ⇒ Object
Returns the value of attribute rodauth.
-
#tests ⇒ Object
Returns the value of attribute tests.
Instance Method Summary collapse
- #api? ⇒ Boolean
- #const_project_name ⇒ Object
- #database? ⇒ Boolean
-
#foo_bar_example ⇒ Object
rubocop:disable Lint/InterpolationCheck.
-
#fullstack? ⇒ Boolean
rubocop:enable Lint/InterpolationCheck.
- #minimal? ⇒ Boolean
- #minitest? ⇒ Boolean
- #mysql? ⇒ Boolean
- #postgresql? ⇒ Boolean
- #rodauth? ⇒ Boolean
- #root_example ⇒ Object
- #rspec? ⇒ Boolean
- #sqlite? ⇒ Boolean
Methods included from Helpers::Ids
#api_id, #fullstack_id, #minimal_id, #minitest_id, #mysql_id, #postgresql_id, #rspec_id, #sqlite_id
Instance Attribute Details
#base ⇒ Object
Returns the value of attribute base.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def base @base end |
#database ⇒ Object
Returns the value of attribute database.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def database @database end |
#database_type ⇒ Object
Returns the value of attribute database_type.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def database_type @database_type end |
#db_gem ⇒ Object (readonly)
Returns the value of attribute db_gem.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def db_gem @db_gem end |
#dev_db_url ⇒ Object (readonly)
Returns the value of attribute dev_db_url.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def dev_db_url @dev_db_url end |
#project_name ⇒ Object
Returns the value of attribute project_name.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def project_name @project_name end |
#rodauth ⇒ Object
Returns the value of attribute rodauth.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def rodauth @rodauth end |
#tests ⇒ Object
Returns the value of attribute tests.
9 10 11 |
# File 'lib/roda/project/context.rb', line 9 def tests @tests end |
Instance Method Details
#api? ⇒ Boolean
103 104 105 |
# File 'lib/roda/project/context.rb', line 103 def api? base == api_id end |
#const_project_name ⇒ Object
137 138 139 |
# File 'lib/roda/project/context.rb', line 137 def const_project_name @const_project_name ||= project_name.split("_").map(&:capitalize).join end |
#database? ⇒ Boolean
115 116 117 |
# File 'lib/roda/project/context.rb', line 115 def database? database == true end |
#foo_bar_example ⇒ Object
rubocop:disable Lint/InterpolationCheck
86 87 88 89 90 |
# File 'lib/roda/project/context.rb', line 86 def return 'view("bar")' if fullstack? '{ foo: "bar" }' end |
#fullstack? ⇒ Boolean
rubocop:enable Lint/InterpolationCheck
99 100 101 |
# File 'lib/roda/project/context.rb', line 99 def fullstack? base == fullstack_id end |
#minimal? ⇒ Boolean
107 108 109 |
# File 'lib/roda/project/context.rb', line 107 def minimal? base == minimal_id end |
#minitest? ⇒ Boolean
81 82 83 |
# File 'lib/roda/project/context.rb', line 81 def minitest? tests == minitest_id end |
#mysql? ⇒ Boolean
119 120 121 122 123 |
# File 'lib/roda/project/context.rb', line 119 def mysql? return false unless database? database_type == mysql_id end |
#postgresql? ⇒ Boolean
125 126 127 128 129 |
# File 'lib/roda/project/context.rb', line 125 def postgresql? return false unless database? database_type == postgresql_id end |
#rodauth? ⇒ Boolean
111 112 113 |
# File 'lib/roda/project/context.rb', line 111 def rodauth? rodauth == true end |
#root_example ⇒ Object
92 93 94 95 96 |
# File 'lib/roda/project/context.rb', line 92 def root_example return 'view("index")' if fullstack? '{ message: "#{t.hello.message}" }' end |
#rspec? ⇒ Boolean
77 78 79 |
# File 'lib/roda/project/context.rb', line 77 def rspec? tests == rspec_id end |
#sqlite? ⇒ Boolean
131 132 133 134 135 |
# File 'lib/roda/project/context.rb', line 131 def sqlite? return false unless database? database_type == sqlite_id end |