diff --git a/.github/exporter.sh b/.github/exporter.sh deleted file mode 100755 index 8e3a80a..0000000 --- a/.github/exporter.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -set -euo pipefail - -URL="https://exporter.akerl.org/metric" -AUTH="Authorization: Bearer $EXPORTER_TOKEN" -if [[ "$JOB_STATUS" == "success" ]] ; then - VALUE=1 -else - VALUE=0 -fi -BODY="{\"name\":\"gh/${GITHUB_REPOSITORY}\",\"metrics\":[{\"name\":\"ghactions\",\"type\":\"gauge\",\"tags\":{\"repo\":\"${GITHUB_REPOSITORY}\"},\"value\":\"${VALUE}\"}]}" - -echo "$BODY" - -curl -i -XPOST -d "$BODY" -H"$AUTH" "$URL" diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml deleted file mode 100644 index 82ff923..0000000 --- a/.github/workflows/build.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -name: Build -'on': - push: - branches: - - main - tags: - - "**" - pull_request_target: -jobs: - build: - name: Build - runs-on: ubuntu-22.04 - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - uses: ruby/setup-ruby@v1 - with: - ruby-version: '3.1' - bundler-cache: true - - name: Build - run: bundle exec rake - - name: Release - if: github.ref_type == 'tag' - run: bundle exec rake release - env: - GEM_HOST_API_KEY: "${{ secrets.GEM_HOST_API_KEY }}" - - name: Post to hook-exporter - run: "./.github/exporter.sh" - env: - EXPORTER_TOKEN: "${{ secrets.EXPORTER_TOKEN }}" - JOB_STATUS: "${{ job.status }}" - if: always() && github.ref == 'refs/heads/main' diff --git a/.gitignore b/.gitignore index 68ca1c3..093004f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -pkg/*.gem -coverage/ -.coveralls.yml -.bundle Gemfile.lock +pkg/ +coverage/ diff --git a/.nojekyll b/.nojekyll new file mode 100644 index 0000000..e69de29 diff --git a/.rspec b/.rspec deleted file mode 100644 index b7afd2d..0000000 --- a/.rspec +++ /dev/null @@ -1,2 +0,0 @@ ---format Fuubar ---color diff --git a/.rubocop.yml b/.rubocop.yml deleted file mode 100644 index 4814744..0000000 --- a/.rubocop.yml +++ /dev/null @@ -1,2 +0,0 @@ -inherit_gem: - goodcop: .rubocop.yml diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 1fd9ee2..0000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,57 +0,0 @@ -# 4.0.0 / 2023-07-18 - -* [BUGFIX] Update GithubStats dep to use new Github.com format for table - -# 3.4.0 / 2023-01-08 - -* [ENHANCEMENT] Update GithubStats dep - -# 3.3.1 / 2021-02-06 - -* [BUGFIX] Actually bump githubstats dep - -# 3.3.0 / 2021-02-06 - -* [ENHANCEMENT] Update GithubStats dep - -# 3.2.0 / 2020-10-06 - -* [ENHANCEMENT] Update GithubStats dep - -# 3.1.1 / 2020-08-13 - -* [ENHANCEMENT] Update GithubStats dep - -# 3.1.0 / 2017-10-03 - -* [ENHANCEMENT] GitHub updated their styling; this updated matches that change - -# 3.0.0 / 2017-09-29 - -* [ENHANCEMENT] Upgrade to latest githubstats with better error messages - -# 2.1.0 / 2017-08-25 - -* [ENHANCEMENT] Upgrade to latest githubstats - -# 2.0.1 / 2016-11-08 - -* [BUGFIX] Actually update changelog in release - -# 2.0.0 / 2016-11-07 - -* [FEATURE] Add support for svg_square as a rendering type, thanks @blerchin - -# 1.1.0 / 2016-05-19 - -* [BUGFIX] Upgrade to newer GithubStats that fixes streak parsing - -# 1.0.1 / 2015-10-20 - -* [BUGFIX] Fix month labels for parity with GitHub -* [ENHANCEMENT] Link to @2016rshah's awesome service for hosted SVGs - -# 1.0.0 / 2015-01-25 - -* [ENHANCEMENT] Stabilized API - diff --git a/Gemfile b/Gemfile deleted file mode 100644 index fa75df1..0000000 --- a/Gemfile +++ /dev/null @@ -1,3 +0,0 @@ -source 'https://rubygems.org' - -gemspec diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 1336547..0000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2023 Les Aker - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/README.md b/README.md deleted file mode 100644 index 414b5d4..0000000 --- a/README.md +++ /dev/null @@ -1,35 +0,0 @@ -GithubChart -============ - -[![Gem Version](https://img.shields.io/gem/v/githubchart.svg)](https://rubygems.org/gems/githubchart) -[![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/akerl/githubchart/build.yml?branch=main)](https://github.com/akerl/githubchart/actions) -[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license) - -Generates an SVG of your Github contributions: - -![Example image](http://akerl.github.io/githubchart/chart.svg) - -![Other user example](http://akerl.github.io/githubchart/other_user.svg) - -## Usage - -Run `githubchart path/to/svg` to generate an SVG. To override the default username (pulled from your local shell or .gitconfig), use `githubchart -u username path/to/svg` - -GithubChart also allows you to provide input from a file instead of pulling data from Github. You can pass JSON to GithubChart by using `githubchart -i /path/to/file /path/to/svg`, or use '-' to use STDIN. See spec/examples/input.json for example data. - -If you don't provide a file path, the resulting SVG will be printed to stdout. - -To modify the color scheme used, you can provide `-c SCHEME`. For example, `githubchart -c halloween` uses GitHub's halloween colors. Use `-s` to list the available schemes. - -### Hosted SVG - -A hosted service for loading these SVGs was made by [2016rshah](https://github.com/2016rshah): http://ghchart.rshah.org/ ([source code](https://github.com/2016rshah/githubchart-api)) - -## Installation - - gem install githubchart - -## License - -githubchart is released under the MIT License. See the bundled LICENSE file for details. - diff --git a/Rakefile b/Rakefile deleted file mode 100644 index 70f40c0..0000000 --- a/Rakefile +++ /dev/null @@ -1,14 +0,0 @@ -require 'bundler/gem_tasks' -require 'rspec/core/rake_task' -require 'rubocop/rake_task' - -desc 'Run tests' -RSpec::Core::RakeTask.new(:spec) - -desc 'Run Rubocop on the gem' -RuboCop::RakeTask.new(:rubocop) do |task| - task.patterns = ['lib/**/*.rb', 'spec/**/*.rb', 'bin/**/*'] - task.fail_on_error = true -end - -task default: %i[spec rubocop build install] diff --git a/bin/githubchart b/bin/githubchart deleted file mode 100755 index def9582..0000000 --- a/bin/githubchart +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby - -require 'githubchart' -require 'optparse' - -# rubocop:disable Metrics/BlockLength -options = {} -render_type = 'svg'.freeze - -OptionParser.new do |opts| - opts.banner = - "Usage: githubchart (-u username) (-t type) path/for/new/image\n" - opts.banner << "Supported types: #{GithubChart.supported.join(' ')}" - opts.on('-uUSER', '--user=USER', 'Specify GitHub user to graph') do |user| - raise('The --user and --input flags are incompatible with each other.') if options.include? :input - options[:user] = user - end - opts.on('-iFILE', '--input=FILE', 'Specify JSON file, - for stdin') do |input| - raise('The --user and --input flags are incompatible with each other.') if options.include? :user - if input.eql? '-' - raise 'No data provided on stdin' if $stdin.tty? - contents = $stdin.read - else - raise 'File does not exist' unless File.exist? input - contents = File.read input - end - begin - parsed = JSON.parse(contents) - rescue StandardError => e - raise "Unable to parse JSON data provided: #{e}" - end - options[:data] = GithubStats::Data.new(parsed) - end - opts.on('-cSCHEME', '--colors SCHEME', 'Pick a color scheme') do |scheme| - is_good_scheme = GithubChart::COLOR_SCHEMES.include? scheme.to_sym - raise('Unknown color scheme provided') unless is_good_scheme - options[:colors] = scheme.to_sym - end - opts.on('-s', '--schemes', 'List known color schemes') do - puts 'Color schemes:' - GithubChart::COLOR_SCHEMES.each do |scheme, colors| - puts " #{scheme}: #{colors}" - end - exit - end - opts.on('-t TYPE', '--type TYPE', 'What type to render') do |type| - raise('Unsupported render type') unless GithubChart.supported.include?( - type.to_sym - ) - render_type = type - end - opts.on_tail('-v', '--version', 'Show version') do - puts GithubChart::VERSION - exit - end -end.parse! -# rubocop:enable Metrics/BlockLength - -SVG_Path = ARGV.shift - -Chart = GithubChart.new(options).render(render_type) - -if SVG_Path.nil? - puts Chart -else - File.open(SVG_Path, 'w') { |file| file << Chart } -end diff --git a/chart.svg b/chart.svg new file mode 100644 index 0000000..9c5f71d --- /dev/null +++ b/chart.svg @@ -0,0 +1,6 @@ + + + +MTWTFSSOctNovDecJanFebMarAprMayJunJulAug \ No newline at end of file diff --git a/examples/chart.svg b/examples/chart.svg deleted file mode 100644 index 55d5995..0000000 --- a/examples/chart.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - -SSMTWTFNovDecJanFebMarAprMayJunJulAugSepOct \ No newline at end of file diff --git a/examples/other_user.svg b/examples/other_user.svg deleted file mode 100644 index 41da69c..0000000 --- a/examples/other_user.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - -SSMTWTFNovDecJanFebMarAprMayJunJulAugSepOct \ No newline at end of file diff --git a/githubchart.gemspec b/githubchart.gemspec deleted file mode 100644 index 92d39fe..0000000 --- a/githubchart.gemspec +++ /dev/null @@ -1,24 +0,0 @@ -require 'English' -$LOAD_PATH.unshift File.expand_path('lib', __dir__) -require 'githubchart/version' - -Gem::Specification.new do |s| - s.name = 'githubchart' - s.version = GithubChart::VERSION - s.summary = 'Generate an SVG of Github contributions data' - s.description = 'Uses GithubStats to grab Github contributions scores and converts that into an SVG' - s.authors = ['Les Aker'] - s.email = 'me@lesaker.org' - s.homepage = 'https://github.com/akerl/githubchart' - s.license = 'MIT' - - s.files = `git ls-files`.split - s.executables = ['githubchart'] - - s.add_runtime_dependency 'githubstats', '~> 4.0.1' - s.add_runtime_dependency 'matrix', '~> 0.4.2' - s.add_runtime_dependency 'svgplot', '~> 1.0.0' - - s.add_development_dependency 'goodcop', '~> 0.9.7' - s.metadata['rubygems_mfa_required'] = 'true' -end diff --git a/lib/githubchart.rb b/lib/githubchart.rb deleted file mode 100644 index 2ca3e0e..0000000 --- a/lib/githubchart.rb +++ /dev/null @@ -1,113 +0,0 @@ -require 'githubstats' -require 'matrix' - -## -# Graphing tool for creating Github-style contribution charts -module GithubChart - class << self - ## - # Helper to create new charts - - def new(*args) - self::Chart.new(*args) - end - - ## - # Helper to list supported types - - def supported - @supported ||= [] - end - - ## - # Helper to check for type support - - def supports?(type) - supported.include? type.to_sym - end - - protected - - ## - # Add support for a type - - def add_support(type) - @supported ||= [] - @supported << type.to_sym - end - end - - ## - # Color schemes for gradient - COLOR_SCHEMES = { - default: ['#eeeeee', '#c6e48b', '#7bc96f', '#239a3b', '#196127'], - old: ['#eeeeee', '#d6e685', '#8cc665', '#44a340', '#1e6823'], - halloween: ['#EEEEEE', '#FFEE4A', '#FFC501', '#FE9600', '#03001C'] - }.freeze - - ## - # Object for parsing and outputing Github stats data - class Chart - attr_reader :stats - attr_accessor :colors - - ## - # Create a new chart object - # Passes the username through to GithubStats - # Uses colors rather than default, if provided - - def initialize(params = {}) - params = { user: params } unless params.is_a? Hash - @stats = load_stats(params[:data], params[:user]) - @colors = params[:colors] || :default - @colors = COLOR_SCHEMES[@colors] unless @colors.is_a? Array - end - - def render(type) - raise(NameError, "Format #{type} is unsupported.") unless GithubChart.supports? type - send(:"render_#{type}") - end - - private - - ## - # Load stats from provided arg or github - - def load_stats(data, user) - return data if data - raise('No data or user provided') unless user - stats = GithubStats.new(user).data - raise("Failed to find data for #{user} on GitHub") unless stats - stats - end - - ## - # Convert the data into a matrix of weeks - # The fill value is used to pad the front and back - - def matrix(fill_value = -1) - Matrix[*@stats.pad(fill_value).each_slice(7).to_a.transpose] - end - end -end - -## -# Add helper methods to Integer -class Integer - ## - # Add ordinalize to simplify converting to spoken string - - def ordinalize - return to_s if zero? - return "#{self}th" if (11..13).cover?(abs % 100) - case abs % 10 - when 1 then "#{self}st" - when 2 then "#{self}nd" - when 3 then "#{self}rd" - else "#{self}th" - end - end -end - -require 'githubchart/version' -require 'githubchart/svg' diff --git a/lib/githubchart/svg.rb b/lib/githubchart/svg.rb deleted file mode 100644 index b3618da..0000000 --- a/lib/githubchart/svg.rb +++ /dev/null @@ -1,112 +0,0 @@ -require 'svgplot' - -## -# Add SVG support to GithubChart -module GithubChart - ## - # Declare SVG support - - add_support(:svg) - add_support(:svg_square) - - ## - # Convert stats into SVG - class Chart - CUBE_SIZE = 12 - X_PAD = 27 - Y_PAD = 20 - - ## - # Define shared label style - - SVG_SHARED_STYLE = { - fill: '#767676', - 'text-anchor': 'start', - 'text-align': 'center', - 'font-family': '-apple-system, BlinkMacSystemFont, \'Segoe UI\', Helvetica, Arial, sans-serif, \'Apple Color Emoji\', \'Segoe UI Emoji\', \'Segoe UI Symbol\'', # rubocop:disable Layout/LineLength - 'white-space': 'nowrap' - }.freeze - - ## - # Define style for weekday labels - - SVG_WEEKDAY_STYLE = SVG_SHARED_STYLE.dup.merge('font-size': '9px').freeze - - ## - # Define Style for month labels - - SVG_MONTH_STYLE = SVG_SHARED_STYLE.dup.merge('font-size': '10px').freeze - - private - - def render_svg - grid = matrix - chart = SVGPlot.new(width: (CUBE_SIZE * grid.column_size) + X_PAD, - height: (CUBE_SIZE * grid.row_size) + Y_PAD) - svg_add_points grid, chart - svg_add_weekdays chart - svg_add_months chart - chart.to_s - end - - def render_svg_square - grid = matrix.minor(0, 7, -7, 7) - chart = SVGPlot.new(width: (CUBE_SIZE * grid.column_size) - 2, - height: (CUBE_SIZE * grid.row_size) - 2) - svg_add_points grid, chart, 0, 0 - chart.to_s - end - - def svg_point_style(point) - { - fill: @colors[@stats.quartile(point.score)], - 'shape-rendering': 'crispedges' - } - end - - def svg_add_points(grid, chart, xpadding = X_PAD, ypadding = Y_PAD) - grid.each_with_index do |point, y, x| - next if point.score == -1 - chart.rectangle( - (x * CUBE_SIZE) + xpadding, (y * CUBE_SIZE) + ypadding, 10, 10, - data: { score: point.score, date: point.date }, - style: svg_point_style(point) - ) - end - end - - def svg_add_weekday(chart, point) - index = point.date.wday - letter = point.date.strftime('%a') - style = SVG_WEEKDAY_STYLE.dup - style[:display] = 'none' unless [1, 3, 5].include? index - shift = index > 3 ? 29 : 28 - chart.text(0, (CUBE_SIZE * index) + shift, style: style) { raw letter } - end - - def svg_add_weekdays(chart) - @stats.raw.first(7).each { |point| svg_add_weekday chart, point } - end - - def svg_get_month_offsets # rubocop:disable Metrics/AbcSize - list = @stats.raw.select { |x| x.date.sunday? } - list.unshift(@stats.raw.first) unless @stats.raw.first.date.sunday? - list.map! { |x| x.date.strftime('%b') } - acc = 0 - list.chunk { |x| x }.map do |month, offset| - acc += offset.size - [month, acc - offset.size] - end - end - - def svg_add_months(chart) - offsets = svg_get_month_offsets - offsets.shift if [1, 2].include? offsets[1].last - offsets.each do |month, offset| - next if offset > 50 - x = (CUBE_SIZE * offset) + X_PAD - chart.text(x, 10, style: SVG_MONTH_STYLE) { raw month } - end - end - end -end diff --git a/lib/githubchart/version.rb b/lib/githubchart/version.rb deleted file mode 100644 index 4578a4d..0000000 --- a/lib/githubchart/version.rb +++ /dev/null @@ -1,5 +0,0 @@ -## -# Define the version -module GithubChart - VERSION = '4.0.0'.freeze -end diff --git a/other_user.svg b/other_user.svg new file mode 100644 index 0000000..b5a23f7 --- /dev/null +++ b/other_user.svg @@ -0,0 +1,6 @@ + + + +MTWTFSSOctNovDecJanFebMarAprMayJunJulAug \ No newline at end of file diff --git a/spec/examples/input.json b/spec/examples/input.json deleted file mode 100644 index 946be39..0000000 --- a/spec/examples/input.json +++ /dev/null @@ -1 +0,0 @@ -[["2013/08/30",0],["2013/08/31",2],["2013/09/01",0],["2013/09/02",0],["2013/09/03",0],["2013/09/04",0],["2013/09/05",0],["2013/09/06",0],["2013/09/07",0],["2013/09/08",0],["2013/09/09",0],["2013/09/10",0],["2013/09/11",0],["2013/09/12",0],["2013/09/13",0],["2013/09/14",0],["2013/09/15",0],["2013/09/16",0],["2013/09/17",0],["2013/09/18",0],["2013/09/19",0],["2013/09/20",0],["2013/09/21",8],["2013/09/22",0],["2013/09/23",0],["2013/09/24",0],["2013/09/25",0],["2013/09/26",0],["2013/09/27",0],["2013/09/28",0],["2013/09/29",0],["2013/09/30",8],["2013/10/01",0],["2013/10/02",1],["2013/10/03",0],["2013/10/04",0],["2013/10/05",1],["2013/10/06",0],["2013/10/07",7],["2013/10/08",10],["2013/10/09",0],["2013/10/10",2],["2013/10/11",0],["2013/10/12",0],["2013/10/13",0],["2013/10/14",0],["2013/10/15",0],["2013/10/16",0],["2013/10/17",0],["2013/10/18",0],["2013/10/19",0],["2013/10/20",0],["2013/10/21",1],["2013/10/22",0],["2013/10/23",0],["2013/10/24",0],["2013/10/25",0],["2013/10/26",0],["2013/10/27",0],["2013/10/28",0],["2013/10/29",0],["2013/10/30",0],["2013/10/31",0],["2013/11/01",0],["2013/11/02",5],["2013/11/03",0],["2013/11/04",0],["2013/11/05",0],["2013/11/06",0],["2013/11/07",0],["2013/11/08",0],["2013/11/09",0],["2013/11/10",0],["2013/11/11",0],["2013/11/12",0],["2013/11/13",0],["2013/11/14",0],["2013/11/15",0],["2013/11/16",1],["2013/11/17",0],["2013/11/18",0],["2013/11/19",0],["2013/11/20",0],["2013/11/21",0],["2013/11/22",0],["2013/11/23",0],["2013/11/24",1],["2013/11/25",9],["2013/11/26",1],["2013/11/27",0],["2013/11/28",0],["2013/11/29",4],["2013/11/30",0],["2013/12/01",17],["2013/12/02",0],["2013/12/03",1],["2013/12/04",9],["2013/12/05",3],["2013/12/06",7],["2013/12/07",1],["2013/12/08",6],["2013/12/09",6],["2013/12/10",1],["2013/12/11",2],["2013/12/12",2],["2013/12/13",1],["2013/12/14",13],["2013/12/15",1],["2013/12/16",3],["2013/12/17",1],["2013/12/18",0],["2013/12/19",1],["2013/12/20",1],["2013/12/21",0],["2013/12/22",4],["2013/12/23",0],["2013/12/24",0],["2013/12/25",0],["2013/12/26",1],["2013/12/27",0],["2013/12/28",0],["2013/12/29",0],["2013/12/30",0],["2013/12/31",0],["2014/01/01",0],["2014/01/02",0],["2014/01/03",0],["2014/01/04",0],["2014/01/05",0],["2014/01/06",0],["2014/01/07",0],["2014/01/08",0],["2014/01/09",0],["2014/01/10",0],["2014/01/11",0],["2014/01/12",0],["2014/01/13",0],["2014/01/14",0],["2014/01/15",0],["2014/01/16",0],["2014/01/17",0],["2014/01/18",0],["2014/01/19",0],["2014/01/20",0],["2014/01/21",0],["2014/01/22",0],["2014/01/23",0],["2014/01/24",0],["2014/01/25",0],["2014/01/26",0],["2014/01/27",0],["2014/01/28",0],["2014/01/29",0],["2014/01/30",0],["2014/01/31",0],["2014/02/01",0],["2014/02/02",0],["2014/02/03",0],["2014/02/04",0],["2014/02/05",0],["2014/02/06",0],["2014/02/07",0],["2014/02/08",0],["2014/02/09",0],["2014/02/10",0],["2014/02/11",0],["2014/02/12",0],["2014/02/13",0],["2014/02/14",0],["2014/02/15",0],["2014/02/16",3],["2014/02/17",0],["2014/02/18",0],["2014/02/19",0],["2014/02/20",0],["2014/02/21",0],["2014/02/22",0],["2014/02/23",0],["2014/02/24",0],["2014/02/25",0],["2014/02/26",0],["2014/02/27",0],["2014/02/28",0],["2014/03/01",0],["2014/03/02",0],["2014/03/03",0],["2014/03/04",1],["2014/03/05",0],["2014/03/06",0],["2014/03/07",0],["2014/03/08",0],["2014/03/09",0],["2014/03/10",1],["2014/03/11",0],["2014/03/12",1],["2014/03/13",0],["2014/03/14",0],["2014/03/15",3],["2014/03/16",4],["2014/03/17",1],["2014/03/18",0],["2014/03/19",0],["2014/03/20",0],["2014/03/21",0],["2014/03/22",3],["2014/03/23",1],["2014/03/24",0],["2014/03/25",0],["2014/03/26",0],["2014/03/27",3],["2014/03/28",3],["2014/03/29",0],["2014/03/30",0],["2014/03/31",0],["2014/04/01",0],["2014/04/02",0],["2014/04/03",0],["2014/04/04",0],["2014/04/05",0],["2014/04/06",0],["2014/04/07",0],["2014/04/08",1],["2014/04/09",0],["2014/04/10",0],["2014/04/11",0],["2014/04/12",0],["2014/04/13",0],["2014/04/14",0],["2014/04/15",0],["2014/04/16",0],["2014/04/17",0],["2014/04/18",0],["2014/04/19",4],["2014/04/20",1],["2014/04/21",0],["2014/04/22",2],["2014/04/23",0],["2014/04/24",0],["2014/04/25",0],["2014/04/26",0],["2014/04/27",0],["2014/04/28",0],["2014/04/29",0],["2014/04/30",1],["2014/05/01",0],["2014/05/02",0],["2014/05/03",2],["2014/05/04",1],["2014/05/05",0],["2014/05/06",0],["2014/05/07",0],["2014/05/08",0],["2014/05/09",2],["2014/05/10",0],["2014/05/11",0],["2014/05/12",2],["2014/05/13",0],["2014/05/14",0],["2014/05/15",0],["2014/05/16",1],["2014/05/17",0],["2014/05/18",0],["2014/05/19",2],["2014/05/20",0],["2014/05/21",0],["2014/05/22",0],["2014/05/23",0],["2014/05/24",0],["2014/05/25",0],["2014/05/26",0],["2014/05/27",0],["2014/05/28",2],["2014/05/29",0],["2014/05/30",0],["2014/05/31",0],["2014/06/01",0],["2014/06/02",0],["2014/06/03",0],["2014/06/04",0],["2014/06/05",0],["2014/06/06",0],["2014/06/07",0],["2014/06/08",2],["2014/06/09",0],["2014/06/10",2],["2014/06/11",0],["2014/06/12",0],["2014/06/13",2],["2014/06/14",0],["2014/06/15",1],["2014/06/16",0],["2014/06/17",1],["2014/06/18",0],["2014/06/19",0],["2014/06/20",0],["2014/06/21",0],["2014/06/22",0],["2014/06/23",0],["2014/06/24",0],["2014/06/25",1],["2014/06/26",0],["2014/06/27",5],["2014/06/28",0],["2014/06/29",7],["2014/06/30",0],["2014/07/01",2],["2014/07/02",1],["2014/07/03",0],["2014/07/04",0],["2014/07/05",1],["2014/07/06",2],["2014/07/07",3],["2014/07/08",5],["2014/07/09",5],["2014/07/10",0],["2014/07/11",0],["2014/07/12",0],["2014/07/13",0],["2014/07/14",0],["2014/07/15",0],["2014/07/16",0],["2014/07/17",3],["2014/07/18",0],["2014/07/19",0],["2014/07/20",0],["2014/07/21",0],["2014/07/22",0],["2014/07/23",0],["2014/07/24",0],["2014/07/25",0],["2014/07/26",0],["2014/07/27",0],["2014/07/28",0],["2014/07/29",0],["2014/07/30",0],["2014/07/31",0],["2014/08/01",0],["2014/08/02",0],["2014/08/03",0],["2014/08/04",0],["2014/08/05",0],["2014/08/06",0],["2014/08/07",0],["2014/08/08",0],["2014/08/09",0],["2014/08/10",2],["2014/08/11",0],["2014/08/12",0],["2014/08/13",0],["2014/08/14",0],["2014/08/15",0],["2014/08/16",4],["2014/08/17",0],["2014/08/18",0],["2014/08/19",1],["2014/08/20",0],["2014/08/21",0],["2014/08/22",0],["2014/08/23",0],["2014/08/24",0],["2014/08/25",2],["2014/08/26",0],["2014/08/27",0],["2014/08/28",0],["2014/08/29",0],["2014/08/30",0],["2014/08/31",8]] \ No newline at end of file diff --git a/spec/githubchart/svg_spec.rb b/spec/githubchart/svg_spec.rb deleted file mode 100644 index c3361a7..0000000 --- a/spec/githubchart/svg_spec.rb +++ /dev/null @@ -1,26 +0,0 @@ -require 'spec_helper' -require 'tempfile' - -def test_svg(type) - file = Tempfile.new('svg') - file.write(GithubChart.new(user: 'akerl').render(type)) - path = file.path - file.close - res = `file #{path}` - file.unlink - res -end - -describe GithubChart::Chart do - describe '#render_svg' do - it 'makes an SVG' do - expect(test_svg(:svg)).to include('Scalable Vector Graphic') - end - end - - describe '#render_svg_square' do - it 'makes an SVG' do - expect(test_svg(:svg_square)).to include('Scalable Vector Graphic') - end - end -end diff --git a/spec/githubchart_spec.rb b/spec/githubchart_spec.rb deleted file mode 100644 index d7a56be..0000000 --- a/spec/githubchart_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -describe GithubChart do - describe '#new' do - it 'creates a new Chart object' do - expect(GithubChart.new(data: [])).to be_an_instance_of GithubChart::Chart - end - end - - describe '#supported' do - it 'lists supported types' do - expect(GithubChart.supported).to include(:svg) - end - end - - describe '#supports?' do - it 'checks for type support' do - expect(GithubChart.supports?(:svg)).to be_truthy - expect(GithubChart.supports?(:fish)).to be_falsey - end - end - - describe GithubChart::Chart do - it 'has default colors' do - expect(GithubChart.new(data: []).colors.last).to eql '#196127' - end - it 'lets you override the colors' do - colors = [1, 2, 3, 4, 5] - expect(GithubChart.new(data: [], colors: colors).colors.last).to eql 5 - end - it 'lets you pass external data' do - data = JSON.parse(File.read('spec/examples/input.json')) - expect(GithubChart.new(data: data).stats).to eql data - end - it 'creates a data object when not provided' do - expect( - GithubChart.new(user: 'akerl').stats - ).to be_an_instance_of GithubStats::Data - end - end - - describe '#render' do - it 'raises error if render type is unsupported' do - expect { GithubChart.new(user: 'akerl').render(:dog) } - .to raise_error(NameError) - end - end -end - -describe Integer do - describe '#ordinalize' do - it 'returns a spoken string for a number' do - [ - [0, '0'], - [13, '13th'], - [21, '21st'], - [32, '32nd'], - [43, '43rd'], - [54, '54th'] - ].each do |i, o| - expect(i.ordinalize).to eql o - end - end - end -end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb deleted file mode 100644 index 42f5852..0000000 --- a/spec/spec_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -require 'rspec' -require 'githubchart' diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..1b888e6 --- /dev/null +++ b/update.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +githubchart chart.svg +githubchart -u fly other_user.svg +