Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added wrapper for config files and images
- Loading branch information
Showing
11 changed files
with
160 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
{ | ||
"recommend_endpoint": "http://localhost:8080/iOS/Recommend", | ||
"endpoint": "http://localhost:8080/iOS/Recommend", | ||
"song_file": "/local/picassound/index/songs", | ||
"base_file": "/local/picassound/base", | ||
"samples_file": "/local/picassound/index/samples", | ||
"data_file": "/local/picassound/index/data", | ||
"mappings_dir": "/local/picassound/mappings3/", | ||
"image_dir": "/local/picassound/images/" | ||
"image_dir": "/mnt/images/" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
require "json" | ||
|
||
module Picloud | ||
module Config | ||
["aws", "aws_keys", "picassound"].each do |cfg| | ||
cfg_file = File.join(Picloud.root_dir, "cfg/#{cfg}.json") | ||
cfg_hash = JSON.parse((File.read cfg_file), :symbolize_names => true) | ||
cfg_hash.each do |k,v| | ||
define_singleton_method k do | ||
v | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
require "picloud/config" | ||
require "uuidtools" | ||
|
||
module Picloud | ||
class Image | ||
attr_reader :data, :type, :size, :id, :path | ||
|
||
def initialize(type, data) | ||
@type = type | ||
@data = data | ||
@size = data.length | ||
end | ||
|
||
def id | ||
@id ||= UUIDTools::UUID.random_create.to_s | ||
end | ||
|
||
def store | ||
Dir.mkdir Config.image_dir unless Dir.exists? Config.image_dir | ||
file_name = "#{id.to_s}.#{type}" | ||
@path = File.join(Config.image_dir, file_name) | ||
File.open(path, "w") {|f| f.write data} | ||
|
||
@path | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.