Sha256: e49a4bee91a3f72910f5ac98715b46cc66c441c1757227871a2c58313f7f55da

Contents?: true

Size: 843 Bytes

Versions: 5

Compression:

Stored size: 843 Bytes

Contents

#!/usr/bin/env ruby

require 'open-uri'
require 'json'

def get_story_info(story_id)
  return nil if story_id.empty?

  begin
    open("https://www.pivotaltracker.com/services/v5/stories/#{story_id}", 'X-TrackerToken' => ENV['PIVOTAL_TRACKER_API_TOKEN']).read
  rescue StandardError => e
    JSON.generate({error: "could not get story info for story #{story_id}: #{e.message}\nstory info may be available at https://www.pivotaltracker.com/story/show/#{story_id}"})
  end
end

stream = ARGV.any? ? ARGV : ARGF

if stream == ARGF && $stdin.tty?
  puts "Usage:\nget-story-info-from-id STORY_ID\n"
  puts " OR\n"
  puts "echo STORY_ID | get-story-info-from-id"
  exit 1
end

infos = stream.reduce([]) do |reduced, story_id|
  next reduced unless story_id && story_id =~ /\d+/
  reduced << get_story_info(story_id.strip)
end

puts infos.join("\n")

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
pivotoolz-1.0.0 exe/get-story-info-from-id
pivotoolz-0.2.0 exe/get-story-info-from-id
pivotoolz-0.1.3 exe/get-story-info-from-id
pivotoolz-0.1.2 exe/get-story-info-from-id
pivotoolz-0.1.1 exe/get-story-info-from-id