Class: Datagraph::Repository

Inherits:
Resource show all
Defined in:
lib/datagraph/repository.rb

Overview

Represents a Datagraph.org RDF repository.

Constant Summary

SPEC =

/account/repository

%r(^([^/]+)/([^/]+)$)

Constants inherited from Resource

HEADERS

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Resource

#<=>, #eql?, #exists?, #get, #head, #inspect, #inspect!, new, #to_rdf, #to_uri

Constructor Details

- (Repository) initialize(account_name, name)

A new instance of Repository

Parameters:

  • (String, #to_s) account_name
  • (String, #to_s) name


68
69
70
71
72
73
74
75
# File 'lib/datagraph/repository.rb', line 68

def initialize(, name)
  @account = case 
    when Account then 
    else Account.new(.to_s)
  end
  @name = name.to_s
  super(Datagraph::URL.join(@account.name, @name))
end

Instance Attribute Details

- (Account) account (readonly)

The account the repository belongs to.

Returns:



27
28
29
# File 'lib/datagraph/repository.rb', line 27

def 
  @account
end

- (DateTime) created (readonly)

The time that the repository was first created.

Returns:

  • (DateTime)


51
52
53
# File 'lib/datagraph/repository.rb', line 51

def created
  @created
end

- (String) description (readonly)

The long description of the repository.

Returns:

  • (String)


45
46
47
# File 'lib/datagraph/repository.rb', line 45

def description
  @description
end

- (String) name (readonly)

The machine-readable name of the repository.

Returns:

  • (String)


33
34
35
# File 'lib/datagraph/repository.rb', line 33

def name
  @name
end

- (String) summary (readonly)

The short description of the repository.

Returns:

  • (String)


39
40
41
# File 'lib/datagraph/repository.rb', line 39

def summary
  @summary
end

- (DateTime) updated (readonly)

The time that the repository was last updated.

Returns:

  • (DateTime)


57
58
59
# File 'lib/datagraph/repository.rb', line 57

def updated
  @updated
end

Class Method Details

+ (Enumerator) each(options = {}) {|repository| ... }

Parameters:

  • (Hash{Symbol => Object}) options (defaults to: {})

Options Hash (options):

  • (String) :account_name — default: nil

Yields:

  • (repository)

Yield Parameters:

Returns:

  • (Enumerator)


13
14
15
16
17
18
19
20
21
# File 'lib/datagraph/repository.rb', line 13

def self.each(options = {}, &block)
  if block_given?
    result = Datagraph::Client.rpc.call('datagraph.repository.list', options[:account_name] || '')
    result.each do |(, repository_name)|
      block.call(Repository.new(, repository_name))
    end
  end
  enum_for(:each, options)
end

Instance Method Details

- (Process) clear!

Deletes all data from this repository.

Returns:



97
98
99
# File 'lib/datagraph/repository.rb', line 97

def clear!
  Process.new(Datagraph::Client.rpc.call('datagraph.repository.clear', .name, name))
end

- (Integer) count

Returns the number of RDF statements in this repository.

Returns:

  • (Integer)


114
115
116
# File 'lib/datagraph/repository.rb', line 114

def count
  Datagraph::Client.rpc.call('datagraph.repository.count', .name, name)
end

- (Process) create!

Creates this repository on Datagraph.org.

Returns:



81
82
83
# File 'lib/datagraph/repository.rb', line 81

def create!
  Process.new(Datagraph::Client.rpc.call('datagraph.repository.create', .name, name))
end

- (Process) destroy!

Destroys this repository from Datagraph.org.

Returns:



89
90
91
# File 'lib/datagraph/repository.rb', line 89

def destroy!
  Process.new(Datagraph::Client.rpc.call('datagraph.repository.destroy', .name, name))
end

- (Process) import!(url)

Imports data from a URL into this repository.

Parameters:

  • (String, #to_s) url

Returns:



106
107
108
# File 'lib/datagraph/repository.rb', line 106

def import!(url)
  Process.new(Datagraph::Client.rpc.call('datagraph.repository.import', .name, name, url.to_s))
end

- (Process) query(query)

Queries this repository.

Parameters:

  • (String) query

Returns:



123
124
125
# File 'lib/datagraph/repository.rb', line 123

def query(query)
  Process.new(Datagraph::Client.rpc.call('datagraph.repository.query', .name, name, query.to_s))
end

- (String) to_s

Returns a string representation of the repository name.

Returns:

  • (String)


131
132
133
# File 'lib/datagraph/repository.rb', line 131

def to_s
  [.name, name].join('/')
end