class Qiita::Build::Command
Public Class Methods
new(stdin, argv)
click to toggle source
# File lib/qiita/build/command.rb, line 8 def initialize(stdin, argv) @options = {} @json = JSON.parse(stdin) @argv = parse_options!(argv) end
Public Instance Methods
run()
click to toggle source
# File lib/qiita/build/command.rb, line 14 def run client = Qiita::Client.new(team: team, access_token: access_token) response = client.get_template(template_id) template = response.body["body"] puts Builder.new.build(template: template, json: @json) end
Private Instance Methods
access_token()
click to toggle source
# File lib/qiita/build/command.rb, line 36 def access_token @options[:access_token] end
option_parser()
click to toggle source
# File lib/qiita/build/command.rb, line 32 def option_parser @option_parser ||= OptionParser.new end
parse_options!(options)
click to toggle source
# File lib/qiita/build/command.rb, line 23 def parse_options!(options) option_parser.on("-a VAL", "--access-token=VAL") { |v| @options[:access_token] = v } option_parser.on("-t VAL", "--team=VAL") { |v| @options[:team] = v } argv = option_parser.parse!(options) argv.delete(access_token) argv.delete(team) argv end
team()
click to toggle source
# File lib/qiita/build/command.rb, line 40 def team @options[:team] end
template_id()
click to toggle source
# File lib/qiita/build/command.rb, line 44 def template_id @template_id ||= @argv.pop end