Auto color data#23
Open
nanobowers wants to merge 2 commits intored-data-tools:masterfrom
Open
Conversation
kou
reviewed
Jan 26, 2022
| }.freeze | ||
| end | ||
| end | ||
| require_relative "./color_data/matplotlib" |
Member
There was a problem hiding this comment.
We don't need the preceding ./:
Suggested change
| require_relative "./color_data/matplotlib" | |
| require_relative "color_data/matplotlib" |
| require "open-uri" | ||
| require "nokogiri" | ||
|
|
||
| module GetColors |
|
|
||
| class CSS4 | ||
| def initialize | ||
| @colordata = [] |
| @colordata = [] | ||
| end | ||
|
|
||
| def get_data |
| doc = Nokogiri::HTML(html) | ||
| table = doc.css("table.named-color-table").first | ||
| table.css("tbody").children.each do |kid| | ||
| colorname = kid.css("dfn").text.strip |
| end | ||
|
|
||
| def dump_file(filename) | ||
| File.open(filename, "w") do |fh| |
Member
There was a problem hiding this comment.
Opened file is a File object not file handler. So file is better than fh:
Suggested change
| File.open(filename, "w") do |fh| | |
| File.open(filename, "w") do |file| |
| CSS4FOOTER | ||
| end | ||
|
|
||
| def dump_file(filename) |
| end | ||
|
|
||
| def header(fh) | ||
| fh.puts <<~CSS4HEADER |
Member
There was a problem hiding this comment.
We can remove CSS4 prefix because this class is for CSS4:
Suggested change
| fh.puts <<~CSS4HEADER | |
| fh.puts <<~HEADER |
| css4.dump_file("lib/colors/color_data/css4.rb") | ||
| end | ||
|
|
||
| desc "Get color data files from the web, per issue #8" |
Member
There was a problem hiding this comment.
We don't need to refer #8 here.
Suggested change
| desc "Get color data files from the web, per issue #8" | |
| desc "Get color data files from the web" |
| end | ||
|
|
||
| desc "Get color data files from the web, per issue #8" | ||
| task :get_colors => [:get_xkcd, :get_css4] |
Member
There was a problem hiding this comment.
How about colors:generate?
Suggested change
| task :get_colors => [:get_xkcd, :get_css4] | |
| namespace :colors do | |
| namespace :generate do | |
| task :xkcd do | |
| # ... | |
| end | |
| task :css4 do | |
| # ... | |
| end | |
| end | |
| task :generate => [:xkcd, :css4] | |
| end |
Member
|
Could you create a separated pull request that separates |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves issue #8 by adding rake-tasks to get XKCD and CSS4 colors from the URIs listed in the documentation.
It is worth noting that:
colors/color_data.rbinto separate files, in preparation for some portions (xkcd.rb, css4.rb) to be autogenerated.