jekyll_mtg 1.0.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d87c90171e88d4f20498861a07ad63de04bd9bce07fa90cd32c0ba72067d50f5
4
+ data.tar.gz: 74ee29255ae317e1e31cdfdc517d816927ad3ed892411bbc1afa15f8c33c0441
5
+ SHA512:
6
+ metadata.gz: 14d009a4276b3eb4785e220ddd65fd97fcbfa145aabfea260a5816a77a15c0e9246a9dc59f44c29b8ecabe18ccfa624b456b3b6e9606c7885cb1a1b114d5ffe2
7
+ data.tar.gz: c0968511f48ab3c9e676a6caaaa74d308f1e3ebe81b424aca50da45fcd029595d74212b05bc48af3d77e179ec80599e4d004a1da1b5c94bf47e499db6150fe37
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,17 @@
1
+ AllCops:
2
+ NewCops: enable
3
+ TargetRubyVersion: 3.1
4
+
5
+ Layout/LineLength:
6
+ Exclude:
7
+ - 'spec/**'
8
+
9
+ Metrics/BlockLength:
10
+ Exclude:
11
+ - 'spec/**'
12
+
13
+ Style/StringLiterals:
14
+ EnforcedStyle: single_quotes
15
+
16
+ Style/StringLiteralsInInterpolation:
17
+ EnforcedStyle: double_quotes
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License (MIT)
2
+
3
+ Copyright (c) 2025 Matthew Serre
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # JekyllMTG
2
+
3
+ `jekyll_mtg` is a `jekyll` plugin that helps you reference *Magic: The Gathering* cards in your site content. You can generate links to cards on [Scryfall](https://scryfall.com/) by using a simple `Liquid` tag.
4
+
5
+ ## Installation
6
+
7
+ Add `jekyll_mtg` to your `Gemfile`
8
+
9
+ ```
10
+ group :jekyll_plugins do
11
+ gem "jekyll_mtg"
12
+ end
13
+ ```
14
+
15
+ and run `bundle`. Then add it to your `_config.yml`.
16
+
17
+ ```
18
+ plugins:
19
+ - jekyll_mtg
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ### Link a Card
25
+
26
+ ```
27
+ # Link to any version of the named card.
28
+ {% link_card name="Obliterate" %}
29
+
30
+ # Or link to a specific version by including the set code.
31
+ {% link_card name="Obliterate" set="INV" %}
32
+
33
+ # Override the card name as the default contents of the anchor tag.
34
+ {% link_card name="Obliterate" set="INV" contents="Obliterate (the one with the good flavor text) %}
35
+ ```
36
+
37
+ ### Coming Soon
38
+
39
+ Embed a card image
40
+ Render a full deck list
41
+
42
+ ## Development
43
+
44
+ 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.
45
+
46
+ 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](https://rubygems.org).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MatthewSerre/jekyll_mtg.
51
+
52
+ ## License
53
+
54
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module JekyllMTG
4
+ VERSION = '1.0.0'
5
+ end
data/lib/jekyll_mtg.rb ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll'
4
+ require 'net/http'
5
+ require_relative 'utils'
6
+
7
+ module JekyllMTG
8
+ # Links cards
9
+ class LinkCard < Liquid::Tag
10
+ include Utils
11
+
12
+ def initialize(tag_name, card_info, tokens)
13
+ super
14
+
15
+ @card_info = card_info
16
+ end
17
+
18
+ attr_reader :card_info
19
+
20
+ def render(_context)
21
+ parsed_card_info = parse_card_info(card_info)
22
+ response = fetch_card(parsed_card_info)
23
+
24
+ text = parsed_card_info[:contents] || parsed_card_info[:card_name]
25
+ if response['scryfall_uri']
26
+ "<a href='#{response["scryfall_uri"]}'>#{text}</a>"
27
+ else
28
+ text
29
+ end
30
+ end
31
+ end
32
+ end
33
+
34
+ Liquid::Template.register_tag('link_card', JekyllMTG::LinkCard)
data/lib/utils.rb ADDED
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'jekyll_mtg/version'
4
+
5
+ module JekyllMTG
6
+ # Provides shared methods
7
+ module Utils
8
+ DEFAULT_REQUEST_FORMAT = 'json'
9
+ SCRYFALL_BASE_URI = 'https://api.scryfall.com/'
10
+ SCRYFALL_FUZZY_PATH = '/cards/named'
11
+
12
+ def parse_card_info(card_info)
13
+ args = {}
14
+
15
+ card_info.scan(/(\w+)="([^\"]*)"/) do |key, value|
16
+ args[key.to_sym] = value # Store as symbols for convenience
17
+ end
18
+
19
+ { card_name: args[:name], set_code: args[:set], contents: args[:contents] }
20
+ end
21
+
22
+ def fetch_card(parsed_card_info)
23
+ uri = URI(SCRYFALL_BASE_URI)
24
+ uri.path = SCRYFALL_FUZZY_PATH
25
+ params = { fuzzy: parsed_card_info[:card_name], set: parsed_card_info[:set_code], format: DEFAULT_REQUEST_FORMAT }
26
+ uri.query = URI.encode_www_form(params)
27
+ headers = { 'Accept' => 'application/json', 'User-Agent' => "JekyllMTG/#{JekyllMTG::VERSION}" }
28
+ response = Net::HTTP.get(uri, headers)
29
+ JSON.parse(response)
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,4 @@
1
+ module JekyllMTG
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jekyll_mtg
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Serre
8
+ bindir: exe
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: jekyll
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '0'
26
+ email:
27
+ - matthew.serre+github@gmail.com
28
+ executables: []
29
+ extensions: []
30
+ extra_rdoc_files: []
31
+ files:
32
+ - ".rspec"
33
+ - ".rubocop.yml"
34
+ - LICENSE
35
+ - README.md
36
+ - Rakefile
37
+ - lib/jekyll_mtg.rb
38
+ - lib/jekyll_mtg/version.rb
39
+ - lib/utils.rb
40
+ - sig/jekyll_mtg.rbs
41
+ homepage: https://github.com/MatthewSerre/jekyll_mtg
42
+ licenses:
43
+ - MIT
44
+ metadata:
45
+ allowed_push_host: https://rubygems.org
46
+ homepage_uri: https://github.com/MatthewSerre/jekyll_mtg
47
+ source_code_uri: https://github.com/MatthewSerre/jekyll_mtg
48
+ rubygems_mfa_required: 'true'
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 3.1.0
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubygems_version: 3.6.7
64
+ specification_version: 4
65
+ summary: 'A Jekyll plugin for adding Magic: The Gathering links, images, and decklists
66
+ via custom Liquid tags'
67
+ test_files: []