lib/jackfs/adapters/db_adapter.rb in jackfs-0.0.3 vs lib/jackfs/adapters/db_adapter.rb in jackfs-0.0.4
- old
+ new
@@ -1,7 +1,8 @@
require 'base64'
require 'fileutils'
+require 'uri'
begin
require 'sequel/no_core_ext'
rescue LoadError
puts 'sequel gem is required to use file store'
@@ -19,11 +20,11 @@
@app_env = app_env
FileUtils.mkdir_p temp_file_path
yml = YAML.load_file(config_file)[@app_env.to_s]
- @connection = yml["connection"]
+ @connection = uri_escape(yml["connection"])
@table_name = yml["table_name"]
# Clean up temp files
FileUtils.remove_file(File.join(temp_file_path,'/*'), true)
end
@@ -34,10 +35,11 @@
:name => name,
:body => body,
:created_at => Time.now,
:updated_at => Time.now
)
+ name
end
def get(name)
record = data.where(:name => name).order(:name).first
unique_name = UUIDTools::UUID.random_create.to_s
@@ -70,8 +72,16 @@
end
def config_file
File.join(@app_root, Jackfs::FileStore::CONFIG_FILE)
end
+
+ def uri_escape(uri)
+ begin
+ URI.escape(uri)
+ rescue Exception => e
+ $stdout.puts "Error encountered when parsing #{uri} - #{e.message}"
+ end
+ end
end
end