Module: GoodData::Bam::Repository
- Defined in:
- lib/base/repo.rb
Class Method Summary collapse
Class Method Details
.create(repository) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/base/repo.rb', line 5 def self.create(repository) fail "repository has to have \"type\" defined. You specified \"#{repository}\"" unless repository.has_key?(:type) case repository[:type] when :file repository.merge({ :base => Pathname(repository[:base])}) when :hash fail "Repo has to have content defined" if repository[:content].nil? || !repository[:content].is_a?(Hash) repository when :http repository.merge({ :base => URI(repository[:base])}) end end |
.find(repository, path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/base/repo.rb', line 20 def self.find(repository, path) case repository[:type] when :file path = repository[:base] + Pathname(path) if (path).exist? Graph.create({ :path => Pathname(path)., :repository => repository }) end when :hash Graph.create(repository[:content][path]) when :http path = repository[:base] + URI(path) puts path begin RestClient.get(path.to_s) Graph.create({ :path => path, :repository => repository }) rescue RestClient::ResourceNotFound => e nil end else fail "not implemented" end end |