Skip to content

Commit

Permalink
Merge pull request #1 from apainintheneck/add-ci
Browse files Browse the repository at this point in the history
Add CI
  • Loading branch information
apainintheneck authored Dec 1, 2024
2 parents 9347bf0 + c26986f commit 244d6b6
Show file tree
Hide file tree
Showing 15 changed files with 552 additions and 506 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
open-pull-requests-limit: 2
- package-ecosystem: "bundler"
directory: "/"
schedule:
interval: "weekly"
day: "sunday"
open-pull-requests-limit: 5
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: CI
on:
push:
branches: main
pull_request:
jobs:
tests:
strategy:
matrix:
platform: ["ubuntu-latest", "macos-latest"]
ruby: [3.0, 3.1, 3.2, 3.3]
runs-on: ${{ matrix.platform }}
steps:
- name: Set up Git repository
uses: actions/checkout@main

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Run linter
run: bundle exec standardrb

- name: Run tests
run: bundle exec rspec
3 changes: 2 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PATH
tty-markdown (~> 0.7.2)
tty-pager (~> 0.14.0)
tty-prompt (~> 0.23.1)
zeitwerk (< 2.7)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -143,7 +144,7 @@ GEM
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
wisper (2.0.1)
zeitwerk (2.7.1)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand Down
12 changes: 0 additions & 12 deletions Rakefile

This file was deleted.

19 changes: 10 additions & 9 deletions gemview.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ Gem::Specification.new do |spec|
spec.authors = ["apainintheneck"]
spec.email = ["[email protected]"]

spec.summary = "TODO: Write a short summary, because RubyGems requires one."
spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.summary = "An unofficial CLI interface to browse rubygems.org"
spec.description = <<~DESCRIPTION
An unofficial CLI interface to browse rubygems.org. Search for gems by name, see which ones have been recently updated and look at their dependencies.
DESCRIPTION
spec.homepage = "https://github.com/apainintheneck/gemview"
spec.license = "MIT"
spec.required_ruby_version = ">= 3.0.0"

spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
spec.metadata["source_code_uri"] = spec.homepage
spec.metadata["changelog_uri"] = "https://github.com/apainintheneck/gemview/blob/main/CHANGELOG.md"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

# Direct dependencies
spec.add_dependency "dry-cli", "~> 1.2.0"
spec.add_dependency "dry-struct", "~> 1.6.0"
spec.add_dependency "gems", "~> 1.3.0"
Expand All @@ -41,6 +42,6 @@ Gem::Specification.new do |spec|
spec.add_dependency "tty-pager", "~> 0.14.0"
spec.add_dependency "tty-prompt", "~> 0.23.1"

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
# Transitive dependencies
spec.add_dependency "zeitwerk", "< 2.7"
end
19 changes: 8 additions & 11 deletions lib/gemview/gem.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,15 @@ def selector_str

# @return [String]
def header_str
info_lines = Strings.wrap(info, 80).lines.map(&:strip)
info_lines = info_lines.take(3).append("...") if info_lines.size > 3

header = <<~HEADER
## [#{version}] #{name}
#{Strings.wrap(info, 80).chomp}
```
#{info_lines.join("\n")}
```
| Updated at | #{version_created_at} |
| Total Downloads | #{humanized_downloads} |
Expand All @@ -87,11 +92,7 @@ def header_str
| Project URI | #{project_uri} |
HEADER

begin
TTY::Markdown.parse(header)
rescue # Return the raw markdown if parsing fails
header
end
Terminal.prettify_markdown(header)
end

# @return [String]
Expand Down Expand Up @@ -120,11 +121,7 @@ def dependencies_str
#{dev_deps_str}
DEPENDENCIES

begin
TTY::Markdown.parse(dependencies)
rescue # Return the raw markdown if parsing fails
dependencies
end
Terminal.prettify_markdown(dependencies)
end

# @return [Array<String>]
Expand Down
6 changes: 1 addition & 5 deletions lib/gemview/git_repo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,7 @@ def fetch(url)
response = Net::HTTP.get_response(URI(url))
if response.is_a?(Net::HTTPSuccess)
body = response.body.force_encoding("UTF-8")
begin
TTY::Markdown.parse(body)
rescue # Return raw body on any parsing errors
body
end
Terminal.prettify_markdown(body)
end
rescue Net::HTTPError
nil
Expand Down
14 changes: 14 additions & 0 deletions lib/gemview/terminal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ def self.choose(message, choices, per_page: 6)
end
end

TTY_COLOR = ENV["NO_COLOR"] ? :never : :auto
private_constant :TTY_COLOR

# A best effort attempt to format and highlight markdown text.
# If it's unsuccessful, it will return the original text.
#
# @param text [String]
# @return [String]
def self.prettify_markdown(text)
TTY::Markdown.parse(text, color: TTY_COLOR)
rescue # Return the raw markdown if parsing fails
text
end

# @return [Selector]
def self.selector
@selector ||= Selector.new
Expand Down
71 changes: 35 additions & 36 deletions spec/gemview/__snapshots__/ble-gem-readme
Original file line number Diff line number Diff line change
@@ -1,39 +1,38 @@
ruby-ble
ruby-ble
Bluetooth Low Energy for Ruby
(Gem Version - https://badge.fury.io/rb/ble.svg) » https://badge.fury.io/rb/ble
(Gem Version - https://badge.fury.io/rb/ble.svg) » https://badge.fury.io/rb/ble

Requirements
● ruby >= 2.3
● Dbus
● bluez >= 5.36 (available on debian testing)
● bluetoothd started with option -E (experimental)
Requirements
ruby >= 2.3
Dbus
bluez >= 5.36 (available on debian testing)
● bluetoothd started with option -E (experimental)

Examples
# Selecter adapter
$a = BLE::Adapter.new('hci0')
puts "Info: #{$a.iface} #{$a.address} #{$a.name}"

# Run discovery
$a.start_discovery
sleep(2)
$a.stop_discovery

# Get device and connect to it
$d = $a['F4:AD:CB:FB:B4:85']
$d.connect

# Get temperature from the environmental sensing service
$d[:environmental_sensing, :temperature]

# Dump device information
srv = :device_information
$d.characteristics(srv).each {|uuid|
 info = BLE::Characteristic[uuid]
 name = info.nil? ? uuid : info[:name]
 value = $d[srv, uuid] rescue '/!\\ not-readable /!\\'
 puts "%-30s: %s" % [ name, value ]
}


Contributors
● Oliver Valls (tramuntanal): Bug fixes / BLE Notification support
Examples
# Selecter adapter
$a = BLE::Adapter.new('hci0')
puts "Info: #{$a.iface} #{$a.address} #{$a.name}"

# Run discovery
$a.start_discovery
sleep(2)
$a.stop_discovery

# Get device and connect to it
$d = $a['F4:AD:CB:FB:B4:85']
$d.connect

# Get temperature from the environmental sensing service
$d[:environmental_sensing, :temperature]

# Dump device information
srv = :device_information
$d.characteristics(srv).each {|uuid|
info = BLE::Characteristic[uuid]
name = info.nil? ? uuid : info[:name]
value = $d[srv, uuid] rescue '/!\\ not-readable /!\\'
puts "%-30s: %s" % [ name, value ]
}

Contributors
● Oliver Valls (tramuntanal): Bug fixes / BLE Notification support
33 changes: 16 additions & 17 deletions spec/gemview/__snapshots__/rails-dependencies-str
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
[Dependencies]
[Dependencies]

Runtime Dependencies:
gem "actioncable", "= 8.0.0"
gem "actionmailbox", "= 8.0.0"
gem "actionmailer", "= 8.0.0"
gem "actionpack", "= 8.0.0"
gem "actiontext", "= 8.0.0"
gem "actionview", "= 8.0.0"
gem "activejob", "= 8.0.0"
gem "activemodel", "= 8.0.0"
gem "activerecord", "= 8.0.0"
gem "activestorage", "= 8.0.0"
gem "activesupport", "= 8.0.0"
gem "bundler", ">= 1.15.0"
gem "railties", "= 8.0.0"

Development Dependencies:
Runtime Dependencies:
gem "actioncable", "= 8.0.0"
gem "actionmailbox", "= 8.0.0"
gem "actionmailer", "= 8.0.0"
gem "actionpack", "= 8.0.0"
gem "actiontext", "= 8.0.0"
gem "actionview", "= 8.0.0"
gem "activejob", "= 8.0.0"
gem "activemodel", "= 8.0.0"
gem "activerecord", "= 8.0.0"
gem "activestorage", "= 8.0.0"
gem "activesupport", "= 8.0.0"
gem "bundler", ">= 1.15.0"
gem "railties", "= 8.0.0"
Development Dependencies:
(none)
29 changes: 14 additions & 15 deletions spec/gemview/__snapshots__/rails-header-str
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[8.0.0] rails
[8.0.0] rails

Ruby on Rails is a full-stack web framework optimized for programmer happiness
and sustainable productivity. It encourages beautiful code by favoring
Ruby on Rails is a full-stack web framework optimized for programmer happiness
and sustainable productivity. It encourages beautiful code by favoring
convention over configuration.

┌─────────────────┬─────────────────────────────────┐
│ Updated at │ 2024-11-07 22:30:42 UTC │
├─────────────────┼─────────────────────────────────┤
│ Total Downloads │ 567,406,953 │
├─────────────────┼─────────────────────────────────┤
│ Authors │ David Heinemeier Hansson │
├─────────────────┼─────────────────────────────────┤
│ Licenses │ [“MIT”] │
├─────────────────┼─────────────────────────────────┤
│ Project URI │ https://rubygems.org/gems/rails │
└─────────────────┴─────────────────────────────────┘
┌─────────────────┬─────────────────────────────────┐
│ Updated at │ 2024-11-07 22:30:42 UTC │
├─────────────────┼─────────────────────────────────┤
│ Total Downloads │ 567,406,953 │
├─────────────────┼─────────────────────────────────┤
│ Authors │ David Heinemeier Hansson │
├─────────────────┼─────────────────────────────────┤
│ Licenses │ [“MIT”] │
├─────────────────┼─────────────────────────────────┤
│ Project URI │ https://rubygems.org/gems/rails │
└─────────────────┴─────────────────────────────────┘
17 changes: 8 additions & 9 deletions spec/gemview/__snapshots__/standard-dependencies-str
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[Dependencies]
[Dependencies]

Runtime Dependencies:
gem "language_server-protocol", "~> 3.17.0.2"
gem "lint_roller", "~> 1.0"
gem "rubocop", "~> 1.68.0"
gem "standard-custom", "~> 1.0.0"
gem "standard-performance", "~> 1.5"

Development Dependencies:
Runtime Dependencies:
gem "language_server-protocol", "~> 3.17.0.2"
gem "lint_roller", "~> 1.0"
gem "rubocop", "~> 1.68.0"
gem "standard-custom", "~> 1.0.0"
gem "standard-performance", "~> 1.5"
Development Dependencies:
(none)
Loading

0 comments on commit 244d6b6

Please sign in to comment.