Sha256: b5741b205dfbc2ed5d7f29a8db7abd686249e8b9707c8048dfe57fa5f729b71f
Contents?: true
Size: 1.67 KB
Versions: 1
Compression:
Stored size: 1.67 KB
Contents
require 'yaml' require 'json' require 'fileutils' require 'tmpdir' require 'erb' module Shiba class Output WEB_PATH = File.join(File.dirname(__FILE__), "..", "..", "web") def self.tags @tags ||= YAML.load_file(File.join(File.dirname(__FILE__), "output", "tags.yaml")) end def initialize(queries, options = {}) @queries = queries @options = options end def default_filename @default_filename ||= "shiba_results-#{Time.now.to_i}.html" end def logdir File.join(Dir.pwd, "log") end def output_path return @options['output'] if @options['output'] if File.exist?(logdir) FileUtils.mkdir_p(File.join(logdir, "shiba_results")) File.join(Dir.pwd, "log", "shiba_results", default_filename) else File.join(Shiba.path, default_filename) end end def js_path File.join(output_path, "js") end def remote_url url = `git config --get remote.origin.url` rescue nil return nil unless url return nil if url =~ %r{burrito-brothers/shiba} url.chomp! url.gsub!('git@github.com:', 'https://github.com/') url.gsub!(/\.git$/, '') url + '/blob/master/' end def make_web! js = Dir.glob(File.join(WEB_PATH, "dist", "*.js")) css = Dir.glob(File.join(WEB_PATH, "*.css")) data = { js: js, css: css, queries: @queries, tags: self.class.tags, url: remote_url } erb = ERB.new(File.read(File.join(WEB_PATH, "..", "web", "results.html.erb"))) File.open(output_path, "w+") do |f| f.write(erb.result(binding)) end output_path end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
shiba-0.3.0 | lib/shiba/output.rb |