Class: PlanMyStuff::Configuration
- Inherits:
-
Object
- Object
- PlanMyStuff::Configuration
- Defined in:
- lib/plan_my_stuff/configuration.rb
Instance Attribute Summary collapse
-
#access_token ⇒ String
GitHub PAT with repo and project scopes.
-
#app_name ⇒ String?
Name of the consuming app, stored in metadata (e.g. “Atlas”).
-
#custom_fields ⇒ Hash{Symbol => Hash}
App-defined field definitions stored in issue/comment metadata.
-
#default_project_number ⇒ Integer?
Default GitHub Projects V2 number for add_to_project calls.
-
#default_repo ⇒ Symbol?
Default repo key used when callers omit repo: param.
-
#deferred_email_from ⇒ String?
Sender address for built-in deferred request notifications.
-
#deferred_email_to ⇒ String?
Recipient address for built-in deferred request notifications.
-
#deferred_notifier ⇒ Proc?
Custom notifier for deferred requests, or nil to use DeferredMailer.
-
#display_name_method ⇒ Symbol
Method called on user object to get display name for comment headers.
-
#issues_url_prefix ⇒ String?
URL prefix for building user-facing ticket URLs in the consuming app.
-
#job_classes ⇒ Hash{Symbol => String}
Map of action type to job class name for deferred requests.
-
#markdown_options ⇒ Hash
Default options passed to the markdown renderer.
-
#markdown_renderer ⇒ Symbol
Which markdown gem to use: :commonmarker or :redcarpet.
-
#organization ⇒ String
GitHub organization name.
-
#repos ⇒ Hash{Symbol => String}
readonly
Named repo configs.
-
#should_send_request ⇒ Proc?
Proc returning boolean, or nil (always send).
-
#support_method ⇒ Symbol, Proc
Determines if a user is support staff.
-
#user_class ⇒ String
Consuming app’s user model class name, constantized for lookups.
-
#user_id_method ⇒ Symbol
Method called on user object to extract the app-side user ID.
Instance Method Summary collapse
-
#authenticate_with(&block) ⇒ void
Sets the authentication block for engine controllers.
- #initialize ⇒ Configuration constructor
-
#validate! ⇒ void
Validates that required configuration options are set.
Constructor Details
#initialize ⇒ Configuration
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/plan_my_stuff/configuration.rb', line 93 def initialize @repos = {} @user_class = 'User' @display_name_method = :to_s @user_id_method = :id @support_method = :support? @markdown_renderer = :commonmarker @markdown_options = {} @job_classes = {} @custom_fields = {} end |
Instance Attribute Details
#access_token ⇒ String
Returns GitHub PAT with repo and project scopes. Required.
6 7 8 |
# File 'lib/plan_my_stuff/configuration.rb', line 6 def access_token @access_token end |
#app_name ⇒ String?
Returns name of the consuming app, stored in metadata (e.g. “Atlas”).
84 85 86 |
# File 'lib/plan_my_stuff/configuration.rb', line 84 def app_name @app_name end |
#custom_fields ⇒ Hash{Symbol => Hash}
App-defined field definitions stored in issue/comment metadata. Keys are field names, values are hashes with :type and :required.
78 79 80 |
# File 'lib/plan_my_stuff/configuration.rb', line 78 def custom_fields @custom_fields end |
#default_project_number ⇒ Integer?
Returns default GitHub Projects V2 number for add_to_project calls.
15 16 17 |
# File 'lib/plan_my_stuff/configuration.rb', line 15 def default_project_number @default_project_number end |
#default_repo ⇒ Symbol?
Returns default repo key used when callers omit repo: param.
12 13 14 |
# File 'lib/plan_my_stuff/configuration.rb', line 12 def default_repo @default_repo end |
#deferred_email_from ⇒ String?
Returns sender address for built-in deferred request notifications.
68 69 70 |
# File 'lib/plan_my_stuff/configuration.rb', line 68 def deferred_email_from @deferred_email_from end |
#deferred_email_to ⇒ String?
Returns recipient address for built-in deferred request notifications.
71 72 73 |
# File 'lib/plan_my_stuff/configuration.rb', line 71 def deferred_email_to @deferred_email_to end |
#deferred_notifier ⇒ Proc?
Returns custom notifier for deferred requests, or nil to use DeferredMailer.
65 66 67 |
# File 'lib/plan_my_stuff/configuration.rb', line 65 def deferred_notifier @deferred_notifier end |
#display_name_method ⇒ Symbol
Returns method called on user object to get display name for comment headers.
21 22 23 |
# File 'lib/plan_my_stuff/configuration.rb', line 21 def display_name_method @display_name_method end |
#issues_url_prefix ⇒ String?
Returns URL prefix for building user-facing ticket URLs in the consuming app.
81 82 83 |
# File 'lib/plan_my_stuff/configuration.rb', line 81 def issues_url_prefix @issues_url_prefix end |
#job_classes ⇒ Hash{Symbol => String}
Map of action type to job class name for deferred requests. Keys: :create_ticket, :post_comment, :update_status.
62 63 64 |
# File 'lib/plan_my_stuff/configuration.rb', line 62 def job_classes @job_classes end |
#markdown_options ⇒ Hash
Default options passed to the markdown renderer. Per-call options in Markdown.render merge on top of these.
For :commonmarker - passed as ‘options:` to `Commonmarker.to_html`
e.g. `{ render: { hardbreaks: true } }`
For :redcarpet - :render_options and :renderer are extracted for the HTML renderer;
remaining keys are passed as extensions to `Redcarpet::Markdown.new`
e.g. `{ render_options: { hard_wrap: true, no_styles: true }, autolink: true }`
48 49 50 |
# File 'lib/plan_my_stuff/configuration.rb', line 48 def @markdown_options end |
#markdown_renderer ⇒ Symbol
Returns which markdown gem to use: :commonmarker or :redcarpet.
34 35 36 |
# File 'lib/plan_my_stuff/configuration.rb', line 34 def markdown_renderer @markdown_renderer end |
#organization ⇒ String
Returns GitHub organization name. Required.
9 10 11 |
# File 'lib/plan_my_stuff/configuration.rb', line 9 def organization @organization end |
#repos ⇒ Hash{Symbol => String} (readonly)
Named repo configs. Set via config.repos = ‘BrandsInsurance/Element’.
90 91 92 |
# File 'lib/plan_my_stuff/configuration.rb', line 90 def repos @repos end |
#should_send_request ⇒ Proc?
Proc returning boolean, or nil (always send). When it returns false the request is deferred to a background job instead of hitting GitHub.
55 56 57 |
# File 'lib/plan_my_stuff/configuration.rb', line 55 def should_send_request @should_send_request end |
#support_method ⇒ Symbol, Proc
Determines if a user is support staff. Symbol (method name on user) or Proc that receives the user object and returns boolean.
31 32 33 |
# File 'lib/plan_my_stuff/configuration.rb', line 31 def support_method @support_method end |
#user_class ⇒ String
Returns consuming app’s user model class name, constantized for lookups.
18 19 20 |
# File 'lib/plan_my_stuff/configuration.rb', line 18 def user_class @user_class end |
#user_id_method ⇒ Symbol
Returns method called on user object to extract the app-side user ID.
24 25 26 |
# File 'lib/plan_my_stuff/configuration.rb', line 24 def user_id_method @user_id_method end |
Instance Method Details
#authenticate_with(&block) ⇒ void
This method returns an undefined value.
Sets the authentication block for engine controllers.
109 110 111 112 113 114 115 |
# File 'lib/plan_my_stuff/configuration.rb', line 109 def authenticate_with(&block) if block @authenticate_with = block else @authenticate_with end end |
#validate! ⇒ void
This method returns an undefined value.
Validates that required configuration options are set.
123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/plan_my_stuff/configuration.rb', line 123 def validate! missing = [] missing << 'access_token' if access_token.nil? || access_token.to_s.strip.empty? missing << 'organization' if organization.nil? || organization.to_s.strip.empty? return if missing.empty? raise( ConfigurationError, "Missing required PlanMyStuff configuration: #{missing.join(', ')}", ) end |