Module: Apphunk
- Defined in:
- lib/apphunk.rb,
lib/apphunk/proxy.rb,
lib/apphunk/config.rb,
lib/apphunk/logger.rb
Defined Under Namespace
Modules: Config, Logger, Proxy
Class Attribute Summary collapse
-
.default_options ⇒ Object
Default options to be used for Apphunk.post.
Class Method Summary collapse
-
.config {|Apphunk::Config| ... } ⇒ Object
Set runtime configuration options.
-
.init_defaults ⇒ Object
Init configuration defaults.
-
.post(message, options = {}) ⇒ Object
Sends a
message
to your remote inbox at apphunk.com. -
.post_with_options(options = {}) {|_self| ... } ⇒ Object
Send messages with predefined options in a block.
-
.rails_environment ⇒ Object
Get the current rails environment if its Rails.
Class Attribute Details
.default_options ⇒ Object
Default options to be used for Apphunk.post. Initialized by Apphunk::Config.
13 14 15 |
# File 'lib/apphunk.rb', line 13 def @default_options end |
Class Method Details
.config {|Apphunk::Config| ... } ⇒ Object
Set runtime configuration options
Yields Apphunk::Config which can be used to set configuration options in one place. See Apphunk::Config for a list of available options. These options will be available in Apphunk.default_options.
Examples
Apphunk.config do |config|
config.token = "secret_project_token"
config.environments = %w(staging production)
end
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/apphunk.rb', line 68 def config(&block) yield Apphunk::Config self. ||= {} self.[:tags] = Apphunk::Config. self.[:token] = Apphunk::Config.token self.[:trails] = Apphunk::Config.trails unless Apphunk::Config.environments.nil? self.[:environments] = Apphunk::Config.environments end if Apphunk::Config.environment.nil? || Apphunk::Config.environment == "" Apphunk::Config.environment = self.[:environment] else self.[:environment] = Apphunk::Config.environment end end |
.init_defaults ⇒ Object
Init configuration defaults
87 88 89 90 91 92 93 94 |
# File 'lib/apphunk.rb', line 87 def init_defaults #:nodoc: if env = rails_environment Apphunk. = { :environment => env, :environments => %w(production) } end end |
.post(message, options = {}) ⇒ Object
Sends a message
to your remote inbox at apphunk.com
-
message
- The body of the message -
options
- A hash of options. Merges with Apphunk.default_options
For a list of available options see Apphunk::Config.
Examples
Apphunk.post("Yet another hello world")
Apphunk.post("Tag me baby", :tags => 'apphunk, doc, examples', :trails => { :user_id => 5 })
Apphunk.post("I'm on my way to a different project", :token => 'secret_project_access_token')
28 29 30 31 |
# File 'lib/apphunk.rb', line 28 def post(, = {}) = (self. || {}).merge() Apphunk::Proxy.(, ) end |
.post_with_options(options = {}) {|_self| ... } ⇒ Object
Send messages with predefined options in a block
Yields the Apphunk module which can be used to send messages via Apphunk.post, but temporarily merges the provided options
with Apphunk.default_options. Can be used to send a bunch of messages with the same options.
-
options
- A hash of options. Merges with Apphunk.default_options
For a list of available options see Apphunk::Config.
Examples
Apphunk.(:tags => 'hello world') do |apphunk|
apphunk.post("A messages with tags")
apphunk.post("Another messages with the same tags")
end
49 50 51 52 53 54 |
# File 'lib/apphunk.rb', line 49 def ( = {}, &block) preserved_defaults = self. self. = (self. || {}).merge() yield self self. = preserved_defaults end |
.rails_environment ⇒ Object
Get the current rails environment if its Rails
97 98 99 100 101 102 103 104 105 106 |
# File 'lib/apphunk.rb', line 97 def rails_environment #:nodoc: case when defined?(RAILS_ENV) RAILS_ENV when defined?(Rails.env) Rails.env else nil end end |