Lospec
Installation
TODO: Replace UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
Install the gem and add to the application's Gemfile by executing:
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
Usage
Use Lospec::Palette.search to search for palettes. For example, to find a palette with four colors:
palette = Lospec::Palette.search(colors: 4).first
palette.slug # => "tropical-fruit-04"
palette.colors # => ["f5b413", "9c1904", "dd0956", "250442"]
You can also sort by most downloads first, and specify an endless range for colors. The available sort options are %i[default alphabetical downloads newest].
palette = Lospec::Palette.search(colors: ..3, tag: 'black', sort: :downloads).first
palette.title # => "1bit Monitor Glow"
palette.colors # => ["222323", "f0f6f0"]
The search method returns a lazy enumerable, so you can filter and limit. For example, to find up to three popular palettes with four or more colors containing pure white:
palettes = Lospec::Palette
.search(colors: 4.., sort: :downloads)
.filter { |palette| palette.colors.include?("ffffff") }
.take(3)
.to_a
palettes.map(&:slug) # => ["2-bit-grayscale", "arq4", "cga-palette-1-high"]
If you know the slug of a specific palette, you can fetch it directly:
palette = Lospec::Palette.fetch("nintendo-gameboy-bgb")
palette.description # => "The default palette used by the bgb emulator..."
Development
After checking out the repo, run bin/setup to install dependencies. Then, run rake spec to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.
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 the created tag, and push the .gem file to rubygems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/Aesthetikx/lospec.
License
The gem is available as open source under the terms of the MIT License.