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.
- #minitest? ⇒ Boolean
- #mysql? ⇒ Boolean
- #postgresql? ⇒ Boolean
- #rodauth? ⇒ Boolean
- #root_example ⇒ Object
- #rspec? ⇒ Boolean
- #sqlite? ⇒ Boolean
Methods included from Helpers::Ids
#api_id, #fullstack_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
101 102 103 |
# File 'lib/roda/project/context.rb', line 101 def api? base == api_id end |
#const_project_name ⇒ Object
131 132 133 |
# File 'lib/roda/project/context.rb', line 131 def const_project_name @const_project_name ||= project_name.split('_').map(&:capitalize).join end |
#database? ⇒ Boolean
109 110 111 |
# File 'lib/roda/project/context.rb', line 109 def database? database == true end |
#foo_bar_example ⇒ Object
rubocop:disable Lint/InterpolationCheck
84 85 86 87 88 |
# File 'lib/roda/project/context.rb', line 84 def return 'view("bar")' if fullstack? '{ foo: "bar" }' end |
#fullstack? ⇒ Boolean
rubocop:enable Lint/InterpolationCheck
97 98 99 |
# File 'lib/roda/project/context.rb', line 97 def fullstack? base == fullstack_id end |
#minitest? ⇒ Boolean
79 80 81 |
# File 'lib/roda/project/context.rb', line 79 def minitest? tests == minitest_id end |
#mysql? ⇒ Boolean
113 114 115 116 117 |
# File 'lib/roda/project/context.rb', line 113 def mysql? return false unless database? database_type == mysql_id end |
#postgresql? ⇒ Boolean
119 120 121 122 123 |
# File 'lib/roda/project/context.rb', line 119 def postgresql? return false unless database? database_type == postgresql_id end |
#rodauth? ⇒ Boolean
105 106 107 |
# File 'lib/roda/project/context.rb', line 105 def rodauth? rodauth == true end |
#root_example ⇒ Object
90 91 92 93 94 |
# File 'lib/roda/project/context.rb', line 90 def root_example return 'view("index")' if fullstack? '{ message: "#{t.hello.message}" }' end |
#rspec? ⇒ Boolean
75 76 77 |
# File 'lib/roda/project/context.rb', line 75 def rspec? tests == rspec_id end |
#sqlite? ⇒ Boolean
125 126 127 128 129 |
# File 'lib/roda/project/context.rb', line 125 def sqlite? return false unless database? database_type == sqlite_id end |