Class: CloudFile::Service

Inherits:
Object show all
Includes:
FromHash
Defined in:
lib/cloud_file/service.rb

Direct Known Subclasses

Dropbox, Evernote, Gdrive, Local, Memory

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.formatObject

Returns the value of attribute format.



55
56
57
# File 'lib/cloud_file/service.rb', line 55

def format
  @format
end

.location_params(*args) ⇒ Object

Returns the value of attribute location_params.



55
56
57
# File 'lib/cloud_file/service.rb', line 55

def location_params
  @location_params
end

.providerObject

Returns the value of attribute provider.



55
56
57
# File 'lib/cloud_file/service.rb', line 55

def provider
  @provider
end

.uri_parserObject

Returns the value of attribute uri_parser.



74
75
76
# File 'lib/cloud_file/service.rb', line 74

def uri_parser
  @uri_parser
end

Class Method Details

.auth_value(*args) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/cloud_file/service.rb', line 6

def auth_value(*args)
  args.flatten.each do |meth|
    define_method(meth) do
      auth_hash[meth.to_s]
    end
    define_method("#{meth}=") do |val|
      auth_hash[meth.to_s] = val
    end
  end
end

.for_user(user) ⇒ Object



48
49
50
51
52
53
# File 'lib/cloud_file/service.rb', line 48

def for_user(user)
  #puts user.identities.map { |x| x.provider }.inspect
  #puts name
  ident = user.identities.find { |x| x.provider == provider }
  new(:access_token => ident.access_token, :access_secret => ident.access_secret)
end

.register(ops) ⇒ Object



56
57
58
59
60
61
# File 'lib/cloud_file/service.rb', line 56

def register(ops)
  ::CloudFile::Services << self
  ops.each do |k,v|
    send("#{k}=",v)
  end
end

.register_converter(ops, &b) ⇒ Object



62
63
64
# File 'lib/cloud_file/service.rb', line 62

def register_converter(ops,&b)
  ::CloudFile::Convertors.register(ops,&b)
end

.uri_format(str) ⇒ Object



75
76
77
# File 'lib/cloud_file/service.rb', line 75

def uri_format(str)
  CloudUri::Dsl.new(:service_class => self, :format => str).run!
end

Instance Method Details

#files(*args) ⇒ Object



31
32
33
34
35
# File 'lib/cloud_file/service.rb', line 31

def files(*args)
  list(*args).map do |f|
    CloudFile::File.new(:service => self, :loc => f)
  end
end

#open(ops) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/cloud_file/service.rb', line 39

def open(ops)
  file = CloudFile::File.new(:loc => ops, :service => self)
  if block_given?
    yield(file)
  end
  file
end

#read(ops) ⇒ Object

Raises:

  • (NotImplementedError)


20
21
22
# File 'lib/cloud_file/service.rb', line 20

def read(ops)
  raise NotImplementedError.new("read")
end

#read_format(target_format, ops) ⇒ Object



27
28
29
# File 'lib/cloud_file/service.rb', line 27

def read_format(target_format,ops)
  ::CloudFile::Convertors.convert(self.class.format,target_format,read(ops))
end

#write(ops, val) ⇒ Object

Raises:

  • (NotImplementedError)


23
24
25
# File 'lib/cloud_file/service.rb', line 23

def write(ops,val)
  raise NotImplementedError.new("write")
end