Skip to content

Commit

Permalink
Use oga instead of nokogiri
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlgo11 committed Dec 1, 2021
1 parent 684486f commit 0163335
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM ruby:3-alpine
RUN apk add --no-cache ruby-bundler build-base libxml2-dev libxslt-dev
RUN apk add --no-cache make gcc libc-dev
RUN echo -e "#!/bin/sh\ncd /nanoleaf;./main.rb >> /var/log/nanoleaf" > /etc/periodic/15min/nanoleaf
RUN chmod +x /etc/periodic/15min/nanoleaf
RUN adduser -DHu 1001 nanoleaf
Expand All @@ -11,6 +11,5 @@ COPY --chown=1001 ["main.rb", "Gemfile", "effect.json", "/nanoleaf/"]
ENV HOME="/tmp/"
ENV GEM_HOME="/nanoleaf/vendor/bundle"
ENV PATH $GEM_HOME/bin:$GEM_HOME/gems/bin:$PATH
RUN bundle config build.nokogiri --use-system-libraries
RUN bundle install
CMD ./main.rb >> /var/log/nanoleaf & tail -F /var/log/nanoleaf
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
source 'https://rubygems.org'

gem 'color-converter'
gem 'nokogiri'
gem 'oga'
4 changes: 2 additions & 2 deletions main.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

require 'nokogiri'
require 'json'
require 'uri'
require 'net/http'
require 'color_converter'
require 'date'
require 'open-uri'
require 'oga'

def colors
case Date.today.strftime('%m%d')
Expand All @@ -25,7 +25,7 @@ def fetch_var(name)
end

def fetch_github_activity(length)
html = Nokogiri::HTML.parse(URI.open("https://github.com/#{fetch_var('GITHUB_USER')}"))
html = Oga.parse_html(URI.open("https://github.com/#{fetch_var('GITHUB_USER')}"))
days = []
boxes = html.css('rect.ContributionCalendar-day')
boxes.each { |item| days << Integer(item['data-level']) unless item['data-date'].nil? }
Expand Down

0 comments on commit 0163335

Please sign in to comment.