shill 0.1.1 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6b37e2e8280c1b400c3d5a9d8faa3a292eadc7835090f01511c1d28658d101d1
4
- data.tar.gz: 8c9584c5fddc36f5aa515119244687771ac4b2cc32aec5be0e4f2318627a8147
3
+ metadata.gz: 524172e34543e6279787babb3e191d017c60da59221f550c93057f7a0b223c98
4
+ data.tar.gz: f9a4ebc9597c2a32f7207d3920e66efcaec55472464228c4b0a796882525bf84
5
5
  SHA512:
6
- metadata.gz: 7ebf69a9daf634fc8d66547044274e8cd15df36e14fb5216e4fca278ff32c7b3b0b17bb0f7bb2216fdb11aee1322e16452e3476d5d3864b6604ae6af680e18ea
7
- data.tar.gz: f1d1170b2606988b8bffee707851191bb921a84c52deb723f27fe7e317bd92ef2b30fe1b803557ca1e656975dd51ff1a7b251e993f1492af2b4f9934a25dcc17
6
+ metadata.gz: 49d711dd937079351e88e3e1a1365d4b83057de33ab8699e73a9e1fb7de2c89d31de28d147e35d7d404b78bd483b8535c6cf1ccd7bdc63af2dbe594c1c57bbb8
7
+ data.tar.gz: e0896a8544989da97e060d903991d6b66fdb6348fff6345d3959ed0623f6fe89bb0160d35e917b5a60a3ebd40859e93b78f77f7fcb6572a00c66ef49b27575e2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.1] - 2025-05-15
4
+
5
+ - Change: `fetch_projects` now always raises `Shill::Error` on failure instead of silently returning `nil`. This prevents `Shill.projects` from ever returning `nil`.
6
+
7
+ ## [0.2.0] - 2025-05-15
8
+
9
+ - Feature: `shill_projects` and `shill_random_project` view helpers auto-load in Rails apps.
10
+
3
11
  ## [0.1.1] - 2025-05-15
4
12
 
5
13
  - Fix: Replace example URLs
data/README.md CHANGED
@@ -14,8 +14,7 @@ A tiny, dependency-free Ruby gem that fetches and exposes a list of projects fro
14
14
  Add the gem to your project:
15
15
 
16
16
  ```ruby
17
- gem "shill", github: "marckohlbrugge/shill" # until published on RubyGems
18
- gem "shill" # once published
17
+ gem "shill"
19
18
  ```
20
19
 
21
20
  Then install:
@@ -179,3 +178,27 @@ Shill.projects(refresh: true) # bypasses cache and stores fresh data
179
178
  ```
180
179
 
181
180
  ---
181
+
182
+ ## Rails view helpers
183
+
184
+ Once the gem is loaded in a Rails app, you can access the data directly in any view:
185
+
186
+ ```erb
187
+ <ul>
188
+ <% shill_projects.each do |project| %>
189
+ <li>
190
+ <%= link_to project.name, project.url %> — <%= project.description %>
191
+ </li>
192
+ <% end %>
193
+ </ul>
194
+ ```
195
+
196
+ Need just one?
197
+
198
+ ```erb
199
+ <% if (proj = shill_random_project) %>
200
+ <%= link_to proj.name, proj.url %>
201
+ <% end %>
202
+ ```
203
+
204
+ ---
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Shill
4
+ # View-helper methods for Rails
5
+ module Helpers
6
+ # Returns all cached projects (see Shill.projects)
7
+ def shill_projects
8
+ Shill.projects
9
+ end
10
+
11
+ # Returns a single random project
12
+ def shill_random_project
13
+ Shill.random_project
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/railtie"
4
+
5
+ module Shill
6
+ class Railtie < ::Rails::Railtie
7
+ initializer "shill.view_helpers" do
8
+ ActiveSupport.on_load(:action_view) do
9
+ include Shill::Helpers
10
+ end
11
+ end
12
+ end
13
+ end
data/lib/shill/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shill
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.1"
5
5
  end
data/lib/shill.rb CHANGED
@@ -1,6 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "shill/version"
4
+ # Autoload internal files
5
+ require_relative "shill/helpers"
6
+
7
+ # Load Railtie if Rails is present
8
+ if defined?(Rails::Railtie)
9
+ require_relative "shill/railtie"
10
+ end
4
11
 
5
12
  module Shill
6
13
  class Error < StandardError; end
@@ -99,8 +106,8 @@ module Shill
99
106
  # Return an array of Project objects for nicer dot-notation access.
100
107
  parsed.map { |attrs| Project.new(attrs) }
101
108
  rescue StandardError => e
102
- # Re-wrap into Shill::Error to keep API consistent
103
- raise Error, e.message unless e.is_a?(Error)
109
+ # Always propagate as Shill::Error so callers never receive `nil`.
110
+ raise Error, e.message
104
111
  end
105
112
 
106
113
  # Ensure we have an array of hashes with required keys.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marc Köhlbrugge
@@ -24,6 +24,8 @@ files:
24
24
  - README.md
25
25
  - Rakefile
26
26
  - lib/shill.rb
27
+ - lib/shill/helpers.rb
28
+ - lib/shill/railtie.rb
27
29
  - lib/shill/version.rb
28
30
  - sig/shill.rbs
29
31
  homepage: https://github.com/marckohlbrugge/shill