shill 0.1.1 → 0.2.0
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 +4 -4
- data/README.md +25 -2
- data/lib/shill/helpers.rb +16 -0
- data/lib/shill/railtie.rb +13 -0
- data/lib/shill/version.rb +1 -1
- data/lib/shill.rb +7 -0
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f0ffc8cf45e7690dea17a48ab6370bb9016df49f0e6ca70b701c782316db2ae
|
4
|
+
data.tar.gz: 37f21d5c06c84e3f4afd104331476fb17a8f5789cf6c1bfd230678b5b94218e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa60818f20a34a3080ea6dc83f58a005b546ce59f56a277b245e1f46e6332e284de696e3fe654000b3e8fd0aa3d34ab4401dd3145e0f2a9bb86073a19c8b4329
|
7
|
+
data.tar.gz: a2add6060a5e0af99d10faadd0ce372d054c1780b7515620dae1a6bcc66b33b1e17735c0c2dd9e6a81ca321d8ea9e99a29b3fb236e45e0b8414131d3a6b7076c
|
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"
|
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
|
data/lib/shill/version.rb
CHANGED
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
|
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.
|
4
|
+
version: 0.2.0
|
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
|