Last active
December 26, 2015 06:39
-
-
Save ys/7108981 to your computer and use it in GitHub Desktop.
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
.bundle |
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
source 'https://rubygems.org' | |
gem 'netrc' | |
gem 'octokit' |
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
GEM | |
remote: https://rubygems.org/ | |
specs: | |
addressable (2.3.5) | |
faraday (0.8.8) | |
multipart-post (~> 1.2.0) | |
multipart-post (1.2.0) | |
netrc (0.7.7) | |
octokit (2.7.0) | |
sawyer (~> 0.5.2) | |
sawyer (0.5.2) | |
addressable (~> 2.3.5) | |
faraday (~> 0.8, < 0.10) | |
PLATFORMS | |
ruby | |
DEPENDENCIES | |
netrc | |
octokit |
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
require 'octokit' | |
class PuppetFileVersions | |
EX_USAGE = 64 | |
def initialize(file_path) | |
@file_path = file_path | |
end | |
def run | |
exit_if_no_file | |
instance_eval(read_file) | |
end | |
private | |
def mod(name, version, options) | |
$stdout.puts "#{name} :: #{client.tags(options[:github_tarball]).first.name}" | |
rescue => e | |
$stdout.puts "#{name} :: no version found. #{e.message}" | |
end | |
def read_file | |
File.open(@file_path, "r") { |f| f.read } | |
end | |
def exit_if_no_file | |
unless @file_path | |
$stderr.puts 'usage: puppetv <puppetfile_path>' | |
exit EX_USAGE | |
end | |
end | |
def client | |
@client ||= Octokit::Client.new(netrc: true).tap do |client| | |
client.login | |
end | |
end | |
end |
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 | |
$: << File.expand_path('../', __FILE__) | |
require 'puppet_versions' | |
begin | |
PuppetFileVersions.new(ARGV.first).run | |
rescue => e | |
$stderr.puts "puppetv: Error: #{e.message}" | |
exit 1 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment