Module: Bidi2pdfRails::TestHelpers::EnvironmentHelper

Defined in:
lib/bidi2pdf_rails/test_helpers/environment_helper.rb

Instance Method Summary collapse

Instance Method Details

#environment_ci?Boolean

Checks if the current environment is a CI environment.

Returns:

  • (Boolean)

    true if the environment is CI, false otherwise



35
36
37
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 35

def environment_ci?
  environment_type? :ci
end

#environment_codespaces?Boolean

Checks if the current environment is a GitHub Codespaces environment.

Returns:

  • (Boolean)

    true if the environment is Codespaces, false otherwise



41
42
43
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 41

def environment_codespaces?
  environment_type? :codespaces
end

#environment_container?Boolean

Checks if the current environment is a containerized environment.

Returns:

  • (Boolean)

    true if the environment is a container, false otherwise



47
48
49
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 47

def environment_container?
  environment_type? :container
end

#environment_local?Boolean

Checks if the current environment is a local environment.

Returns:

  • (Boolean)

    true if the environment is local, false otherwise



53
54
55
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 53

def environment_local?
  environment_type? :local
end

#environment_typeSymbol

Determines the current environment type based on environment variables and context.

Returns:

  • (Symbol)

    the environment type (:ci, :codespaces, :container, or :local)



14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 14

def environment_type
  if ENV["CI"]
    :ci
  elsif ENV["CODESPACES"] && ENV["CODESPACES"] == "true"
    :codespaces
  elsif inside_container?
    :container
  else
    :local
  end
end

#environment_type?(type) ⇒ Boolean

Checks if the current environment matches the given type.

Parameters:

  • type (Symbol)

    the environment type to check (:ci, :codespaces, :container, or :local)

Returns:

  • (Boolean)

    true if the current environment matches the given type, false otherwise



29
30
31
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 29

def environment_type?(type)
  environment_type == type
end

#inside_container?Boolean

Checks if the code is running inside a Docker container.

Returns:

  • (Boolean)

    true if inside a Docker container, false otherwise



8
9
10
# File 'lib/bidi2pdf_rails/test_helpers/environment_helper.rb', line 8

def inside_container?
  File.exist?("/.dockerenv")
end