Module: Loader::Utils
Instance Method Summary collapse
- #pwd ⇒ Object
- #require(file_path) ⇒ Object
-
#underscore(camel_cased_word) ⇒ Object
Based on ActiveSupport, removed inflections.
Instance Method Details
#pwd ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/loader/utils.rb', line 12 def pwd if !!ENV['BUNDLE_GEMFILE'] ENV['BUNDLE_GEMFILE'].split(File::Separator)[0..-2].join(File::Separator) elsif defined?(Rails) && Rails.respond_to?(:root) && Rails.root Rails.root.to_s else Dir.pwd end end |
#require(file_path) ⇒ Object
6 7 8 9 10 |
# File 'lib/loader/utils.rb', line 6 def require(file_path) Kernel.require(file_path) rescue LoadError Kernel.load(file_path) end |
#underscore(camel_cased_word) ⇒ Object
Based on ActiveSupport, removed inflections. github.com/rails/rails/blob/v4.1.0.rc1/activesupport/lib/active_support/inflector/methods.rb
24 25 26 27 28 29 30 31 |
# File 'lib/loader/utils.rb', line 24 def underscore(camel_cased_word) word = camel_cased_word.to_s.gsub('::', '/') word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2') word.gsub!(/([a-z\d])([A-Z])/, '\1_\2') word.tr!("-", "_") word.downcase! word end |