Class: Yetty::Publisher

Inherits:
Shelr::Publisher
  • Object
show all
Defined in:
lib/yetty/record.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_name = 'yetty.json') ⇒ Publisher

Returns a new instance of Publisher.



10
11
12
13
# File 'lib/yetty/record.rb', line 10

def initialize(file_name='yetty.json')
  @file_name = file_name
  super()
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



8
9
10
# File 'lib/yetty/record.rb', line 8

def file_name
  @file_name
end

Instance Method Details

#dump_filenameObject



31
32
33
# File 'lib/yetty/record.rb', line 31

def dump_filename
  file_name
end

#prepare(id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/yetty/record.rb', line 15

def prepare(id)
  out = {}
  ['meta', 'timing', 'typescript'].each do |file|
    out[file] = File.read(File.join(Shelr.data_dir(id), file))
  end

  meta = JSON.parse(out.delete('meta'))
  meta.each { |k,v| out[k] = v }
  STDOUT.print 'Description: '
  out['description'] = STDIN.gets.strip
  STDOUT.print 'Tags (ex: howto, linux): '
  out['tags'] = STDIN.gets.strip
  out['private'] = @private
  return out.to_json
end