gitpaint 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +8 -0
- data/LICENSE.md +21 -0
- data/LICENSE.txt +21 -0
- data/README.md +58 -0
- data/Rakefile +16 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/config/defaults.yaml +5 -0
- data/gitpaint.gemspec +37 -0
- data/lib/gitpaint.rb +166 -0
- data/lib/gitpaint/config.rb +20 -0
- data/lib/gitpaint/github_client.rb +21 -0
- data/lib/gitpaint/png_renderer.rb +29 -0
- data/lib/gitpaint/version.rb +3 -0
- metadata +230 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 05d61488e3636badf34248947c418d8aad02b9e0fef1a551dfd0be156751bc93
|
4
|
+
data.tar.gz: 487bf22c9d33216195211e84dfb08b5dabb14e7acb87266fbc0e0cde639f7fe4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 565af44670ec73c813e89033ce8476a5e7c7aaecd85056831df1445f688496a1cfa1cfbfb58f3b8d5aa0b06d48bd76e40a445b39cb154bfaa2ce49c5e232f1d7
|
7
|
+
data.tar.gz: fbe389b638e20c75e31249798a62014d677caaeabe241a22aa3c225d4cfe99df01534003a4b217c3ddec41b33bd23a3336c045b4378cc76c0b478c57d95dbebc
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at sam.pikesley@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
|
3
|
+
## Copyright (c) 2018 pikesley
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 pikesley
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the 'Software'), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
[![Build Status](http://img.shields.io/travis/pikesley/gitpaint.svg?style=flat-square)](https://travis-ci.org/pikesley/gitpaint)
|
2
|
+
[![Coverage Status](http://img.shields.io/coveralls/pikesley/gitpaint.svg?style=flat-square)](https://coveralls.io/r/pikesley/gitpaint)
|
3
|
+
[![Gem Version](http://img.shields.io/gem/v/gitpaint.svg?style=flat-square)](https://rubygems.org/gems/gitpaint)
|
4
|
+
[![License](http://img.shields.io/:license-mit-blue.svg?style=flat-square)](http://pikesley.mit-license.org)
|
5
|
+
|
6
|
+
# Gitpaint
|
7
|
+
|
8
|
+
Draw a grid of data onto the Github contributions graph
|
9
|
+
|
10
|
+
# Installation
|
11
|
+
|
12
|
+
git clone https://github.com/pikesley/gitpaint
|
13
|
+
cd gitpaint
|
14
|
+
bundle
|
15
|
+
bundle exec rake
|
16
|
+
bundle exec rake install
|
17
|
+
|
18
|
+
# Configuration
|
19
|
+
|
20
|
+
Gitpaint.configure do |config|
|
21
|
+
config.username = github_user
|
22
|
+
config.email = github_email
|
23
|
+
config.repo = github_repo
|
24
|
+
config.token = github_api_token
|
25
|
+
config.ssh_key = /path/to/ssh_key
|
26
|
+
end
|
27
|
+
|
28
|
+
## About the configuration
|
29
|
+
|
30
|
+
* Github only credits you with a contribution if the commit (apparently) came from the username and email associated with your account, so we need those
|
31
|
+
* We also need a (disposable) repo to work with: this will be created locally at `/tmp/#{repo}` and remotely at `https://github.com/#{github_user}/#{repo}` (and it will be mercilessly deleted from both places between runs)
|
32
|
+
* We need a Github [personal access token](https://github.com/settings/tokens) that has the `repo` privileges and, crucially, the separate `delete repo` privilege
|
33
|
+
* And we need the path to an ssh key that can commit to the `#{github_user}` account
|
34
|
+
|
35
|
+
# Painting
|
36
|
+
|
37
|
+
data = [
|
38
|
+
[3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 0, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3],
|
39
|
+
[3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3],
|
40
|
+
[2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 0, 1, 0, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 3],
|
41
|
+
[2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 2, 2, 2, 1, 2, 2, 1, 1, 1, 2, 3, 3, 3, 2, 2, 3, 2, 2, 2, 2, 2, 2],
|
42
|
+
[2, 2, 2, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 1, 2, 2, 1, 1, 1, 1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
|
43
|
+
[2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 2, 3, 2, 2, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 0, 1, 1, 2, 2, 1, 0, 1, 1, 1, 0, 0, 1, 2, 2, 2, 1, 1, 2, 2, 2, 2, 2, 1, 1],
|
44
|
+
[2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 2, 2, 1, 1, 1, 1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 2, 2, 1, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
|
45
|
+
]
|
46
|
+
Gitpaint.paint data
|
47
|
+
|
48
|
+
## Rendering from a PNG
|
49
|
+
|
50
|
+
There's some slightly clunky code that will take a 52*7 greyscale PNG image and turn it into data suitable for Gitpaint. Use it like
|
51
|
+
|
52
|
+
pngr = Gitpaint::PNGRenderer.new 'image.png'
|
53
|
+
|
54
|
+
or
|
55
|
+
|
56
|
+
bundle exec rake image:decompose[image.png]
|
57
|
+
|
58
|
+
the pass that to `Gitpaint.paint`
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
2
|
+
require 'rspec/core/rake_task'
|
3
|
+
|
4
|
+
require 'gitpaint'
|
5
|
+
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
|
8
|
+
task :default => :spec
|
9
|
+
|
10
|
+
namespace :image do
|
11
|
+
desc 'turn PNG into array of numbers'
|
12
|
+
task :decompose, [:path] do |t, args|
|
13
|
+
@pr = Gitpaint::PNGRenderer.new args[:path]
|
14
|
+
puts @pr.inspect
|
15
|
+
end
|
16
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'gitpaint'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require 'pry'
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/gitpaint.gemspec
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gitpaint/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'gitpaint'
|
8
|
+
spec.version = Gitpaint::VERSION
|
9
|
+
spec.authors = ['pikesley']
|
10
|
+
spec.email = ['sam.pikesley@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = %q{API for the Github Commit Graph}
|
13
|
+
spec.description = %q{Just because I can}
|
14
|
+
spec.homepage = 'http://pikesley.org'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = 'exe'
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'httparty', '~> 0.16'
|
25
|
+
spec.add_dependency 'nokogiri', '~> 1.8'
|
26
|
+
spec.add_dependency 'git', '~> 1.5'
|
27
|
+
spec.add_dependency 'octokit', '~> 4.12'
|
28
|
+
spec.add_dependency 'chunky_png', '~> 1.3'
|
29
|
+
|
30
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
32
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
33
|
+
spec.add_development_dependency 'vcr', '~> 4.0'
|
34
|
+
spec.add_development_dependency 'webmock', '~> 3.4'
|
35
|
+
spec.add_development_dependency 'timecop', '~> 0.9'
|
36
|
+
spec.add_development_dependency 'coveralls', '~> 0.8'
|
37
|
+
end
|
data/lib/gitpaint.rb
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
require 'date'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'singleton'
|
4
|
+
|
5
|
+
require 'httparty'
|
6
|
+
require 'nokogiri'
|
7
|
+
require 'git'
|
8
|
+
require 'octokit'
|
9
|
+
|
10
|
+
require 'gitpaint/version'
|
11
|
+
require 'gitpaint/github_client'
|
12
|
+
require 'gitpaint/png_renderer'
|
13
|
+
require 'gitpaint/config'
|
14
|
+
|
15
|
+
module Gitpaint
|
16
|
+
def self.github_client
|
17
|
+
GithubClient.instance.client
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.configure
|
21
|
+
yield Config.instance.config
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.config
|
25
|
+
Config.instance.config
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.current_grid account
|
29
|
+
response = HTTParty.get 'https://github.com/users/%s/contributions' % account
|
30
|
+
data = Nokogiri::HTML(response.body).xpath '//rect'
|
31
|
+
|
32
|
+
weeks = []
|
33
|
+
while data.count > 0 do
|
34
|
+
weeks.push []
|
35
|
+
7.times do
|
36
|
+
d = data.shift
|
37
|
+
begin
|
38
|
+
value = d['data-count'].to_i
|
39
|
+
rescue NoMethodError
|
40
|
+
value = nil
|
41
|
+
end
|
42
|
+
weeks.last.push value
|
43
|
+
end
|
44
|
+
end
|
45
|
+
weeks.transpose
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.sunday_before_a_year_ago
|
49
|
+
year_ago = (Date.today - 365)
|
50
|
+
if Date.today.strftime('%A') == 'Sunday'
|
51
|
+
return Date.today - 364
|
52
|
+
end
|
53
|
+
year_ago - year_ago.wday
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.data_to_dates data
|
57
|
+
current_date = sunday_before_a_year_ago
|
58
|
+
dates = {}
|
59
|
+
line = pad_grid(data).transpose.flatten
|
60
|
+
|
61
|
+
line.each do |value|
|
62
|
+
dates[current_date.iso8601] = value if value > 0
|
63
|
+
current_date += 1
|
64
|
+
end
|
65
|
+
|
66
|
+
dates
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.pad_row row
|
70
|
+
row + [0] * (52 - row.count)
|
71
|
+
end
|
72
|
+
|
73
|
+
def self.pad_grid grid
|
74
|
+
grid.map! { |row| pad_row row }
|
75
|
+
|
76
|
+
until grid.count >= 7
|
77
|
+
grid.push [0] * 52
|
78
|
+
end
|
79
|
+
grid
|
80
|
+
end
|
81
|
+
|
82
|
+
def self.scale_commits grid
|
83
|
+
grid.map { |row| row.map { |v| v * config.scale_factor } }
|
84
|
+
end
|
85
|
+
|
86
|
+
def self.make_commit date, message: 'The commit is a lie'
|
87
|
+
pieces = []
|
88
|
+
|
89
|
+
pieces.push "GIT_AUTHOR_NAME=%s" % config.username
|
90
|
+
pieces.push "GIT_AUTHOR_EMAIL=%s" % config.email
|
91
|
+
pieces.push "GIT_AUTHOR_DATE=%sT12:00:00" % date
|
92
|
+
pieces.push "GIT_COMMITTER_NAME=%s" % config.username
|
93
|
+
pieces.push "GIT_COMMITTER_EMAIL=%s" % config.email
|
94
|
+
pieces.push "GIT_COMMITTER_DATE=%sT12:00:00" % date
|
95
|
+
|
96
|
+
"%s git commit --allow-empty -m '%s' > /dev/null" % [
|
97
|
+
pieces.join(' '),
|
98
|
+
message
|
99
|
+
]
|
100
|
+
end
|
101
|
+
|
102
|
+
def self.paint data, message: config.commit_message
|
103
|
+
start_dir = Dir.pwd
|
104
|
+
clean_local
|
105
|
+
nuke
|
106
|
+
|
107
|
+
unless data.flatten.uniq.delete_if { |i| i == 0 } == []
|
108
|
+
remote = create
|
109
|
+
custom_ssh_script
|
110
|
+
Git.configure do |config|
|
111
|
+
config.git_ssh = '/tmp/custom.sh'
|
112
|
+
end
|
113
|
+
|
114
|
+
g = Git.init "/tmp/#{config.repo}"
|
115
|
+
g.add_remote 'origin', remote
|
116
|
+
|
117
|
+
make_commits data, message: message
|
118
|
+
|
119
|
+
push
|
120
|
+
end
|
121
|
+
FileUtils.chdir start_dir
|
122
|
+
end
|
123
|
+
|
124
|
+
def self.make_commits data, message:
|
125
|
+
FileUtils.chdir "/tmp/#{config.repo}"
|
126
|
+
data = scale_commits data
|
127
|
+
dates = data_to_dates data
|
128
|
+
dates.each_pair do |date, count|
|
129
|
+
count.times do
|
130
|
+
s = Gitpaint.make_commit date, message: message
|
131
|
+
`#{s}`
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def self.clean_local
|
137
|
+
FileUtils.rm_rf "/tmp/#{config.repo}"
|
138
|
+
end
|
139
|
+
|
140
|
+
def self.nuke
|
141
|
+
begin
|
142
|
+
victim = github_client.repos.select { |r| r.name == config.repo }.first.id
|
143
|
+
github_client.delete_repository victim
|
144
|
+
rescue NoMethodError => e
|
145
|
+
# do something here
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
def self.custom_ssh_script dir = '/tmp'
|
150
|
+
File.open "#{dir}/custom.sh", 'w' do |f|
|
151
|
+
f.write "#!/bin/sh\n"
|
152
|
+
f.write 'ssh -i "%s" "$@"' % config.ssh_key
|
153
|
+
end
|
154
|
+
FileUtils.chmod '+x', "#{dir}/custom.sh"
|
155
|
+
end
|
156
|
+
|
157
|
+
def self.create
|
158
|
+
r = github_client.create_repository config.repo
|
159
|
+
r.ssh_url
|
160
|
+
end
|
161
|
+
|
162
|
+
def self.push
|
163
|
+
g = Git.open "/tmp/#{config.repo}"
|
164
|
+
g.push 'origin', 'master'
|
165
|
+
end
|
166
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gitpaint
|
2
|
+
class Config
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
defaults = YAML.load_file (File.join(File.dirname(__FILE__), '..', '..', 'config/defaults.yaml'))
|
7
|
+
|
8
|
+
begin
|
9
|
+
defaults.merge!(YAML.load_file "#{ENV['HOME']}/.gitpaint/config.yaml")
|
10
|
+
rescue Errno::ENOENT
|
11
|
+
end
|
12
|
+
|
13
|
+
@config = OpenStruct.new defaults
|
14
|
+
end
|
15
|
+
|
16
|
+
def config
|
17
|
+
@config
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Gitpaint
|
2
|
+
class GithubClient
|
3
|
+
include Singleton
|
4
|
+
|
5
|
+
def initialize
|
6
|
+
@client = Octokit::Client.new access_token: Config.instance.config.token
|
7
|
+
end
|
8
|
+
|
9
|
+
def client
|
10
|
+
@client
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.custom_ssh_script dir
|
14
|
+
File.open "#{dir}/custom.sh", 'w' do |f|
|
15
|
+
f.write "#!/bin/sh\n"
|
16
|
+
f.write 'ssh -i "%s" "$@"' % config.ssh_key
|
17
|
+
end
|
18
|
+
FileUtils.chmod '+x', "#{dir}/custom.sh"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'chunky_png'
|
2
|
+
|
3
|
+
module Gitpaint
|
4
|
+
class PNGRenderer < Array
|
5
|
+
def initialize png_path
|
6
|
+
png = ChunkyPNG::Image.from_file png_path
|
7
|
+
|
8
|
+
png.height.times do |i|
|
9
|
+
self.push(
|
10
|
+
png.row(i).to_a.map do |p|
|
11
|
+
self.class.scale self.class.invert self.class.magnitude p
|
12
|
+
end
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.magnitude value
|
18
|
+
value / 256 ** 3
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.invert value
|
22
|
+
256 - value
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.scale value
|
26
|
+
value / (256 / 5)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,230 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gitpaint
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pikesley
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-10-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.16'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: nokogiri
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: git
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.5'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.12'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.12'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: chunky_png
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '1.3'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '1.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.16'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.16'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: vcr
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '4.0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '4.0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: webmock
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '3.4'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '3.4'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: timecop
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0.9'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0.9'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: coveralls
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.8'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.8'
|
181
|
+
description: Just because I can
|
182
|
+
email:
|
183
|
+
- sam.pikesley@gmail.com
|
184
|
+
executables: []
|
185
|
+
extensions: []
|
186
|
+
extra_rdoc_files: []
|
187
|
+
files:
|
188
|
+
- ".gitignore"
|
189
|
+
- ".rspec"
|
190
|
+
- ".travis.yml"
|
191
|
+
- CODE_OF_CONDUCT.md
|
192
|
+
- Gemfile
|
193
|
+
- LICENSE.md
|
194
|
+
- LICENSE.txt
|
195
|
+
- README.md
|
196
|
+
- Rakefile
|
197
|
+
- bin/console
|
198
|
+
- bin/setup
|
199
|
+
- config/defaults.yaml
|
200
|
+
- gitpaint.gemspec
|
201
|
+
- lib/gitpaint.rb
|
202
|
+
- lib/gitpaint/config.rb
|
203
|
+
- lib/gitpaint/github_client.rb
|
204
|
+
- lib/gitpaint/png_renderer.rb
|
205
|
+
- lib/gitpaint/version.rb
|
206
|
+
homepage: http://pikesley.org
|
207
|
+
licenses:
|
208
|
+
- MIT
|
209
|
+
metadata: {}
|
210
|
+
post_install_message:
|
211
|
+
rdoc_options: []
|
212
|
+
require_paths:
|
213
|
+
- lib
|
214
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
215
|
+
requirements:
|
216
|
+
- - ">="
|
217
|
+
- !ruby/object:Gem::Version
|
218
|
+
version: '0'
|
219
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
220
|
+
requirements:
|
221
|
+
- - ">="
|
222
|
+
- !ruby/object:Gem::Version
|
223
|
+
version: '0'
|
224
|
+
requirements: []
|
225
|
+
rubyforge_project:
|
226
|
+
rubygems_version: 2.7.3
|
227
|
+
signing_key:
|
228
|
+
specification_version: 4
|
229
|
+
summary: API for the Github Commit Graph
|
230
|
+
test_files: []
|