pax_global_header00006660000000000000000000000064140222235510014506gustar00rootroot0000000000000052 comment=272af47fce13f823d25f9896929d1251393aafd8 jekyll-remote-theme-0.4.3/000077500000000000000000000000001402222355100153755ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/.github/000077500000000000000000000000001402222355100167355ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/.github/CODEOWNERS000066400000000000000000000002461402222355100203320ustar00rootroot00000000000000# Require @benbalter's :+1: for changes to the .github repo-config files # mainly due to https://github.com/probot/settings privilege escalation .github/* @benbalter jekyll-remote-theme-0.4.3/.github/ISSUE_TEMPLATE/000077500000000000000000000000001402222355100211205ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/.github/ISSUE_TEMPLATE/bug_report.md000066400000000000000000000010071402222355100236100ustar00rootroot00000000000000--- name: Bug report about: Create a report to help us improve --- ### Describe the bug A clear and concise description of what the bug is. ### Steps to reproduce the behavior 1. Go to '...' 2. Click on '....' 3. Scroll down to '....' 4. See error ### Expected behavior A clear and concise description of what you expected to happen. ### Screenshots If applicable, add screenshots to help explain your problem. ### Additional context Add any other context about the problem here. jekyll-remote-theme-0.4.3/.github/ISSUE_TEMPLATE/feature_request.md000066400000000000000000000011541402222355100246460ustar00rootroot00000000000000--- name: Feature request about: Suggest an idea for this project --- ### Is your feature request related to a problem? Please describe the problem you're trying to solve. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] ### Describe the solution you'd like A clear and concise description of what you want to happen. ### Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered. ### Additional context Add any other context or screenshots about the feature request here. jekyll-remote-theme-0.4.3/.github/config.yml000066400000000000000000000034741402222355100207350ustar00rootroot00000000000000# Behaviorbot config. See https://github.com/behaviorbot/ for more information. # Note: Please Don't edit this file directly. # Edit https://github.com/benbalter/shared-community-files instead. # Configuration for update-docs - https://github.com/behaviorbot/update-docs updateDocsComment: "Thanks for the pull request! If you are making any changes to the user-facing functionality, please be sure to update the documentation in the `README` or `docs/` folder alongside your change. :heart:" # Configuration for request-info - https://github.com/behaviorbot/request-info requestInfoReplyComment: Thanks for this. Do you mind providing a bit more information about what problem you're trying to solve? requestInfoLabelToAdd: more-information-needed # Configuration for new-issue-welcome - https://github.com/behaviorbot/new-issue-welcome #newIssueWelcomeComment: > # Welcome! # Configuration for new-pr-welcome - https://github.com/behaviorbot/new-pr-welcome newPRWelcomeComment: Welcome! Congrats on your first pull request to Jekyll Remote Theme. If you haven't already, please be sure to check out [the contributing guidelines](https://github.com/benbalter/jekyll-remote-theme/blob/master/docs/CONTRIBUTING.md). # Configuration for first-pr-merge - https://github.com/behaviorbot/first-pr-merge firstPRMergeComment: "Congrats on getting your first pull request to Jekyll Remote Theme merged! Without amazing humans like you submitting pull requests, we couldn’t run this project. You rock! :tada:

If you're interested in tackling another bug or feature, take a look at [the open issues](https://github.com/benbalter/jekyll-remote-theme/issues), especially those [labeled `help wanted`](https://github.com/benbalter/jekyll-remote-theme/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22)." # Bug workaround contact_links: [] jekyll-remote-theme-0.4.3/.github/funding.yml000066400000000000000000000000231402222355100211050ustar00rootroot00000000000000patreon: benbalter jekyll-remote-theme-0.4.3/.github/no-response.yml000066400000000000000000000014631402222355100217340ustar00rootroot00000000000000# Configuration for probot-no-response - https://github.com/probot/no-response # Note: Please Don't edit this file directly. # Edit https://github.com/benbalter/shared-community-files instead. # Number of days of inactivity before an Issue is closed for lack of response daysUntilClose: 14 # Label requiring a response responseRequiredLabel: more-information-needed # Comment to post when closing an Issue for lack of response. Set to `false` to disable closeComment: > This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. jekyll-remote-theme-0.4.3/.github/release-drafter.yml000066400000000000000000000000541402222355100225240ustar00rootroot00000000000000template: | ## What's Changed $CHANGES jekyll-remote-theme-0.4.3/.github/settings.yml000066400000000000000000000015101402222355100213150ustar00rootroot00000000000000# Repository settings set via https://github.com/probot/settings # Note: Please Don't edit this file directly. # Edit https://github.com/benbalter/shared-community-files instead. repository: has_issues: true has_wiki: false has_projects: false has_downloads: false labels: - name: help wanted oldname: help-wanted color: 0e8a16 - name: more-information-needed color: d93f0b - name: bug color: b60205 - name: feature color: 1d76db - name: good first issue color: "5319e7" # Not currently implemented by probot/settings, but manually implemented in script/deploy branch_protection: restrictions: null enforce_admins: false required_status_checks: strict: true contexts: - "continuous-integration/travis-ci" required_pull_request_reviews: require_code_owner_reviews: true jekyll-remote-theme-0.4.3/.github/stale.yml000066400000000000000000000017121402222355100205710ustar00rootroot00000000000000# Configuration for probot-stale - https://github.com/probot/stale # Note: Please Don't edit this file directly. # Edit https://github.com/benbalter/shared-community-files instead. # Number of days of inactivity before an Issue or Pull Request becomes stale daysUntilStale: 60 # Number of days of inactivity before a stale Issue or Pull Request is closed daysUntilClose: 7 # Issues or Pull Requests with these labels will never be considered stale exemptLabels: - pinned - security # Label to use when marking as stale staleLabel: wontfix # Comment to post when marking as stale. Set to `false` to disable markComment: > This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. # Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable closeComment: false # Limit to only `issues` or `pulls` # only: issues jekyll-remote-theme-0.4.3/.gitignore000066400000000000000000000001121402222355100173570ustar00rootroot00000000000000Gemfile.lock spec/examples.txt *.gem tmp/ spec/fixtures/site/.jekyll-cachejekyll-remote-theme-0.4.3/.rspec000066400000000000000000000000261402222355100165100ustar00rootroot00000000000000--require spec_helper jekyll-remote-theme-0.4.3/.rubocop.yml000066400000000000000000000001531402222355100176460ustar00rootroot00000000000000require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: Exclude: - vendor/**/* jekyll-remote-theme-0.4.3/.travis.yml000066400000000000000000000002431402222355100175050ustar00rootroot00000000000000language: ruby cache: bundler sudo: false rvm: 2.5 install: script/bootstrap script: script/cibuild env: - JEKYLL_VERSION="~> 3.0" - JEKYLL_VERSION="~> 4.0" jekyll-remote-theme-0.4.3/Gemfile000066400000000000000000000003061402222355100166670ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] if ENV["JEKYLL_VERSION"] gem "jekyll-github-metadata", :github => "jekyll/github-metadata" jekyll-remote-theme-0.4.3/LICENSE000066400000000000000000000020531402222355100164020ustar00rootroot00000000000000MIT License Copyright (c) 2017 Ben Balter Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jekyll-remote-theme-0.4.3/README.md000066400000000000000000000043271402222355100166620ustar00rootroot00000000000000# Jekyll Remote Theme Jekyll plugin for building Jekyll sites with any public GitHub-hosted theme [![Gem Version](https://badge.fury.io/rb/jekyll-remote-theme.svg)](https://badge.fury.io/rb/jekyll-remote-theme) [![Build Status](https://travis-ci.org/benbalter/jekyll-remote-theme.svg?branch=master)](https://travis-ci.org/benbalter/jekyll-remote-theme) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com) ## Usage 1. Add the following to your Gemfile ```ruby gem "jekyll-remote-theme" ``` and run `bundle install` to install the plugin 2. Add the following to your site's `_config.yml` to activate the plugin ```yml plugins: - jekyll-remote-theme ``` Note: If you are using a Jekyll version less than 3.5.0, use the `gems` key instead of `plugins`. 3. Add the following to your site's `_config.yml` to choose your theme ```yml remote_theme: benbalter/retlab ``` or 1 ```yml remote_theme: http[s]://github..com/benbalter/retlab ``` 1 The codeload subdomain needs to be available on your github enterprise instance for this to work. ## Declaring your theme Remote themes are specified by the `remote_theme` key in the site's config. For public GitHub, remote themes must be in the form of `OWNER/REPOSITORY`, and must represent a public GitHub-hosted Jekyll theme. See [the Jekyll documentation](https://jekyllrb.com/docs/themes/) for more information on authoring a theme. Note that you do not need to upload the gem to RubyGems or include a `.gemspec` file. You may also optionally specify a branch, tag, or commit to use by appending an `@` and the Git ref (e.g., `benbalter/retlab@v1.0.0` or `benbalter/retlab@develop`). If you don't specify a Git ref, the `HEAD` ref will be used. For Enterprise GitHub, remote themes must be in the form of `http[s]://GITHUBHOST.com/OWNER/REPOSITORY`, and must represent a public (non-private repository) GitHub-hosted Jekyll theme. Other than requiring the fully qualified domain name of the enterprise GitHub instance, this works exactly the same as the public usage. ## Debugging Adding `--verbose` to the `build` or `serve` command may provide additional information. jekyll-remote-theme-0.4.3/docs/000077500000000000000000000000001402222355100163255ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/docs/CODE_OF_CONDUCT.md000066400000000000000000000062131402222355100211260ustar00rootroot00000000000000# Contributor Covenant Code of Conduct ## Our Pledge In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. ## Our Standards Examples of behavior that contributes to creating a positive environment include: * Using welcoming and inclusive language * Being respectful of differing viewpoints and experiences * Gracefully accepting constructive criticism * Focusing on what is best for the community * Showing empathy towards other community members Examples of unacceptable behavior by participants include: * The use of sexualized language or imagery and unwelcome sexual attention or advances * Trolling, insulting/derogatory comments, and personal or political attacks * Public or private harassment * Publishing others' private information, such as a physical or electronic address, without explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Our Responsibilities Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. ## Scope This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at ben@balter.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. ## Attribution This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org [version]: http://contributor-covenant.org/version/1/4/ jekyll-remote-theme-0.4.3/docs/CONTRIBUTING.md000066400000000000000000000132741402222355100205650ustar00rootroot00000000000000# Contributing to Jekyll Remote Theme Hi there! We're thrilled that you'd like to contribute to Jekyll Remote Theme. Your help is essential for keeping it great. Jekyll Remote Theme is an open source project supported by the efforts of an entire community and built one contribution at a time by users like you. We'd love for you to get involved. Whatever your level of skill or however much time you can give, your contribution is greatly appreciated. There are many ways to contribute, from writing tutorials or blog posts, improving the documentation, submitting bug reports and feature requests, helping other users by commenting on issues, or writing code which can be incorporated into Jekyll Remote Theme itself. Following these guidelines helps to communicate that you respect the time of the developers managing and developing this open source project. In return, they should reciprocate that respect in addressing your issue, assessing changes, and helping you finalize your pull requests. ## How to report a bug Think you found a bug? Please check [the list of open issues](https://github.com/benbalter/jekyll-remote-theme/issues) to see if your bug has already been reported. If it hasn't please [submit a new issue](https://github.com/benbalter/jekyll-remote-theme/issues/new). Here are a few tips for writing *great* bug reports: * Describe the specific problem (e.g., "widget doesn't turn clockwise" versus "getting an error") * Include the steps to reproduce the bug, what you expected to happen, and what happened instead * Check that you are using the latest version of the project and its dependencies * Include what version of the project your using, as well as any relevant dependencies * Only include one bug per issue. If you have discovered two bugs, please file two issues * Include screenshots or screencasts whenever possible * Even if you don't know how to fix the bug, including a failing test may help others track it down **If you find a security vulnerability, do not open an issue. Please email ben@balter.com instead.** ## How to suggest a feature or enhancement If you find yourself wishing for a feature that doesn't exist in Jekyll Remote Theme, you are probably not alone. There are bound to be others out there with similar needs. Many of the features that Jekyll Remote Theme has today have been added because our users saw the need. Feature requests are welcome. But take a moment to find out whether your idea fits with the scope and goals of the project. It's up to you to make a strong case to convince the project's developers of the merits of this feature. Please provide as much detail and context as possible, including describing the problem you're trying to solve. [Open an issue](https://github.com/benbalter/jekyll-remote-theme/issues/new) which describes the feature you would like to see, why you want it, how it should work, etc. ## Your first contribution We'd love for you to contribute to the project. Unsure where to begin contributing to Jekyll Remote Theme? You can start by looking through these "good first issue" and "help wanted" issues: * [Good first issues](https://github.com/benbalter/jekyll-remote-theme/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22) - issues which should only require a few lines of code and a test or two * [Help wanted issues](https://github.com/benbalter/jekyll-remote-theme/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) - issues which may be a bit more involved, but are specifically seeking community contributions *p.s. Feel free to ask for help; everyone is a beginner at first* :smiley_cat: ## How to propose changes Here's a few general guidelines for proposing changes: * If you are changing any user-facing functionality, please be sure to update the documentation * If you are adding a new behavior or changing an existing behavior, please be sure to update the corresponding test(s) * Each pull request should implement **one** feature or bug fix. If you want to add or fix more than one thing, submit more than one pull request * Do not commit changes to files that are irrelevant to your feature or bug fix * Don't bump the version number in your pull request (it will be bumped prior to release) * Write [a good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) At a high level, [the process for proposing changes](https://guides.github.com/introduction/flow/) is: 1. [Fork](https://github.com/benbalter/jekyll-remote-theme/fork) and clone the project 2. Configure and install the dependencies: `script/bootstrap` 3. Make sure the tests pass on your machine: `script/cibuild` 4. Create a descriptively named branch: `git checkout -b my-branch-name` 5. Make your change, add tests and documentation, and make sure the tests still pass 6. Push to your fork and [submit a pull request](https://github.com/benbalter/jekyll-remote-theme/compare) describing your change 7. Pat your self on the back and wait for your pull request to be reviewed and merged **Interesting in submitting your first Pull Request?** It's easy! You can learn how from this *free* series [How to Contribute to an Open Source Project on GitHub](https://egghead.io/series/how-to-contribute-to-an-open-source-project-on-github) ## Bootstrapping your local development environment `script/bootstrap` ## Running tests `script/cibuild` ## Code of conduct This project is governed by [the Contributor Covenant Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. ## Additional Resources * [Contributing to Open Source on GitHub](https://guides.github.com/activities/contributing-to-open-source/) * [Using Pull Requests](https://help.github.com/articles/using-pull-requests/) * [GitHub Help](https://help.github.com) jekyll-remote-theme-0.4.3/docs/SECURITY.md000066400000000000000000000001551402222355100201170ustar00rootroot00000000000000# Security Policy To report a security vulnerability, please email [ben@balter.com](mailto:ben@balter.com). jekyll-remote-theme-0.4.3/jekyll-remote-theme.gemspec000066400000000000000000000024431402222355100226300ustar00rootroot00000000000000# frozen_string_literal: true $LOAD_PATH.unshift File.expand_path("lib", __dir__) require "jekyll-remote-theme/version" Gem::Specification.new do |s| s.name = "jekyll-remote-theme" s.version = Jekyll::RemoteTheme::VERSION s.authors = ["Ben Balter"] s.email = ["ben.balter@github.com"] s.homepage = "https://github.com/benbalter/jekyll-remote-theme" s.summary = "Jekyll plugin for building Jekyll sites with any GitHub-hosted theme" s.files = `git ls-files app lib`.split("\n") s.require_paths = ["lib"] s.license = "MIT" s.add_dependency "addressable", "~> 2.0" s.add_dependency "jekyll", ">= 3.5", "< 5.0" s.add_dependency "jekyll-sass-converter", ">= 1.0", "<= 3.0.0", "!= 2.0.0" s.add_dependency "rubyzip", ">= 1.3.0", "< 3.0" s.add_development_dependency "jekyll-theme-primer", "~> 0.5" s.add_development_dependency "jekyll_test_plugin_malicious", "~> 0.2" s.add_development_dependency "kramdown-parser-gfm", "~> 1.0" s.add_development_dependency "pry", "~> 0.11" s.add_development_dependency "rspec", "~> 3.0" s.add_development_dependency "rubocop", "~> 0.71" s.add_development_dependency "rubocop-jekyll", "~> 0.10" s.add_development_dependency "webmock", "~> 3.0" s.required_ruby_version = ">= 2.3.0" end jekyll-remote-theme-0.4.3/lib/000077500000000000000000000000001402222355100161435ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme.rb000066400000000000000000000014771402222355100223640ustar00rootroot00000000000000# frozen_string_literal: true require "jekyll" require "fileutils" require "tempfile" require "addressable" require "net/http" require "zip" $LOAD_PATH.unshift(File.dirname(__FILE__)) module Jekyll module RemoteTheme class DownloadError < StandardError; end autoload :Downloader, "jekyll-remote-theme/downloader" autoload :MockGemspec, "jekyll-remote-theme/mock_gemspec" autoload :Munger, "jekyll-remote-theme/munger" autoload :Theme, "jekyll-remote-theme/theme" autoload :VERSION, "jekyll-remote-theme/version" CONFIG_KEY = "remote_theme" LOG_KEY = "Remote Theme:" TEMP_PREFIX = "jekyll-remote-theme-" def self.init(site) Munger.new(site).munge! end end end Jekyll::Hooks.register :site, :after_reset do |site| Jekyll::RemoteTheme.init(site) end jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/000077500000000000000000000000001402222355100220265ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/downloader.rb000066400000000000000000000067741402222355100245270ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module RemoteTheme class Downloader PROJECT_URL = "https://github.com/benbalter/jekyll-remote-theme" USER_AGENT = "Jekyll Remote Theme/#{VERSION} (+#{PROJECT_URL})" MAX_FILE_SIZE = 1 * (1024 * 1024 * 1024) # Size in bytes (1 GB) NET_HTTP_ERRORS = [ Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::OpenTimeout, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError, ].freeze def initialize(theme) @theme = theme end def run if downloaded? Jekyll.logger.debug LOG_KEY, "Using existing #{theme.name_with_owner}" return end download unzip end def downloaded? @downloaded ||= theme_dir_exists? && !theme_dir_empty? end private attr_reader :theme def zip_file @zip_file ||= Tempfile.new([TEMP_PREFIX, ".zip"], :binmode => true) end def download Jekyll.logger.debug LOG_KEY, "Downloading #{zip_url} to #{zip_file.path}" Net::HTTP.start(zip_url.host, zip_url.port, :use_ssl => true) do |http| http.request(request) do |response| raise_unless_sucess(response) enforce_max_file_size(response.content_length) response.read_body do |chunk| zip_file.write chunk end end end @downloaded = true rescue *NET_HTTP_ERRORS => e raise DownloadError, e.message end def request return @request if defined? @request @request = Net::HTTP::Get.new zip_url.request_uri @request["User-Agent"] = USER_AGENT @request end def raise_unless_sucess(response) return if response.is_a?(Net::HTTPSuccess) raise DownloadError, "#{response.code} - #{response.message} - Loading URL: #{zip_url}" end def enforce_max_file_size(size) return unless size && size > MAX_FILE_SIZE raise DownloadError, "Maximum file size of #{MAX_FILE_SIZE} bytes exceeded" end def unzip Jekyll.logger.debug LOG_KEY, "Unzipping #{zip_file.path} to #{theme.root}" # File IO is already open, rewind pointer to start of file to read zip_file.rewind Zip::File.open(zip_file) do |archive| archive.each { |file| file.extract path_without_name_and_ref(file.name) } end ensure zip_file.close zip_file.unlink end # Full URL to codeload zip download endpoint for the given theme def zip_url @zip_url ||= Addressable::URI.new( :scheme => theme.scheme, :host => "codeload.#{theme.host}", :path => [theme.owner, theme.name, "zip", theme.git_ref].join("/") ).normalize end def theme_dir_exists? theme.root && Dir.exist?(theme.root) end def theme_dir_empty? Dir["#{theme.root}/*"].empty? end # Codeload generated zip files contain a top level folder in the form of # THEME_NAME-GIT_REF/. While requests for Git repos are case insensitive, # the zip subfolder will respect the case in the repository's name, thus # making it impossible to predict the true path to the theme. In case we're # on a case-sensitive file system, strip the parent folder from all paths. def path_without_name_and_ref(path) Jekyll.sanitized_path theme.root, path.split("/").drop(1).join("/") end end end end jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/mock_gemspec.rb000066400000000000000000000026251402222355100250140ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module RemoteTheme # Jekyll::Theme expects the theme's gemspec to tell it things like # the path to the theme and runtime dependencies. MockGemspec serves as a # stand in, since remote themes don't need Gemspecs class MockGemspec extend Forwardable def_delegator :theme, :root, :full_gem_path DEPENDENCY_PREFIX = %r!^\s*[a-z]+\.add_(?:runtime_)?dependency!.freeze DEPENDENCY_REGEX = %r!#{DEPENDENCY_PREFIX}\(?\s*["']([a-z_-]+)["']!.freeze def initialize(theme) @theme = theme end def runtime_dependencies @runtime_dependencies ||= dependency_names.map do |name| Gem::Dependency.new(name) end end private def contents @contents ||= File.read(path, :encoding => "utf-8") if path end def path @path ||= potential_paths.find { |path| File.exist? path } end def potential_paths [theme.name, "jekyll-theme-#{theme.name}"].map do |filename| File.expand_path "#{filename}.gemspec", theme.root end end def dependency_names @dependency_names ||= if contents contents.scan(DEPENDENCY_REGEX).flatten else [] end end attr_reader :theme end end end jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/munger.rb000066400000000000000000000026411402222355100236530ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module RemoteTheme class Munger extend Forwardable def_delegator :site, :config attr_reader :site def initialize(site) @site = site end def munge! return unless raw_theme unless theme.valid? Jekyll.logger.error LOG_KEY, "#{raw_theme.inspect} is not a valid remote theme" return end Jekyll.logger.info LOG_KEY, "Using theme #{theme.name_with_owner}" unless munged? downloader.run configure_theme end enqueue_theme_cleanup theme end private def munged? site.theme&.is_a?(Jekyll::RemoteTheme::Theme) end def theme @theme ||= Theme.new(raw_theme) end def raw_theme config[CONFIG_KEY] end def downloader @downloader ||= Downloader.new(theme) end def configure_theme return unless theme site.config["theme"] = theme.name site.theme = theme site.theme.configure_sass if site.theme.respond_to?(:configure_sass) site.send(:configure_include_paths) site.plugin_manager.require_theme_deps end def enqueue_theme_cleanup at_exit do Jekyll.logger.debug LOG_KEY, "Cleaning up #{theme.root}" FileUtils.rm_rf theme.root end end end end end jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/theme.rb000066400000000000000000000051571402222355100234650ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module RemoteTheme class Theme < Jekyll::Theme OWNER_REGEX = %r!(?[a-z0-9\-]+)!i.freeze NAME_REGEX = %r!(?[a-z0-9\._\-]+)!i.freeze REF_REGEX = %r!@(?[a-z0-9\._\-]+)!i.freeze # May be a branch, tag, or commit THEME_REGEX = %r!\A#{OWNER_REGEX}/#{NAME_REGEX}(?:#{REF_REGEX})?\z!i.freeze # Initializes a new Jekyll::RemoteTheme::Theme # # raw_theme can be in the form of: # # 1. owner/theme-name - a GitHub owner + theme-name string # 2. owner/theme-name@git_ref - a GitHub owner + theme-name + Git ref string # 3. http[s]://github..com/owner/theme-name # - An enterprise GitHub instance + a GitHub owner + a theme-name string # 4. http[s]://github..com/owner/theme-name@git_ref # - An enterprise GitHub instance + a GitHub owner + a theme-name + Git ref string def initialize(raw_theme) @raw_theme = raw_theme.to_s.downcase.strip super(@raw_theme) end def name theme_parts[:name] end def owner theme_parts[:owner] end def host uri&.host end def scheme uri&.scheme end def name_with_owner [owner, name].join("/") end alias_method :nwo, :name_with_owner def valid? return false unless uri && theme_parts && name && owner host && valid_hosts.include?(host) end def git_ref theme_parts[:ref] || "HEAD" end def root @root ||= File.realpath Dir.mktmpdir(TEMP_PREFIX) end def inspect "#" end private def uri return @uri if defined? @uri @uri = if THEME_REGEX.match?(@raw_theme) Addressable::URI.new( :scheme => "https", :host => "github.com", :path => @raw_theme ) else Addressable::URI.parse @raw_theme end rescue Addressable::URI::InvalidURIError @uri = nil end def theme_parts @theme_parts ||= uri.path[1..-1].match(THEME_REGEX) if uri end def gemspec @gemspec ||= MockGemspec.new(self) end def valid_hosts @valid_hosts ||= [ "github.com", ENV["PAGES_GITHUB_HOSTNAME"], ENV["GITHUB_HOSTNAME"], ].compact.to_set end end end end jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/version.rb000066400000000000000000000001421402222355100240350ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll module RemoteTheme VERSION = "0.4.3" end end jekyll-remote-theme-0.4.3/script/000077500000000000000000000000001402222355100167015ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/script/bootstrap000077500000000000000000000000321402222355100206370ustar00rootroot00000000000000#!/bin/sh bundle install jekyll-remote-theme-0.4.3/script/cibuild000077500000000000000000000001371402222355100202430ustar00rootroot00000000000000#!/bin/sh set -e bundle exec rspec bundle exec rubocop gem build jekyll-remote-theme.gemspec jekyll-remote-theme-0.4.3/script/console000077500000000000000000000000751402222355100202730ustar00rootroot00000000000000#!/bin/sh bundle exec pry -r './lib/jekyll-remote-theme.rb' jekyll-remote-theme-0.4.3/spec/000077500000000000000000000000001402222355100163275ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/fixtures/000077500000000000000000000000001402222355100202005ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/fixtures/gemspecs/000077500000000000000000000000001402222355100220065ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/fixtures/gemspecs/alldeps.gemspec000066400000000000000000000010571402222355100250020ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "alldeps/version" Gem::Specification.new do |s| s.name = "alldeps" s.version = AllDeps::VERSION s.authors = ["John Doe"] s.summary = "Dummy gemspec" # runtime dependencies s.add_dependency "jekyll", "~> 3.5" s.add_dependency "jekyll-feed", "~> 0.6" s.add_dependency "jekyll-sitemap", "~> 1.5" # development dependencies s.add_dependency "bundler", "~> 1.12" s.add_dependency "rake", "~> 10.0" end jekyll-remote-theme-0.4.3/spec/fixtures/gemspecs/braces.gemspec000066400000000000000000000012341402222355100246120ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "braces/version" Gem::Specification.new do |s| s.name = "braces" s.version = Braces::VERSION s.authors = ["John Doe"] s.summary = "Dummy gemspec" # rubocop:disable Style/StringLiterals # runtime dependencies s.add_dependency('jekyll', "~> 3.5") s.add_dependency('jekyll-feed', "~> 0.6") s.add_dependency('jekyll-sitemap', "~> 1.5") # development dependencies s.add_dependency('bundler', "~> 1.12") s.add_dependency('rake', "~> 10.0") # rubocop:enable Style/StringLiterals end jekyll-remote-theme-0.4.3/spec/fixtures/gemspecs/nodeps.gemspec000066400000000000000000000006221402222355100246430ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "nodeps/version" Gem::Specification.new do |s| s.name = "nodeps" s.version = Lorem::VERSION s.authors = ["John Doe"] s.summary = "Dummy gemspec" s.add_development_dependency("bundler", "~> 1.12") s.add_development_dependency("rake", "~> 10.0") end jekyll-remote-theme-0.4.3/spec/fixtures/gemspecs/rundev.gemspec000066400000000000000000000011341402222355100246550ustar00rootroot00000000000000# frozen_string_literal: true lib = File.expand_path("lib", __dir__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "rundev/version" Gem::Specification.new do |spec| spec.name = "rundev" spec.version = RunDev::VERSION spec.authors = ["John Doe"] spec.summary = "Dummy gemspec" spec.add_runtime_dependency "jekyll", "~> 3.5" spec.add_runtime_dependency "jekyll-feed", "~> 0.6" # some "random" comment spec.add_runtime_dependency "jekyll-sitemap", "~> 1.5" spec.add_development_dependency "bundler", "~> 1.12" spec.add_development_dependency "rake", "~> 10.0" end jekyll-remote-theme-0.4.3/spec/fixtures/site-without-theme/000077500000000000000000000000001402222355100237455ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/fixtures/site-without-theme/index.md000066400000000000000000000000361402222355100253750ustar00rootroot00000000000000--- --- # Site without theme jekyll-remote-theme-0.4.3/spec/fixtures/site/000077500000000000000000000000001402222355100211445ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/fixtures/site/_config.yml000066400000000000000000000002261402222355100232730ustar00rootroot00000000000000plugins: - jekyll-remote-theme remote_theme: pages-themes/PrImeR whitelist: - jekyll-remote-theme - jekyll-seo-tag - jekyll-github-metadata jekyll-remote-theme-0.4.3/spec/fixtures/site/_malicious_config.yml000066400000000000000000000002451402222355100253410ustar00rootroot00000000000000plugins: - jekyll-remote-theme remote_theme: jekyll/jekyll-test-theme-malicious whitelist: - jekyll-remote-theme - jekyll-seo-tag - jekyll-github-metadata jekyll-remote-theme-0.4.3/spec/fixtures/site/index.md000066400000000000000000000000501402222355100225700ustar00rootroot00000000000000--- layout: default --- # Fixture site jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/000077500000000000000000000000001402222355100222125ustar00rootroot00000000000000jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/downloader_spec.rb000066400000000000000000000054771402222355100257240ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::RemoteTheme::Downloader do let(:raw_theme) { "pages-themes/primer" } let(:theme) { Jekyll::RemoteTheme::Theme.new(raw_theme) } subject { described_class.new(theme) } before { reset_tmp_dir } it "knows it's not downloaded" do expect(subject.downloaded?).to be_falsy end it "creates a zip file" do expect(subject.send(:zip_file)).to be_an_existing_file end context "downloading" do before { subject.run } after { FileUtils.rm_rf theme.root if Dir.exist?(theme.root) } it "knows it's downloaded" do expect(subject.downloaded?).to be_truthy end it "extracts the theme" do expect("#{theme.root}/_layouts/default.html").to be_an_existing_file end it "deletes the zip file" do expect(subject.send(:zip_file).path).to be_nil end it "knows the theme dir exists" do expect(subject.send(:theme_dir_exists?)).to be_truthy end it "knows the theme dir isn't empty" do expect(subject.send(:theme_dir_empty?)).to be_falsy end end context "zip_url" do it "builds the zip url" do expected = "https://codeload.github.com/pages-themes/primer/zip/HEAD" expect(subject.send(:zip_url).to_s).to eql(expected) end context "a custom host" do let(:raw_theme) { "http://example.com/pages-themes/primer" } it "builds the zip url" do expected = "http://codeload.example.com/pages-themes/primer/zip/HEAD" expect(subject.send(:zip_url).to_s).to eql(expected) end end end context "with zip_url stubbed" do before { allow(subject).to receive(:zip_url) { Addressable::URI.parse zip_url } } context "with an invalid URL" do let(:zip_url) { "https://codeload.github.com/benbalter/_invalid_/zip/HEAD" } before do WebMock.disable_net_connect! stub_request(:get, zip_url).to_return(:status => [404, "Not Found"]) end after { WebMock.allow_net_connect! } it "raises a DownloadError" do msg = "404 - Not Found - Loading URL: https://codeload.github.com/benbalter/_invalid_/zip/HEAD" expect { subject.run }.to raise_error(Jekyll::RemoteTheme::DownloadError, msg) end end context "with a large file" do let(:zip_url) { "https://codeload.github.com/benbalter/_invalid_/zip/HEAD" } let(:content_length) { 10 * 1024 * 1024 * 1024 } let(:headers) { { "Content-Length" => content_length } } before do WebMock.disable_net_connect! stub_request(:get, zip_url).to_return(:headers => headers) end after { WebMock.allow_net_connect! } it "raises a DownloadError" do msg = "Maximum file size of 1073741824 bytes exceeded" expect { subject.run }.to raise_error(Jekyll::RemoteTheme::DownloadError, msg) end end end end jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/integration_spec.rb000066400000000000000000000052531402222355100261010ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe "Jekyll::RemoteTheme Integration" do attr_reader :output, :status def config_path File.join source_dir, "_config.yml" end def malicious_config_path File.join source_dir, "_malicious_config.yml" end def args(config_path) [ "bundle", "exec", "jekyll", "build", "--config", config_path, "--source", source_dir, "--dest", dest_dir, "--verbose", "--safe", ] end def build_site(config_path) Dir.chdir tmp_dir do @output, @status = Open3.capture2e(*args(config_path)) @output = @output.encode("UTF-8", :invalid => :replace, :undef => :replace, :replace => "") end end let(:theme) { "pages-themes/primer" } let(:index_path) { File.join dest_dir, "index.html" } let(:index_contents) { File.read(index_path) } let(:stylesheet_path) { File.join dest_dir, "assets", "css", "style.css" } context "the pages-themes/primer theme" do before(:all) { reset_tmp_dir } before(:all) { build_site(config_path) } after(:all) { reset_tmp_dir } it "returns a zero exit code" do expect(status.exitstatus).to eql(0), output end it "outputs that it's using a remote theme" do expect(output).to match("Remote Theme: Using theme #{theme}") end it "build the index" do expect(index_path).to be_an_existing_file end it "uses the theme" do expected = '
' expect(index_contents).to match(expected) end it "builds stylesheets" do expect(stylesheet_path).to be_an_existing_file end it "requires dependencies" do expect(output).to include("Requiring: jekyll-seo-tag") expect(index_contents).to include("Begin Jekyll SEO tag") end end context "the jekyll/jekyll-test-theme-malicious theme" do let(:theme) { "jekyll/jekyll-test-theme-malicious" } before(:all) { reset_tmp_dir } before(:all) { build_site(malicious_config_path) } after(:all) { reset_tmp_dir } it "returns a zero exit code" do expect(status.exitstatus).to eql(0), output end it "outputs that it's using a remote theme" do expect(output).to match("Remote Theme: Using theme #{theme}") end it "build the index" do expect(index_path).to be_an_existing_file end it "uses the theme" do expect(index_contents).to include("Begin Jekyll SEO tag") end it "requires whitelisted dependencies" do expect(output).to include("Requiring: jekyll-seo-tag") end it "dosn't requires unsafe dependencies" do expect(output).to_not include("jekyll_test_plugin_malicious"), output end end end jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/mock_gemspec_spec.rb000066400000000000000000000036021402222355100262060ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::RemoteTheme::MockGemspec do let(:fixture) { "alldeps" } let(:contents) { File.read gemspec_dir("#{fixture}.gemspec") } let(:filename) { "#{theme.name}.gemspec" } let(:path) { File.expand_path filename, theme.root } let(:nwo) { "pages-themes/primer" } let(:theme) { Jekyll::RemoteTheme::Theme.new(nwo) } subject { described_class.new(theme) } before { File.write path, contents } it "stores the theme" do expect(subject.send(:theme)).to eql(theme) end it "determines the path" do expect(subject.send(:path)).to eql(path) end it "reads the contents" do expect(subject.send(:contents)).to eql(contents) end it "builds potential_paths" do expect(subject.send(:potential_paths)).to include(path) end it "returns the theme root" do expect(subject.full_gem_path).to eql(theme.root) end context "fixtures" do let(:dependency_names) { subject.send(:dependency_names) } let(:runtime_dependencies) { subject.runtime_dependencies } # Hash in the form of gemspec fixture => expected dependencies { "alldeps" => %w(jekyll jekyll-feed jekyll-sitemap bundler rake), "braces" => %w(jekyll jekyll-feed jekyll-sitemap bundler rake), "rundev" => %w(jekyll jekyll-feed jekyll-sitemap), "nodeps" => [], }.each do |fixture, expected| context "the #{fixture} gemspec" do let(:fixture) { fixture } it "returns dependency names" do expect(dependency_names).to eql(expected) end it "returns #{expected.count} runtime dependencies" do expect(runtime_dependencies.count).to eql(expected.count) unless expected.empty? expect(runtime_dependencies.first).to be_a(Gem::Dependency) expect(runtime_dependencies.map(&:name)).to eql(expected) end end end end end end jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/munger_spec.rb000066400000000000000000000077061402222355100250600ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::RemoteTheme::Munger do let(:source) { source_dir } let(:overrides) { {} } let(:config) { { "source" => source, "safe" => true }.merge(overrides) } let(:site) { make_site(config) } let(:theme_dir) { theme&.root } let(:layout_path) { File.expand_path "_layouts/default.html", theme_dir } let(:sass_dir) { File.expand_path "_sass/", theme_dir } let(:sass_path) { File.expand_path "jekyll-theme-primer.scss", sass_dir } let(:includes_dir) { File.expand_path "_includes/", theme_dir } let(:theme) { subject.send(:theme) } subject { described_class.new(site) } before { Jekyll.logger.log_level = :error } before { reset_tmp_dir } # Remove :after_reset hook to allow themes to be stubbed prior to munging before(:each) do hooks = Jekyll::Hooks.instance_variable_get("@registry") hooks[:site][:after_reset] = [] Jekyll::Hooks.instance_variable_set("@registry", hooks) end it "stores the site" do expect(subject.site).to be_a(Jekyll::Site) end context "without a theme" do let(:source) { fixture_path("site-without-theme") } it "doesn't set a theme" do expect(site.theme).to_not be_a(Jekyll::RemoteTheme::Theme) end it "doesn't clone" do expect(layout_path).to_not be_an_existing_file end end context "with theme as a hash" do let(:overrides) { { "remote_theme" => { "foo" => "bar" } } } before { subject.munge! } it "doesn't set a theme" do expect(site.theme).to_not be_a(Jekyll::RemoteTheme::Theme) end it "doesn't clone" do expect(layout_path).to_not be_an_existing_file end end context "with a remote theme" do let(:overrides) { { "remote_theme" => "pages-themes/primer" } } before do @old_logger = Jekyll.logger @stubbed_logger = StringIO.new Jekyll.logger = Logger.new(@stubbed_logger) Jekyll.logger.log_level = :debug end before { subject.munge! } after { Jekyll.instance_variable_set("@logger", @old_logger) } it "sets the theme" do expect(site.theme).to be_a(Jekyll::RemoteTheme::Theme) expect(site.theme.name).to eql("primer") expect(site.config["theme"]).to eql("primer") end it "downloads" do expect(layout_path).to be_an_existing_file end it "sets sass paths" do expect(sass_path).to be_an_existing_file if Jekyll::VERSION >= "4.0" converter = Jekyll::Converters::Scss.new(site.config) expect(converter.sass_configs[:load_paths]).to include(sass_dir) else expect(Sass.load_paths).to include(sass_dir) end end it "sets include paths" do expect(site.includes_load_paths).to include(includes_dir) end it "sets layouts" do site.read expect(site.layouts["default"]).to be_truthy expect(site.layouts["default"].path).to eql(layout_path) end it "requires plugins" do @stubbed_logger.rewind expect(@stubbed_logger.read).to include("Requiring: jekyll-seo-tag") end end context "with a malicious theme" do let(:overrides) { { "remote_theme" => "jekyll/jekyll-test-theme-malicious" } } before do @old_logger = Jekyll.logger @stubbed_logger = StringIO.new Jekyll.logger = Logger.new(@stubbed_logger) Jekyll.logger.log_level = :debug end before { subject.munge! } after { Jekyll.instance_variable_set("@logger", @old_logger) } it "sets the theme" do expect(site.theme).to be_a(Jekyll::RemoteTheme::Theme) expect(site.theme.name).to eql("jekyll-test-theme-malicious") expect(site.config["theme"]).to eql("jekyll-test-theme-malicious") end it "requires whitelisted plugins" do @stubbed_logger.rewind expect(@stubbed_logger.read).to include("Requiring: jekyll-seo-tag") end it "doesn't require malicious plugins" do @stubbed_logger.rewind expect(@stubbed_logger.read).to_not include("jekyll_test_plugin_malicious") end end end jekyll-remote-theme-0.4.3/spec/jekyll-remote-theme/theme_spec.rb000066400000000000000000000071211402222355100246540ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::RemoteTheme::Theme do let(:scheme) { nil } let(:host) { nil } let(:owner) { "foo" } let(:name) { "bar" } let(:nwo) { "#{owner}/#{name}" } let(:git_ref) { nil } let(:raw_theme) do raw_theme = +"" raw_theme << "#{scheme}://#{host}/" if scheme && host raw_theme << nwo.to_s raw_theme << "@#{git_ref}" if git_ref raw_theme end subject { described_class.new(raw_theme) } it "stores the theme" do expect(subject.instance_variable_get("@raw_theme")).to eql(nwo) end context "with an abnormal NWO" do let(:nwo) { " FoO/bAr " } it "normalizes the nwo" do expect(subject.instance_variable_get("@raw_theme")).to eql("foo/bar") end end it "extracts the name" do expect(subject.name).to eql(name) end it "extracts the owner" do expect(subject.owner).to eql(owner) end it "uses the default host" do expect(subject.host).to eql("github.com") end it "uses the default scheme" do expect(subject.scheme).to eql("https") end it "builds the name with owner" do expect(subject.name_with_owner).to eql(nwo) expect(subject.nwo).to eql(nwo) end it "knows it's valid" do expect(subject).to be_valid end context "a random string" do let(:nwo) { "foo" } it "isn't valid" do expect(subject).to_not be_valid end end context "with a non-string" do let(:nwo) { [1, 2] } it "isn't valid" do expect(subject).to_not be_valid end end context "with a non-nwo string" do let(:nwo) { "foo/javascript: alert(1);" } it "isn't valid" do expect(subject).to_not be_valid end end it "defaults git_ref to HEAD" do expect(subject.git_ref).to eql("HEAD") end context "with a git_ref" do let(:git_ref) { "foo" } it "parses the git ref" do expect(subject.git_ref).to eql(git_ref) end end it "knows its root" do expect(Dir.exist?(subject.root)).to be_truthy end it "exposes gemspec" do expect(subject.send(:gemspec)).to be_a(Jekyll::RemoteTheme::MockGemspec) end context "a full URL" do let(:host) { "github.com" } let(:scheme) { "https" } it "extracts the name" do expect(subject.name).to eql(name) end it "extracts the owner" do expect(subject.owner).to eql(owner) end it "extracts the host" do expect(subject.host).to eql("github.com") end it "extracts the scheme" do expect(subject.scheme).to eql("https") end it "is valid" do with_env "GITHUB_HOSTNAME", "enterprise.github.com" do expect(subject).to be_valid end end context "a custom host" do let(:host) { "example.com" } let(:scheme) { "http" } it "extracts the name" do expect(subject.name).to eql(name) end it "extracts the owner" do expect(subject.owner).to eql(owner) end it "extracts the host" do expect(subject.host).to eql(host) end it "extracts the scheme" do expect(subject.scheme).to eql(scheme) end it "is valid if a whitelisted host name" do with_env "GITHUB_HOSTNAME", "example.com" do expect(subject).to be_valid end end it "is invalid if not a whitelisted host name" do with_env "GITHUB_HOSTNAME", "enterprise.github.com" do expect(subject).to_not be_valid end end context "with a git ref" do let(:git_ref) { "foo" } it "parses the git ref" do expect(subject.git_ref).to eql(git_ref) end end end end end jekyll-remote-theme-0.4.3/spec/jekyll_remote_theme_spec.rb000066400000000000000000000010341402222355100237130ustar00rootroot00000000000000# frozen_string_literal: true RSpec.describe Jekyll::RemoteTheme do let(:source) { source_dir } let(:config) { { "source" => source } } let(:site) { make_site(config) } subject { described_class } it "returns the version" do expect(subject::VERSION).to match(%r!\d+\.\d+\.\d+!) end it "inits" do expect(subject.init(site)).to be_a(Jekyll::RemoteTheme::Theme) expect(site.theme).to be_a(Jekyll::RemoteTheme::Theme) expect(File.join(site.theme.root, "_layouts/default.html")).to be_an_existing_file end end jekyll-remote-theme-0.4.3/spec/spec_helper.rb000066400000000000000000000024701402222355100211500ustar00rootroot00000000000000# frozen_string_literal: true require_relative "../lib/jekyll-remote-theme" require "fileutils" require "open3" require "pathname" require "webmock/rspec" WebMock.allow_net_connect! RSpec.configure do |config| config.example_status_persistence_file_path = "spec/examples.txt" config.disable_monkey_patching! config.warnings = true config.default_formatter = "doc" if config.files_to_run.one? config.order = :random Kernel.srand config.seed end RSpec::Matchers.define :be_an_existing_file do match { |path| File.exist?(path) } end def tmp_dir @tmp_dir ||= File.expand_path "../tmp", __dir__ end def source_dir @source_dir ||= fixture_path "site" end def dest_dir @dest_dir ||= File.join tmp_dir, "dest" end def gemspec_dir(*contents) File.join(fixture_path("gemspecs"), *contents) end def reset_tmp_dir FileUtils.rm_rf tmp_dir FileUtils.mkdir_p tmp_dir end def fixture_path(fixture) File.expand_path "fixtures/#{fixture}", __dir__ end def config_defaults { "source" => source_dir, "destination" => dest_dir, "gems" => ["jekyll-remote-theme"], } end def make_site(options = {}) config = Jekyll.configuration config_defaults.merge(options) Jekyll::Site.new(config) end def with_env(key, value) old_env = ENV[key] ENV[key] = value yield ENV[key] = old_env end