Class: RailsWayback::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_wayback/configuration.rb

Constant Summary collapse

DEFAULT_VIEW_PATHS =

Includes the common places where Rails apps put render targets. app/components is picked up by the ViewComponent gem; app/views is stock Rails.

["app/views", "app/components"].freeze
DEFAULT_ASSET_PATHS =
["app/assets", "public"].freeze
DEFAULT_MAX_COMMITS =
50
DEFAULT_MAX_RESPONSE_BYTES =
2 * 1024 * 1024
DEFAULT_ALLOWED_ENVIRONMENTS =
%w[development test].freeze
DEFAULT_TRUSTED_REF_PATTERNS =
["refs/heads/*"].freeze
DEFAULT_MAX_CACHED_REFS =
25
DEFAULT_MAX_CACHE_BYTES =
512 * 1024 * 1024

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Configuration

Returns a new instance of Configuration.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rails_wayback/configuration.rb', line 23

def initialize
  @view_paths = DEFAULT_VIEW_PATHS.dup
  @asset_paths = DEFAULT_ASSET_PATHS.dup
  @max_commits = DEFAULT_MAX_COMMITS
  @max_response_bytes = DEFAULT_MAX_RESPONSE_BYTES
  @allowed_environments = DEFAULT_ALLOWED_ENVIRONMENTS.dup
  @trusted_ref_patterns = DEFAULT_TRUSTED_REF_PATTERNS.dup
  @max_cached_refs = DEFAULT_MAX_CACHED_REFS
  @max_cache_bytes = DEFAULT_MAX_CACHE_BYTES
  @app_root = nil
  @cache_root = nil
  @toggle_file = nil
end

Instance Attribute Details

#allowed_environments ⇒ Object

Returns the value of attribute allowed_environments.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def allowed_environments
  @allowed_environments
end

#app_root ⇒ Object

Returns the value of attribute app_root.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def app_root
  @app_root
end

#asset_paths ⇒ Object

Returns the value of attribute asset_paths.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def asset_paths
  @asset_paths
end

#cache_root ⇒ Object

Returns the value of attribute cache_root.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def cache_root
  @cache_root
end

#max_cache_bytes ⇒ Object

Returns the value of attribute max_cache_bytes.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def max_cache_bytes
  @max_cache_bytes
end

#max_cached_refs ⇒ Object

Returns the value of attribute max_cached_refs.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def max_cached_refs
  @max_cached_refs
end

#max_commits ⇒ Object

Returns the value of attribute max_commits.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def max_commits
  @max_commits
end

#max_response_bytes ⇒ Object

Returns the value of attribute max_response_bytes.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def max_response_bytes
  @max_response_bytes
end

#toggle_file ⇒ Object

Returns the value of attribute toggle_file.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def toggle_file
  @toggle_file
end

#trusted_ref_patterns ⇒ Object

Returns the value of attribute trusted_ref_patterns.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def trusted_ref_patterns
  @trusted_ref_patterns
end

#view_paths ⇒ Object

Returns the value of attribute view_paths.



19
20
21
# File 'lib/rails_wayback/configuration.rb', line 19

def view_paths
  @view_paths
end

Instance Method Details

#app_root_path ⇒ Object



37
38
39
# File 'lib/rails_wayback/configuration.rb', line 37

def app_root_path
  Pathname.new(@app_root || RailsWayback.root)
end

#cache_root_path ⇒ Object



41
42
43
# File 'lib/rails_wayback/configuration.rb', line 41

def cache_root_path
  Pathname.new(@cache_root || app_root_path.join("tmp", "rails_wayback"))
end

#refs_cache_path ⇒ Object



49
50
51
# File 'lib/rails_wayback/configuration.rb', line 49

def refs_cache_path
  cache_root_path.join("refs")
end

#toggle_file_path ⇒ Object



45
46
47
# File 'lib/rails_wayback/configuration.rb', line 45

def toggle_file_path
  Pathname.new(@toggle_file || cache_root_path.join("enabled"))
end