Skip to content

Instantly share code, notes, and snippets.

@masoo
Created Jan 9, 2021
Embed
What would you like to do?
proposal
# coding: utf-8
require "erb"
require "optparse"
proposal_file = nil
requester = nil
request_title = nil
crowdsourcing_site_name = nil
options = OptionParser.new
options.on('--proposal_file file_name') {|v| proposal_file = v } # 提案テンプレート
options.on('--requester requester') {|v| requester = v.encode(Encoding::UTF_8) } # 依頼者名
options.on('--request_title title') {|v| request_title = v.encode(Encoding::UTF_8) } # 依頼タイトル
options.on('--crowdsourcing name') {|v| crowdsourcing_site_name = v.encode(Encoding::UTF_8) } # クラウドソーシング名
options.parse!(ARGV)
# ファイル読み込み
proposal_text = File.read(proposal_file, encoding: Encoding::UTF_8)
# 提案文生成
erb = ERB.new(proposal_text)
puts erb.result(binding)
requester = "株式会社ABC"
request_title = "案件タイトル"
crowdsourcing = "クラウドソーシング名"
script = "ruby proposal.rb --proposal_file proposal_template.txt --requester \"#{requester}\" --request_title \"#{request_title}\" --crowdsourcing \"#{crowdsourcing}\" > C:\\Users\\xxxx\\Downloads\\proposal_output.txt"
system(script)
puts "C:\\Users\\xxxx\\Downloads\\proposal_output.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment