Module: Bwkfanboy::Utils
Instance Method Summary collapse
-
#atom(pluginsPath, name, opt) ⇒ Object
Do all the work of reading the plugin, parsing and generating the atom feed.
-
#skeletonCreate(template, desiredName) ⇒ Object
- template
-
a full path to a .erb file [desiredName] a future skeleton name.
Instance Method Details
#atom(pluginsPath, name, opt) ⇒ Object
Do all the work of reading the plugin, parsing and generating the atom feed. FIXME: ensure all streams are closed
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/bwkfanboy/utils.rb', line 46 def atom pluginsPath, name, opt p = Plugin.new pluginsPath, name, opt streams = Fetch.openStreams p.uri p.run_parser(streams) r = Generator.atom p.export Fetch.closeStreams streams r end |
#skeletonCreate(template, desiredName) ⇒ Object
- template
-
a full path to a .erb file
- desiredName
-
a future skeleton name
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bwkfanboy/utils.rb', line 16 def skeletonCreate template, desiredName t = ERB.new File.read template t.filename = template # to report errors relative to this file begin md5_system = Digest::MD5.hexdigest t.result(binding) rescue Exception CliUtils.errx EX_SOFTWARE, "cannot read the template: #{$!}" end if ! File.exists?(desiredName) # create a new skeleton begin File.open(desiredName, 'w+') { |fp| fp.puts t.result(binding) } rescue CliUtils.errx EX_IOERR, "cannot write the skeleton: #{$!}" end else # warn a careless user if md5_system != Digest::MD5.file(desiredName).hexdigest CliUtils.warnx "#{desiredName} already exists" return false end end true end |