Module: FiverunsTuneupMerb

Extended by:
APIKey
Defined in:
lib/fiveruns_tuneup_merb.rb,
lib/fiveruns_tuneup_merb/api_key.rb,
lib/fiveruns_tuneup_merb/instrumentation.rb

Overview

All Slice code is expected to be namespaced inside a module

Defined Under Namespace

Modules: APIKey, Instrumentation Classes: Application, Runs

Class Method Summary collapse

Methods included from APIKey

can_share?, log_share_status

Class Method Details

.activateObject

Activation hook - runs after AfterAppLoads BootLoader



70
71
# File 'lib/fiveruns_tuneup_merb.rb', line 70

def self.activate
end

.deactivateObject

Deactivation hook - triggered by Merb::Slices.deactivate(FiverunsTuneupMerb)



74
75
# File 'lib/fiveruns_tuneup_merb.rb', line 74

def self.deactivate
end

.initObject

Initialization hook - runs before AfterAppLoads BootLoader



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fiveruns_tuneup_merb.rb', line 55

def self.init
  if Merb::Config[:adapter] != 'irb'
    Merb.logger.info "Instrumenting with TuneUp"
    ::Merb::Request.extend(FiverunsTuneupMerb::Instrumentation::Merb::Request)
    ::Merb::Controller.extend(FiverunsTuneupMerb::Instrumentation::Merb::Controller)
    if defined?(::DataMapper)
      ::DataMapper::Repository.extend(FiverunsTuneupMerb::Instrumentation::DataMapper::Repository)
    end
    log_share_status
  else
    Merb.logger.info "Not instrumenting with TuneUp (adapter is '#{Merb::Config[:adapter]}')"
  end
end

.loadedObject

Stub classes loaded hook - runs before LoadClasses BootLoader right after a slice’s classes have been loaded internally.



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/fiveruns_tuneup_merb.rb', line 41

def self.loaded
  Fiveruns::Tuneup::Run.directory = config[:run_directory]
  Fiveruns::Tuneup::Run.api_key  =  config[:api_key]
  Fiveruns::Tuneup::Run.environment.update(
    :application_name => config[:application_name],
    :framework => 'merb',
    :framework_version => Merb::VERSION.to_s,
    :framework_env => Merb.env.to_s
  )
  Fiveruns::Tuneup.javascripts_path = FiverunsTuneupMerb.public_dir_for('javascripts')
  Fiveruns::Tuneup.stylesheets_path = FiverunsTuneupMerb.public_dir_for('stylesheets')
end

.setup_router(scope) ⇒ Object

Note:

prefix your named routes with :fiveruns_tuneup_merb_ to avoid potential conflicts with global named routes.

Setup routes inside the host application

Parameters:

  • scope (Merb::Router::Behaviour)

    Routes will be added within this scope (namespace). In fact, any router behaviour is a valid namespace, so you can attach routes at any level of your router setup.



86
87
88
89
90
91
# File 'lib/fiveruns_tuneup_merb.rb', line 86

def self.setup_router(scope)
  if Fiveruns::Tuneup::Run.api_key?
    # example of a named route
    scope.match(%r{/share/(.+)}).to(:controller => 'runs', :action => 'share', :slug => '[1]').name(:fiveruns_tuneup_merb_share_run)
  end
end