Last active
August 29, 2015 14:03
-
-
Save tfentonz/c0ed391e70c79beb422d to your computer and use it in GitHub Desktop.
Append a fixed width format line to keywords file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'json' | |
def keywords_file | |
ENV['PJKKG'] + '01' | |
end | |
def keywords_line(project) | |
line = format('%-20s', project['project_id']) | |
line += ' ' + format('%-30s', project['name']) | |
line += ' ' + format('%-60s', project['description']) | |
line.strip | |
end | |
project = JSON.parse("{ \"project_id\": \"1234567\", \"name\": \"Project name\", | |
\"description\": \"Project description\" }") | |
open(keywords_file, 'a') { |f| f.puts keywords_line(project) } if File.exists?(keywords_file) | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment