contribcalendar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9a935ec73d662a6352418927d0eff8a9580f05ae
4
+ data.tar.gz: f1434c859a2e306f1e8f6d288377f1454a89ada5
5
+ SHA512:
6
+ metadata.gz: b47a99fb6a61dbf06db2b4fb93d856b58786d77490757ef3f68af57e73cdc25f9a558de33858bd95b2eb047e7515f77f0bed8632efc3d6b8ca1bbb85be22d0f0
7
+ data.tar.gz: dad5c24e2883eb19469ccfd9be5ec31c8eaefbd7682c924821757bcd04c397c39ba39ab8f0d06e22c7526c7eb55e4c716787bb34c1417e56b389994c99182e19
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.swp
11
+ *.gem
12
+ tags
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in contribcalendar.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ [![Code Climate](https://codeclimate.com/github/pbaisla/contrib-calendar/badges/gpa.svg)](https://codeclimate.com/github/pbaisla/contrib-calendar)
2
+ [![Dependency Status](https://gemnasium.com/pbaisla/contrib-calendar.svg)](https://gemnasium.com/pbaisla/contrib-calendar)
3
+
4
+ # contrib-calendar
5
+
6
+ Set your GitHub contribution calendar as your wallpaper.
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'contribcalendar'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install contribcalendar
23
+
24
+ ## Usage
25
+
26
+ ```
27
+ contribcalendar [options]
28
+ -u, --user GitHub username
29
+ -d, --destination destination directory
30
+ --version print the version
31
+ ```
32
+
33
+ ## Development
34
+
35
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
36
+
37
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
38
+
39
+ ## Contributing
40
+
41
+ Bug reports and pull requests are welcome on GitHub at https://github.com/pbaisla/contrib-calendar. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "contribcalendar"
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
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'contribcalendar/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "contribcalendar"
8
+ spec.version = Contribcalendar::VERSION
9
+ spec.authors = ["Prashant Baisla"]
10
+ spec.email = ["prashantbaisla@gmail.com"]
11
+
12
+ spec.summary = %q{Generate an image containing your GitHub contribution calendar.}
13
+ spec.homepage = "https://github.com/pbaisla/contrib-calendar"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "minitest"
23
+
24
+ spec.add_runtime_dependency "nokogiri"
25
+ spec.add_runtime_dependency "rmagick"
26
+ spec.add_runtime_dependency "slop"
27
+ end
@@ -0,0 +1,24 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'contribcalendar'
4
+ require 'slop'
5
+
6
+ opts = Slop.parse do |o|
7
+ o.string '-u', '--user', 'GitHub username'
8
+ o.string '-d', '--destination', 'destination directory', default: '.'
9
+ o.on '--version', 'print the version' do
10
+ puts Contribcalendar::VERSION
11
+ exit
12
+ end
13
+ end
14
+
15
+ user = opts[:user]
16
+ destination = opts[:destination]
17
+
18
+ unless user.nil?
19
+ Contribcalendar.make_wallpaper(user, destination)
20
+ exit
21
+ end
22
+
23
+ # Print usage
24
+ puts opts
@@ -0,0 +1,50 @@
1
+ require "contribcalendar/calendar"
2
+ require "contribcalendar/version"
3
+ require "rmagick"
4
+
5
+ module Contribcalendar
6
+ include Magick
7
+
8
+ module_function
9
+
10
+ def make_wallpaper(username, destination)
11
+ calendar = Calendar.new(username)
12
+
13
+ wallpaper = Image.new(1600, 900)
14
+
15
+ ttext = "Don't break the chain!"
16
+ text = Draw.new
17
+ text.font_family = 'helvetica'
18
+ text.pointsize = 50
19
+ text.gravity = NorthGravity
20
+ text.annotate(wallpaper, 0,0,0,100, ttext)
21
+
22
+ no_of_rows = 7
23
+ no_of_columns = 53
24
+
25
+ square_start_x = 270
26
+ square_start_y = 450
27
+ square_end_x = 286
28
+ square_end_y = 466
29
+
30
+ contributions = calendar.contributions
31
+
32
+ square = Draw.new
33
+
34
+ no_of_columns.times do |x|
35
+ no_of_rows.times do |y|
36
+ contribution = contributions.shift
37
+ unless contribution.nil?
38
+ square.stroke(contribution.color)
39
+ square.fill(contribution.color)
40
+ square.rectangle(square_start_x + x*20, square_start_y + y*20, square_end_x + x*20, square_end_y + y*20)
41
+ square.draw(wallpaper)
42
+ end
43
+ end
44
+ end
45
+
46
+ wallpaper.write(File.join(destination, 'wallpaper.jpg'))
47
+
48
+ end
49
+
50
+ end
@@ -0,0 +1,20 @@
1
+ require 'contribcalendar/day'
2
+
3
+ require 'nokogiri'
4
+ require 'open-uri'
5
+
6
+ class Calendar
7
+ attr_reader :contributions
8
+
9
+ def initialize(username)
10
+ @contributions = []
11
+
12
+ profile_page = Nokogiri::HTML(open("https://github.com/" + username))
13
+ squares = profile_page.css("rect.day")
14
+
15
+ squares.each do |square|
16
+ @contributions << Day.new(square['data-date'], square['data-count'], square['fill'])
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,12 @@
1
+ require 'date'
2
+
3
+ class Day
4
+ attr_reader :date, :count, :color
5
+
6
+ def initialize(date, count, color)
7
+ @date = Date.parse(date)
8
+ @count = count
9
+ @color = color
10
+ end
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ module Contribcalendar
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: contribcalendar
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Prashant Baisla
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-01-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: nokogiri
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rmagick
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: slop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description:
98
+ email:
99
+ - prashantbaisla@gmail.com
100
+ executables:
101
+ - contribcalendar
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - Gemfile.lock
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - contribcalendar.gemspec
115
+ - exe/contribcalendar
116
+ - lib/contribcalendar.rb
117
+ - lib/contribcalendar/calendar.rb
118
+ - lib/contribcalendar/day.rb
119
+ - lib/contribcalendar/version.rb
120
+ homepage: https://github.com/pbaisla/contrib-calendar
121
+ licenses: []
122
+ metadata: {}
123
+ post_install_message:
124
+ rdoc_options: []
125
+ require_paths:
126
+ - lib
127
+ required_ruby_version: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ required_rubygems_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ requirements: []
138
+ rubyforge_project:
139
+ rubygems_version: 2.5.1
140
+ signing_key:
141
+ specification_version: 4
142
+ summary: Generate an image containing your GitHub contribution calendar.
143
+ test_files: []