Class: Stratagem::Model::Application

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/stratagem/model/application.rb

Overview

container for application

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApplication

Returns a new instance of Application.



17
18
19
20
21
22
23
24
25
26
# File 'lib/stratagem/model/application.rb', line 17

def initialize
  log "initializing application model"
  @models = Stratagem::Model::Containers::Base.new self
  @controllers = Stratagem::Model::Containers::Base.new self
  @routes = Stratagem::Model::Containers::Route.new self
  @views = Stratagem::Model::Containers::Base.new self
  @static_files = Stratagem::Model::Containers::Base.new self
  @gems = Stratagem::Model::Containers::Gem.new self
  @plugins = Stratagem::Model::Containers::Plugin.new self
end

Instance Attribute Details

#controllersObject (readonly)

Returns the value of attribute controllers.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def controllers
  @controllers
end

#crawlerObject

Returns the value of attribute crawler.



14
15
16
# File 'lib/stratagem/model/application.rb', line 14

def crawler
  @crawler
end

#gemsObject (readonly)

Returns the value of attribute gems.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def gems
  @gems
end

#modelsObject (readonly)

Returns the value of attribute models.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def models
  @models
end

#pluginsObject (readonly)

Returns the value of attribute plugins.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def plugins
  @plugins
end

#routesObject (readonly)

Returns the value of attribute routes.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def routes
  @routes
end

#static_filesObject (readonly)

Returns the value of attribute static_files.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def static_files
  @static_files
end

#viewsObject (readonly)

Returns the value of attribute views.



15
16
17
# File 'lib/stratagem/model/application.rb', line 15

def views
  @views
end

Instance Method Details

#exportObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/stratagem/model/application.rb', line 32

def export
  puts "exporting site model"
  puts "\tmapping #{Stratagem::Instrumentation::Models::Tracing.invocations_audit.size} references"
  references = []
  begin
    references = Stratagem::Instrumentation::Models::Tracing.invocations_audit.uniq.map {|ia| ia.to_reference.export }.uniq
  rescue
    puts $!.message
    puts $!.backtrace
  end

  puts "\tmapping #{Stratagem.logger.errors.size} errors"
  errors = Stratagem.logger.errors.compact.uniq
  begin
    h = {
      :rails_version => rails_version,
      :rails_environment => Rails.env,
      :rails_root => Rails.root.to_s,
      :plugins => @plugins.export,
      :scanning_exceptions_attributes => errors,

      :models_attributes => @models.export, 
      :controllers_attributes => @controllers.export, 
      :routes_attributes => @routes.export, 
      :views_attributes => @views.export,
      :gems => @gems.export,
      :references_attributes => references,
      :site_attributes => crawler ? crawler.export : {},
    }
  rescue
    puts $!.message
    puts $!.backtrace
  end
  puts "Sending snapshot of #{h.to_json.size} bytes"
  h
end

#log(msg) ⇒ Object



28
29
30
# File 'lib/stratagem/model/application.rb', line 28

def log(msg)
  Stratagem.logger.debug(msg)
end

#rails_versionObject



69
70
71
# File 'lib/stratagem/model/application.rb', line 69

def rails_version
  Stratagem.rails_version
end