lib/restfulx/configuration.rb in restfulx-1.2.5 vs lib/restfulx/configuration.rb in restfulx-1.3.0
- old
+ new
@@ -1,17 +1,21 @@
-# Interestingly enough there's no way to *just* upper-case or down-case first letter of a given
-# string. Ruby's own +capitalize+ actually downcases all the rest of the characters in the string
-# We patch the class to add our own implementation.
-require "yaml"
-require "erb"
-require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/config"
-require File.dirname(__FILE__) + "/rails/schema_to_yaml/settings/core"
+$:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
+require 'erb'
+require 'schema_to_rx_yaml' if !defined?(SchemaToRxYaml)
-Dir[File.dirname(__FILE__) + "/rails/schema_to_yaml/extensions/*.rb"].each do |f|
- require f
+# Enumerable extensions
+module Enumerable
+ # Helps you find duplicates
+ # used in schema_to_yaml.rb for cleanup
+ def dups
+ inject({}) { |h,v| h[v] = h[v].to_i + 1; h }.reject{ |k,v| v == 1 }.keys
+ end
end
+# Interestingly enough there's no way to *just* upper-case or down-case first letter of a given
+# string. Ruby's own +capitalize+ actually downcases all the rest of the characters in the string
+# We patch the class to add our own implementation.
class String
# Upper-case first character of a string leave the rest of the string intact
def ucfirst
self[0,1].capitalize + self[1..-1]
end
@@ -22,16 +26,16 @@
end
end
# Primary RestfulX configuration options
module RestfulX
- # Computes necessary configuration options from the environment. This can be used in Rails, Merb
+ # Computes necessary configuration options from the environment. This can be used in Rails
# or standalone from the command line.
module Configuration
# We try to figure out the application root using a number of possible options
- APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : defined?(Merb) ? Merb.root : File.expand_path(".")
+ APP_ROOT = defined?(RAILS_ROOT) ? RAILS_ROOT : File.expand_path(".")
- RxSettings = SchemaToYaml::Settings::Core
+ RxSettings = SchemaToRxYaml::Settings::Core
# Extract project, package, controller name, etc from the environment. This will respect
# config/restfulx.yml if it exists, you can override all of the defaults there.
def extract_names(project = nil)
if project
\ No newline at end of file