Module: PlanMyStuff

Defined in:
lib/plan_my_stuff.rb,
lib/plan_my_stuff/link.rb,
lib/plan_my_stuff/repo.rb,
lib/plan_my_stuff/cache.rb,
lib/plan_my_stuff/issue.rb,
lib/plan_my_stuff/label.rb,
lib/plan_my_stuff/client.rb,
lib/plan_my_stuff/engine.rb,
lib/plan_my_stuff/errors.rb,
lib/plan_my_stuff/archive.rb,
lib/plan_my_stuff/comment.rb,
lib/plan_my_stuff/project.rb,
lib/plan_my_stuff/version.rb,
lib/plan_my_stuff/approval.rb,
lib/plan_my_stuff/markdown.rb,
lib/plan_my_stuff/pipeline.rb,
lib/plan_my_stuff/verifier.rb,
lib/plan_my_stuff/reminders.rb,
lib/plan_my_stuff/base_project.rb,
lib/plan_my_stuff/project_item.rb,
lib/plan_my_stuff/test_helpers.rb,
lib/plan_my_stuff/archive/sweep.rb,
lib/plan_my_stuff/base_metadata.rb,
lib/plan_my_stuff/configuration.rb,
lib/plan_my_stuff/custom_fields.rb,
lib/plan_my_stuff/notifications.rb,
lib/plan_my_stuff/user_resolver.rb,
lib/plan_my_stuff/issue_metadata.rb,
lib/plan_my_stuff/reminders/fire.rb,
lib/plan_my_stuff/graphql/queries.rb,
lib/plan_my_stuff/metadata_parser.rb,
lib/plan_my_stuff/pipeline/status.rb,
lib/plan_my_stuff/reminders/sweep.rb,
lib/plan_my_stuff/testing_project.rb,
lib/plan_my_stuff/comment_metadata.rb,
lib/plan_my_stuff/pipeline/testing.rb,
lib/plan_my_stuff/project_metadata.rb,
lib/plan_my_stuff/reminders/closer.rb,
lib/plan_my_stuff/webhook_replayer.rb,
lib/plan_my_stuff/aws_sns_simulator.rb,
lib/plan_my_stuff/base_project_item.rb,
lib/plan_my_stuff/application_record.rb,
app/jobs/plan_my_stuff/application_job.rb,
lib/plan_my_stuff/testing_project_item.rb,
lib/plan_my_stuff/base_project_metadata.rb,
lib/plan_my_stuff/pipeline/issue_linker.rb,
lib/plan_my_stuff/project_item_metadata.rb,
app/jobs/plan_my_stuff/reminders_sweep_job.rb,
lib/plan_my_stuff/pipeline/completed_sweep.rb,
lib/plan_my_stuff/testing_project_metadata.rb,
app/controllers/plan_my_stuff/issues_controller.rb,
app/controllers/plan_my_stuff/labels_controller.rb,
app/controllers/plan_my_stuff/comments_controller.rb,
app/controllers/plan_my_stuff/projects_controller.rb,
lib/generators/plan_my_stuff/views/views_generator.rb,
app/controllers/plan_my_stuff/application_controller.rb,
app/controllers/plan_my_stuff/issues/links_controller.rb,
app/controllers/plan_my_stuff/issues/takes_controller.rb,
app/controllers/plan_my_stuff/webhooks/aws_controller.rb,
app/controllers/plan_my_stuff/project_items_controller.rb,
lib/generators/plan_my_stuff/install/install_generator.rb,
app/controllers/plan_my_stuff/issues/viewers_controller.rb,
app/controllers/plan_my_stuff/issues/closures_controller.rb,
app/controllers/plan_my_stuff/issues/waitings_controller.rb,
app/controllers/plan_my_stuff/webhooks/github_controller.rb,
app/controllers/plan_my_stuff/issues/approvals_controller.rb,
app/controllers/plan_my_stuff/testing_projects_controller.rb,
app/controllers/plan_my_stuff/testing_project_items_controller.rb,
app/controllers/plan_my_stuff/project_items/statuses_controller.rb,
app/controllers/plan_my_stuff/project_items/assignments_controller.rb,
app/controllers/plan_my_stuff/testing_project_items/results_controller.rb

Defined Under Namespace

Modules: Archive, AwsSnsSimulator, Cache, Generators, GraphQL, Issues, Markdown, MetadataParser, Notifications, Pipeline, ProjectItems, Reminders, TestHelpers, TestingProjectItems, UserResolver, VERSION, WebhookReplayer, Webhooks Classes: APIError, ApplicationController, ApplicationJob, ApplicationRecord, Approval, AuthorizationError, BaseMetadata, BaseProject, BaseProjectItem, BaseProjectMetadata, Client, Comment, CommentMetadata, CommentsController, Configuration, ConfigurationError, CustomFields, Engine, Error, GraphQLError, Issue, IssueMetadata, IssuesController, Label, LabelsController, Link, LockedIssueError, PendingApprovalsError, PipelineError, Project, ProjectItem, ProjectItemMetadata, ProjectItemsController, ProjectMetadata, ProjectsController, RateLimitError, RemindersSweepJob, Repo, StaleObjectError, TestingProject, TestingProjectItem, TestingProjectItemsController, TestingProjectMetadata, TestingProjectsController, ValidationError, Verifier, WebhookSignatureError

Class Method Summary collapse

Class Method Details

.clientPlanMyStuff::Client

Returns:



58
59
60
# File 'lib/plan_my_stuff.rb', line 58

def client
  @client ||= PlanMyStuff::Client.new
end

.configurationPlanMyStuff::Configuration



48
49
50
# File 'lib/plan_my_stuff.rb', line 48

def configuration
  @configuration ||= PlanMyStuff::Configuration.new
end

.configure {|configuration| ... } ⇒ PlanMyStuff::Configuration



53
54
55
# File 'lib/plan_my_stuff.rb', line 53

def configure
  yield(configuration)
end

.exit_test_mode!void

This method returns an undefined value.

Restores original class / instance methods overwritten by test_mode!



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/plan_my_stuff/test_helpers.rb', line 354

def exit_test_mode!
  return unless @_test_mode

  (@_test_mode_originals || {}).each do |klass, methods|
    methods.each do |key, original|
      kind, name = key
      if kind == :instance
        klass.define_method(name, original)
      else
        klass.define_singleton_method(name, original)
      end
    end
  end

  @_test_mode_originals = nil
  @_test_mode = false
  PlanMyStuff::TestHelpers.recorded_actions = []
end

.format_time(value) ⇒ String?

Formats a time-ish value as an ISO 8601 string. Time and DateTime are normalized to UTC; Date is serialized as-is.

Parameters:

  • value (Time, DateTime, Date, String, nil)

Returns:

  • (String, nil)


87
88
89
90
91
92
93
# File 'lib/plan_my_stuff.rb', line 87

def format_time(value)
  return if value.nil?
  return value if value.is_a?(String)
  return value.iso8601 if value.is_a?(Date) && !value.is_a?(DateTime)

  value.utc.iso8601
end

.import_clientPlanMyStuff::Client

Returns:



63
64
65
# File 'lib/plan_my_stuff.rb', line 63

def import_client
  @import_client ||= PlanMyStuff::Client.new(importing: true)
end

.reset!void

This method returns an undefined value.

Resets the memoized client and configuration. Useful for testing.



99
100
101
102
103
104
105
# File 'lib/plan_my_stuff.rb', line 99

def reset!
  exit_test_mode! if defined?(@_test_mode) && @_test_mode
  PlanMyStuff::Client.exit_trace_mode!
  @client = nil
  @import_client = nil
  @configuration = nil
end

.test_mode!void

This method returns an undefined value.

Activates test mode: stubs all API-calling class methods on Issue, Comment, and ProjectItem so no real HTTP requests are made. Records all actions for assertion matchers.



337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/plan_my_stuff/test_helpers.rb', line 337

def test_mode!
  PlanMyStuff::TestHelpers.recorded_actions = []
  return if @_test_mode

  @_test_mode_originals = {}
  stub_issue_class_methods!
  stub_comment_class_methods!
  stub_project_class_methods!
  stub_project_item_class_methods!
  stub_pipeline_methods!
  @_test_mode = true
end

.unprocessable_statusSymbol

Returns the appropriate HTTP 422 status symbol for the current Rails version. Rails 7.1+ deprecated :unprocessable_entity in favor of :unprocessable_content.

Returns:

  • (Symbol)


72
73
74
75
76
77
78
# File 'lib/plan_my_stuff.rb', line 72

def unprocessable_status
  if Gem::Version.new(Rails.version) >= Gem::Version.new('7.1')
    :unprocessable_content
  else
    :unprocessable_entity
  end
end