Module: MetricFu::Environment
- Included in:
- Configuration
- Defined in:
- lib/metric_fu/environment.rb
Class Method Summary collapse
Instance Method Summary collapse
- #debug_info ⇒ Object
- #environment_details ⇒ Object
- #is_cruise_control_rb? ⇒ Boolean
- #jruby? ⇒ Boolean
- #library_details ⇒ Object
- #mri? ⇒ Boolean
- #osx? ⇒ Boolean
-
#platform ⇒ Object
:nodoc:.
-
#rails? ⇒ Boolean
Perform a simple check to try and guess if we’re running against a rails app.
- #rubinius? ⇒ Boolean
- #ruby18? ⇒ Boolean
- #ruby192? ⇒ Boolean
-
#ruby_details ⇒ Object
To consider $LOADED_FEATURES $LOAD_PATH.
- #ruby_flavor ⇒ Object
- #ruby_version ⇒ Object
- #supports_ripper? ⇒ Boolean
-
#verbose ⇒ Object
TODO: Set log_level here, instead.
- #verbose=(toggle) ⇒ Object
- #version ⇒ Object
Class Method Details
.ruby_strangely_makes_accessors_private? ⇒ Boolean
124 125 126 |
# File 'lib/metric_fu/environment.rb', line 124 def ruby_strangely_makes_accessors_private? @private_accessors ||= ruby192? || jruby? end |
Instance Method Details
#debug_info ⇒ Object
112 113 114 115 116 117 118 |
# File 'lib/metric_fu/environment.rb', line 112 def debug_info @debug_info ||= { "Ruby" => ruby_details, "Environment" => environment_details, "MetricFu" => library_details, } end |
#environment_details ⇒ Object
78 79 80 81 82 83 84 85 86 87 |
# File 'lib/metric_fu/environment.rb', line 78 def environment_details @environment_details ||= { "VERBOSE" => $VERBOSE.inspect, "External Encoding" => Encoding.default_external.to_s, "Internal Encoding" => Encoding.default_internal.to_s, "Host Architecture" => RbConfig::CONFIG["build"], "Ruby Prefix" => RbConfig::CONFIG["prefix"], "Ruby Options" => ENV.keys.grep(/RUBYOPT/).map { |key| "#{key}=#{ENV[key]}" }.join(", "), } end |
#is_cruise_control_rb? ⇒ Boolean
29 30 31 |
# File 'lib/metric_fu/environment.rb', line 29 def is_cruise_control_rb? !!ENV["CC_BUILD_ARTIFACTS"] end |
#jruby? ⇒ Boolean
33 34 35 |
# File 'lib/metric_fu/environment.rb', line 33 def jruby? @jruby ||= !!RedCard.check(:jruby) end |
#library_details ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/metric_fu/environment.rb', line 103 def library_details @library_details ||= { "Version" => version, "Verbose Mode" => verbose, "Enabled Metrics" => MetricFu::Metric.enabled_metrics.map(&:name), "Dependencies" => MetricFu::GemVersion.dependencies_summary, } end |
#mri? ⇒ Boolean
37 38 39 |
# File 'lib/metric_fu/environment.rb', line 37 def mri? @mri ||= !!RedCard.check(:ruby) end |
#osx? ⇒ Boolean
120 121 122 |
# File 'lib/metric_fu/environment.rb', line 120 def osx? @osx ||= platform.include?("darwin") end |
#platform ⇒ Object
:nodoc:
70 71 72 |
# File 'lib/metric_fu/environment.rb', line 70 def platform #:nodoc: RUBY_PLATFORM end |
#rails? ⇒ Boolean
Perform a simple check to try and guess if we’re running against a rails app.
TODO This should probably be made a bit more robust.
19 20 21 22 23 24 25 26 27 |
# File 'lib/metric_fu/environment.rb', line 19 def rails? @rails ||= begin exists = File.exist?("config/environment.rb") def MetricFu.rails? exists end exists end end |
#rubinius? ⇒ Boolean
57 58 59 |
# File 'lib/metric_fu/environment.rb', line 57 def rubinius? @rubinius ||= !!RedCard.check(:rubinius) end |
#ruby18? ⇒ Boolean
49 50 51 |
# File 'lib/metric_fu/environment.rb', line 49 def ruby18? @ruby18 ||= mri? && !!RedCard.check("1.8"..."1.9") end |
#ruby192? ⇒ Boolean
53 54 55 |
# File 'lib/metric_fu/environment.rb', line 53 def ruby192? @ruby192 ||= mri? && ruby_version == "1.9.2" end |
#ruby_details ⇒ Object
To consider $LOADED_FEATURES $LOAD_PATH
92 93 94 95 96 97 98 99 100 101 |
# File 'lib/metric_fu/environment.rb', line 92 def ruby_details @ruby_details ||= { "Engine" => ruby_flavor, "Version" => ruby_version, "Patchlevel" => (defined?(RUBY_PATCHLEVEL) && RUBY_PATCHLEVEL), "Ripper Support" => supports_ripper?, "Rubygems Version" => Gem::VERSION, "Long Description" => (defined?(RUBY_DESCRIPTION) ? RUBY_DESCRIPTION : platform), } end |
#ruby_flavor ⇒ Object
41 42 43 |
# File 'lib/metric_fu/environment.rb', line 41 def ruby_flavor @ruby_flavor ||= RedCard.engine end |
#ruby_version ⇒ Object
45 46 47 |
# File 'lib/metric_fu/environment.rb', line 45 def ruby_version @ruby_version ||= RedCard.engine_version end |
#supports_ripper? ⇒ Boolean
61 62 63 64 65 66 67 68 |
# File 'lib/metric_fu/environment.rb', line 61 def supports_ripper? @supports_ripper ||= begin require "ripper" true rescue LoadError false end end |
#verbose ⇒ Object
TODO: Set log_level here, instead
7 8 9 |
# File 'lib/metric_fu/environment.rb', line 7 def verbose MetricFu.logger.debug_on end |