prawntocat 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: aa44be11277220421d08559a7939a7d2eddde1a9
4
+ data.tar.gz: 27eb2c9f9f15e9f893b44e61109cb55968a58950
5
+ SHA512:
6
+ metadata.gz: 5b9ca31076afb20bffeb741f343b684daa3f958ece7b53bba4e94e4e978b4b6daefe9433acc62ebac30bcee19746d9b2465fdb1be289bf3c7b71e48008d3a4d9
7
+ data.tar.gz: 4cf1df5171e47298969fcbfcf014cbe571d51e5d9bdf43b97010571128f72ce384071ae33985723246fda7f30290674f9a95dad42bfea0b4c861b2c771314282
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 prawntocat.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Steven! Ragnarök
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,25 @@
1
+ # Prawntocat
2
+
3
+ Have you ever wanted a print-ready pdf of your issues? Neither have I, but
4
+ somebody might.
5
+
6
+ ## Installation
7
+
8
+ $ gem install prawntocat
9
+
10
+ ## Usage
11
+
12
+ Before using this gem, please think of the trees.
13
+
14
+ ![trees](/trees.jpg)
15
+
16
+ When you first run prawntocat, you'll need to create an OAuth Token for it's
17
+ use. Be WARNED, this token will be stored naively!
18
+
19
+ ## Contributing
20
+
21
+ 1. Fork it
22
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
23
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
24
+ 4. Push to the branch (`git push origin my-new-feature`)
25
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/prawntocat ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "prawntocat"
4
+
5
+ Prawntocat.authenticate! unless Prawntocat.authenticated?
6
+
7
+ def usage
8
+ puts <<-USAGE
9
+ Usage: prawntocat ACCOUNTNAME/REPONAME [PDF_NAME]
10
+ prawntocat nuclearsandwich/prawntocat issues.pdf
11
+ USAGE
12
+ exit 1
13
+ end
14
+
15
+ repo = ARGV.shift
16
+ pdf = ARGV.shift
17
+
18
+ usage unless repo
19
+ Prawntocat::PDF.new(repo, pdf).generate
20
+
data/lib/prawntocat.rb ADDED
@@ -0,0 +1,39 @@
1
+ require "io/console"
2
+ require "octokit"
3
+ require "pstore"
4
+ require "prawntocat/issues"
5
+ require "prawntocat/pdf"
6
+ require "prawntocat/version"
7
+
8
+ module Prawntocat
9
+ def self.authenticated?
10
+ auth.has_key?('username') and auth.has_key?('token')
11
+ end
12
+
13
+ def self.authenticate!
14
+ $stdout.print("GitHub username: ")
15
+ username = $stdin.gets.chomp
16
+ $stdout.print("GitHub password: ")
17
+ password = $stdin.noecho(&:gets).chomp
18
+ authorization = Octokit::Client.new(login: username, password: password).create_authorization(scopes: ["repo"], note: "Prawntocat Issue Printer", note_url: "http://nuclearsandwich.com/prawntocat")
19
+ auth_store.transaction do
20
+ auth_store['authorization'] ||= Hash.new
21
+ auth_store['authorization']['username'] = username
22
+ auth_store['authorization']['token'] = authorization.token
23
+ end
24
+
25
+ end
26
+
27
+ def self.auth_store
28
+ @auth_store ||= PStore.new(File.join(ENV['HOME'], ".prawntocat.pstore"))
29
+ end
30
+
31
+ def self.auth
32
+ @auth ||= auth_store.transaction{ auth_store['authorization'] ||= Hash.new }
33
+ end
34
+
35
+ def self.client
36
+ Octokit::Client.new login: auth['username'], oauth_token: auth['token']
37
+ end
38
+ end
39
+
@@ -0,0 +1,25 @@
1
+ require "ostruct"
2
+ require "prawntocat"
3
+
4
+ module Prawntocat
5
+ class Issues
6
+
7
+ def initialize repo
8
+ @repo = repo
9
+ end
10
+
11
+ def client
12
+ @client ||= Prawntocat.client
13
+ end
14
+
15
+ def each
16
+ page = 1
17
+ loop do
18
+ issues = client.list_issues(@repo, page: page)
19
+ break if issues.empty?
20
+ page += 1
21
+ issues.each { |hash| yield hash }
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ require "prawn"
2
+ require "prawntocat/issues"
3
+
4
+ module Prawntocat
5
+ class PDF
6
+ def initialize repo, pdf_name
7
+ @repo = repo
8
+ @pdf_name = pdf_name || repo.gsub("/", "_").+(".pdf")
9
+ end
10
+
11
+ def issues
12
+ @issues ||= Prawntocat::Issues.new(@repo)
13
+ end
14
+
15
+ def generate
16
+ Prawn::Document.generate(@pdf_name) do |doc|
17
+ doc.text("Issues for #{@repo}", size: 20)
18
+ doc.move_down 20
19
+ issues.each do |issue|
20
+ doc.text("#{issue.title}\n", :style => :bold)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module Prawntocat
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'prawntocat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "prawntocat"
8
+ spec.version = Prawntocat::VERSION
9
+ spec.authors = ["Steven! Ragnarök"]
10
+ spec.email = ["steven@nuclearsandwich.com"]
11
+ spec.description = %q{Print out your GitHub Issues!}
12
+ spec.summary = %q{Print out your GitHub Issues!}
13
+ spec.homepage = "http://nuclearsandwich.com/prawntocat"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "octokit"
22
+ spec.add_dependency "prawn"
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ end
data/trees.jpg ADDED
Binary file
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: prawntocat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steven! Ragnarök
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: prawn
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Print out your GitHub Issues!
70
+ email:
71
+ - steven@nuclearsandwich.com
72
+ executables:
73
+ - prawntocat
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - .gitignore
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/prawntocat
83
+ - lib/prawntocat.rb
84
+ - lib/prawntocat/issues.rb
85
+ - lib/prawntocat/pdf.rb
86
+ - lib/prawntocat/version.rb
87
+ - prawntocat.gemspec
88
+ - trees.jpg
89
+ homepage: http://nuclearsandwich.com/prawntocat
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Print out your GitHub Issues!
113
+ test_files: []
114
+ has_rdoc: