Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Feature/ahn root #148

Merged
merged 5 commits into from

2 participants

@polysics
Owner

Added Adhearsion.root and Adhearsion.root, deprecated Adhearsion.ahn_root=, added Adhearsion.deprecated.

@benlangfeld benlangfeld commented on the diff
lib/adhearsion.rb
((6 lines not shown))
Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
end
+ def root
+ Adhearsion.config[:platform].root
+ end
+
@benlangfeld Owner

Whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/adhearsion.rb
((6 lines not shown))
Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
end
+ def root
@benlangfeld Owner

Can we add some API docs here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/adhearsion.rb
@@ -37,16 +37,34 @@ module Adhearsion
class << self
- def ahn_root=(path)
+ def root=(path)
@benlangfeld Owner

Can we add some API docs here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
lib/adhearsion.rb
((6 lines not shown))
Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
end
+ def root
+ Adhearsion.config[:platform].root
+ end
+
+
+ #
+ # @deprecated Use #root= instead
+ #
+ def ahn_root=(path)
+ Adhearsion.deprecated("#Adhearsion.root=")
@benlangfeld Owner

parens

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@benlangfeld benlangfeld merged commit b8d3714 into develop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 48 additions and 2 deletions.
  1. +3 −1 CHANGELOG.md
  2. +26 −1 lib/adhearsion.rb
  3. +19 −0 spec/adhearsion_spec.rb
View
4 CHANGELOG.md
@@ -1,5 +1,7 @@
# [develop](https://github.com/adhearsion/adhearsion)
-* CallController#record now has an :interruptible option that allows recording to be stopped by pressing any DTMF key
+ * CallController#record now has an :interruptible option that allows recording to be stopped by pressing any DTMF key
+ * Adhearsion.root and Adhearsion.root= are now available to return the root path to the application. Adhearsion.ahn_root= is deprecated.
+ * Adhearsion.deprecated added for internal use to clearly mark deprecated methods.
# [2.0.0](https://github.com/adhearsion/adhearsion/compare/v1.2.1...v2.0.0) - [2012-04-11](https://rubygems.org/gems/adhearsion/versions/2.0.0)
View
27 lib/adhearsion.rb
@@ -37,16 +37,41 @@ module Adhearsion
class << self
- def ahn_root=(path)
+ #
+ # Sets the application path
+ # @param[String|Pathname] The application path to set
+ #
+ def root=(path)
Adhearsion.config[:platform].root = path.nil? ? nil : File.expand_path(path)
end
+ #
+ # Returns the current application path
+ # @return [Pathname] The application path
+ #
+ def root
+ Adhearsion.config[:platform].root
+ end
+
@benlangfeld Owner

Whitespace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ #
+ # @deprecated Use #root= instead
+ #
+ def ahn_root=(path)
+ Adhearsion.deprecated "#Adhearsion.root="
+ Adhearsion.root = path
+ end
+
def config(&block)
@config ||= initialize_config
block_given? and yield @config
@config
end
+ def deprecated(new_method)
+ logger.info "#{caller[0]} - This method is deprecated, please use #{new_method}."
+ logger.warn caller.join("\n")
+ end
+
def initialize_config
_config = Configuration.new
env = ENV['AHN_ENV'] || ENV['RAILS_ENV']
View
19 spec/adhearsion_spec.rb
@@ -3,6 +3,25 @@
require 'spec_helper'
describe Adhearsion do
+ describe "#root=" do
+ it "should update properly the config root variable" do
+ Adhearsion.root = "./"
+ Adhearsion.config[:platform].root.should be == Dir.getwd
+ end
+
+ it "should update properly the config root variable when path is nil" do
+ Adhearsion.root = nil
+ Adhearsion.config[:platform].root.should be_nil
+ end
+ end
+
+ describe "#root" do
+ it "should return the set root" do
+ Adhearsion.root = "./"
+ Adhearsion.root.should be == Dir.getwd
+ end
+ end
+
describe "#ahn_root=" do
it "should update properly the config root variable" do
Adhearsion.ahn_root = "./"
Something went wrong with that request. Please try again.