Module: PubliSci::DSL

Included in:
Instance
Defined in:
lib/publisci/dsl/dsl.rb,
lib/publisci/dsl/config.rb

Defined Under Namespace

Classes: Configuration, Instance

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_urlObject

Returns the value of attribute base_url


3
4
5
# File 'lib/publisci/dsl/dsl.rb', line 3

def base_url
  @base_url
end

Instance Method Details

#configurationObject


36
37
38
# File 'lib/publisci/dsl/dsl.rb', line 36

def configuration
  @_dsl_config ||= DSL::Configuration.new
end

#configure {|configuration| ... } ⇒ Object

Yields:


40
41
42
# File 'lib/publisci/dsl/dsl.rb', line 40

def configure
  yield configuration
end

#data(&block) ⇒ Object


15
16
17
18
19
20
# File 'lib/publisci/dsl/dsl.rb', line 15

def data(&block)
  inst=PubliSci::Dataset::DSL::Instance.new
  inst.instance_eval(&block)
  @_dsl_data ||= [] << inst
  inst
end

#generate_n3Object


48
49
50
51
52
53
54
# File 'lib/publisci/dsl/dsl.rb', line 48

def generate_n3
  out = ""
  @_dsl_data.each{|dat| out << dat.generate_n3 } if @_dsl_data
  out << @_dsl_metadata.generate_n3 if @_dsl_metadata
  out << @_dsl_prov.generate_n3 if @_dsl_prov
  out
end

#metadata(&block) ⇒ Object


22
23
24
25
26
27
# File 'lib/publisci/dsl/dsl.rb', line 22

def (&block)
  inst=PubliSci::Metadata::DSL::Instance.new
  inst.instance_eval(&block)
  @_dsl_metadata = inst
  inst
end

#provenance(&block) ⇒ Object


29
30
31
32
33
34
# File 'lib/publisci/dsl/dsl.rb', line 29

def provenance(&block)
  inst=PubliSci::Prov::DSL::Instance.new
  inst.instance_eval(&block)
  @_dsl_prov = inst
  inst
end

#settingsObject


44
45
46
# File 'lib/publisci/dsl/dsl.rb', line 44

def settings
  configuration
end

#to_repository(turtle_string = generate_n3) ⇒ Object


56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/publisci/dsl/dsl.rb', line 56

def to_repository(turtle_string=generate_n3)
  repo = settings.repository
  case repo
  when :in_memory
    repo = RDF::Repository.new
  when :fourstore
    repo = RDF::FourStore::Repository.new('http://localhost:8080')
  end
  f=Tempfile.new(['repo','.ttl'])
  f.write(turtle_string)
  f.close
  repo.load(f.path, :format => :ttl).to_s
  f.unlink
  repo
end