pk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in pk.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Huiming Teo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ ### pk - command line tool to print public keys
2
+
3
+ ```
4
+ pk keys fm hm,su,sy
5
+
6
+ pk team add fm https://gist.github.com/abc
7
+ pk team reload
8
+ pk team reload fm
9
+ pk team list
10
+ pk team list fm
11
+ ```
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/pk ADDED
@@ -0,0 +1,75 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+
5
+ module Helper
6
+
7
+ def init
8
+ `mkdir -p ~/.pk/data/`
9
+ end
10
+
11
+ def all_members_of(team)
12
+ [].tap do |list|
13
+ `ls ~/.pk/data/#{team}`.split.each do |filename|
14
+ list << filename unless ignore_file?(filename)
15
+ end
16
+ end
17
+ end
18
+
19
+ def ignore_file?(filename)
20
+ filename.include?('.') ? true : false
21
+ end
22
+ end
23
+
24
+ class Team < Thor
25
+ include Helper
26
+
27
+ desc "add NAME, GIT_URL", "add team repo via git clone"
28
+ def add(name, git_url)
29
+ init
30
+ `git clone #{git_url} ~/.pk/data/#{name}`
31
+ end
32
+
33
+ desc "reload [TEAM]", "reload a team repo, or all teams if not specified"
34
+ def reload(team=nil)
35
+ init
36
+ teams = Dir["#{ENV["HOME"]}/.pk/data/*/"].map{|f| File.basename(f) }
37
+ teams = teams.select{|t| t == team} if team
38
+ teams.each do |t|
39
+ `cd ~/.pk/data/#{t} && git pull && cd -`
40
+ end
41
+ end
42
+
43
+ desc "list [TEAM]", "list all team, or team members if team is specified"
44
+ def list(team=nil)
45
+ init
46
+ if team
47
+ all_members_of(team).each do |m|
48
+ puts m
49
+ end
50
+ else
51
+ `ls ~/.pk/data`.split.each do |t|
52
+ puts t
53
+ end
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ class Pk < Thor
60
+ include Helper
61
+
62
+ desc "keys TEAM [MEMBER1,MEMBER2,..]", "print public keys of members in a specific team"
63
+ def keys(team, members=nil)
64
+ init
65
+ member_list = members ? members.split(',').compact : all_members_of(team)
66
+ member_list.each do |member|
67
+ puts `cat ~/.pk/data/#{team}/#{member}`
68
+ end
69
+ end
70
+
71
+ desc "team", "manage teams"
72
+ subcommand "team", Team
73
+ end
74
+
75
+ Pk.start
data/lib/pk.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "pk/version"
2
+
3
+ module Pk
4
+ # Your code goes here...
5
+ end
data/lib/pk/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Pk
2
+ VERSION = "0.0.1"
3
+ end
data/pk.gemspec ADDED
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'pk/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "pk"
8
+ gem.version = Pk::VERSION
9
+ gem.authors = ["Huiming Teo"]
10
+ gem.email = ["teohuiming@gmail.com"]
11
+ gem.description = %q{Command line tool to collect and print public keys.}
12
+ gem.summary = %q{CLI tool to collect and print public keys.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Huiming Teo
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-01-11 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Command line tool to collect and print public keys.
15
+ email:
16
+ - teohuiming@gmail.com
17
+ executables:
18
+ - pk
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - Gemfile
24
+ - LICENSE.txt
25
+ - README.md
26
+ - Rakefile
27
+ - bin/pk
28
+ - lib/pk.rb
29
+ - lib/pk/version.rb
30
+ - pk.gemspec
31
+ homepage: ''
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project:
51
+ rubygems_version: 1.8.23
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: CLI tool to collect and print public keys.
55
+ test_files: []