diff --git a/CONTRIBUTING.md b/.github/CONTRIBUTING.md similarity index 100% rename from CONTRIBUTING.md rename to .github/CONTRIBUTING.md diff --git a/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md similarity index 100% rename from ISSUE_TEMPLATE.md rename to .github/ISSUE_TEMPLATE.md diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..3034d7e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,21 @@ +name: CI + +on: [push] + +jobs: + test: + runs-on: ubuntu-latest + name: ubuntu-ruby-${{ matrix.ruby-version }} + strategy: + fail-fast: false + matrix: + ruby-version: ["3.3", "3.2", "3.1", "3.0", "2.7", "2.6", "2.5"] + steps: + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true + - name: Runs tests + run: bundle exec rake test diff --git a/.rubocop.yml b/.rubocop.yml index 13d4d2c..7370611 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -2,71 +2,80 @@ require: - rubocop-performance AllCops: - NewCops: disable TargetRubyVersion: 2.5 Include: - '**/*.rb' - - '**/Rakefile' - - '**/Gemfile' - - '**/config.ru' Exclude: - - 'vendor/**/*' - - '**/tmp/**/*' - - 'middleman-cli/lib/middleman-cli/templates/**/*' + - fixtures/**/* + NewCops: disable + SuggestExtensions: false -Style/FrozenStringLiteralComment: - Enabled: true - EnforcedStyle: always +Layout/CaseIndentation: + EnforcedStyle: end +Layout/EndAlignment: + EnforcedStyleAlignWith: variable +Layout/LineLength: + Enabled: false -Security/YAMLLoad: +Lint/AssignmentInCondition: Enabled: false -Style/GuardClause: +Lint/SuppressedException: Enabled: false -Layout/LineLength: +Lint/MissingSuper: Enabled: false -Metrics/MethodLength: +Lint/AmbiguousRegexpLiteral: Enabled: false -Style/Documentation: +Lint/AmbiguousBlockAssociation: + Enabled: false +Lint/UriEscapeUnescape: Enabled: false +Lint/ShadowedException: + Enabled: false + Metrics/AbcSize: Enabled: false -Metrics/CyclomaticComplexity: +Metrics/ClassLength: Enabled: false -Metrics/BlockLength: +Metrics/CyclomaticComplexity: Enabled: false -Metrics/ModuleLength: +Metrics/MethodLength: Enabled: false Metrics/PerceivedComplexity: Enabled: false -Metrics/ClassLength: +Metrics/BlockLength: Enabled: false -Lint/AmbiguousRegexpLiteral: +Metrics/ModuleLength: Enabled: false -Lint/AmbiguousBlockAssociation: + +Style/BlockDelimiters: Enabled: false -Lint/UriEscapeUnescape: +Style/ClassAndModuleChildren: Enabled: false -Lint/SuppressedException: +Style/Documentation: Enabled: false -Lint/ShadowedException: +Style/DoubleNegation: Enabled: false -Naming/FileName: +Style/FormatString: Enabled: false -Naming/MethodParameterName: +Style/FrozenStringLiteralComment: Enabled: false -Naming/MemoizedInstanceVariableName: +Style/HashSyntax: + EnforcedStyle: ruby19 +Style/MultilineBlockChain: Enabled: false -Naming/HeredocDelimiterNaming: +Style/ParallelAssignment: Enabled: false -Security/Eval: +Style/PerlBackrefs: Enabled: false Style/RegexpLiteral: Enabled: false -Style/ClassAndModuleChildren: +Style/SignalException: Enabled: false -Style/MissingRespondToMissing: +Style/SingleLineBlockParams: Enabled: false -Lint/MissingSuper: +Style/SpecialGlobalVars: + Enabled: false +Style/TrivialAccessors: Enabled: false Style/EvalWithLocation: Enabled: false @@ -74,3 +83,14 @@ Style/ClassVars: Enabled: false Style/GlobalVars: Enabled: false +Style/MissingRespondToMissing: + Enabled: false + +Naming/FileName: + Enabled: false +Naming/MethodParameterName: + Enabled: false +Naming/MemoizedInstanceVariableName: + Enabled: false +Naming/HeredocDelimiterNaming: + Enabled: false diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fc717e7..0000000 --- a/.travis.yml +++ /dev/null @@ -1,28 +0,0 @@ -dist: xenial -language: ruby -cache: bundler - -rvm: - - ruby-head - - 2.7 - - 2.6 - - 2.5 - -os: - - linux - -gemfile: - - Gemfile - - Gemfile-4.x - -jobs: - fast_finish: true - allow_failures: - - rvm: ruby-head - -env: - global: - - TEST=true - -notifications: - email: false diff --git a/CHANGELOG.md b/CHANGELOG.md index 21c3590..4d19234 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,38 +1,44 @@ # Changelog +All notable changes to this project will be documented in this file. + +## Unreleased + +* Migrate CI to GitHub Actions (#386). + ## 4.0.3 -* Loosen dependencies and test against Middlman v5 betas -* Adapt to core Rubocop standards -* Title should be always a string (#351) +* Loosen dependencies and test against Middlman v5 betas. +* Adapt to core Rubocop standards. +* Title should be always a string (#351). * Fixed multibyte tags. ## 4.0.2 -* Pushed Gem 2017-05-22 -* Updated safe_parameterize - needs heavy testing from community -* Deprecating previous_article and next_article in favour of article_previous article_next -* Deprecating local_articles in favour of articles_by_locale -* Pull request #336 Add article_locale_next and article_locale_previous -* Pull request #312 Generating a blog article can optional create article subdirectory added manually -* Updated Gemfile for testing tools to remove the deprecation warnings from Aruba -* Added myself to GemSpec so I can push Gem live -* Edited Travis.yml to be inline with middleman core and the Ruby versions it tests against -* Created an GitHub Issue Template -* Created an Editor config -* Ruby 2.3.1 - middleman-core (master/4.2.1) - middleman-cli (master/4.2.1) - middleman-blog (local) - All tests pass -* Updated the Gemfile to use https to remove security warning - upped gem versions to match core -* Updated the license and readme +* Pushed Gem 2017-05-22. +* Updated safe_parameterize - needs heavy testing from community. +* Deprecating previous_article and next_article in favour of article_previous article_next. +* Deprecating local_articles in favour of articles_by_locale. +* Pull request #336 Add article_locale_next and article_locale_previous. +* Pull request #312 Generating a blog article can optional create article subdirectory added manually. +* Updated Gemfile for testing tools to remove the deprecation warnings from Aruba. +* Added myself to GemSpec so I can push Gem live. +* Edited Travis.yml to be inline with middleman core and the Ruby versions it tests against. +* Created an GitHub Issue Template. +* Created an Editor config. +* Ruby 2.3.1 - middleman-core (master/4.2.1) - middleman-cli (master/4.2.1) - middleman-blog (local) - All tests pass. +* Updated the Gemfile to use https to remove security warning - upped gem versions to match core. +* Updated the license and readme. ## 4.0.1 -* Pull in article command from v3.5.3 tag -* Summary fix -* Add address parse cache -* Add filter option -* Make sure to not generate invalid html when creating article summary -* If a summary_generator is defined, always use it to generate summaries -* Fix issue #269: duplicated key +* Pull in article command from v3.5.3 tag. +* Summary fix. +* Add address parse cache. +* Add filter option. +* Make sure to not generate invalid html when creating article summary. +* If a summary_generator is defined, always use it to generate summaries. +* Fix issue #269: duplicated key. ## 4.0.0.rc.1 @@ -40,49 +46,49 @@ ## 3.5.3 -* Update blog_article active_support requires. Fixes #205 +* Update blog_article active_support requires. Fixes #205. ## 3.5.2 * Ignored pages won't be processed by the blog extension. -* Avoid creating an empty-string collection when a post does not have a custom collection property set. #192 -* Fix blog sources matching blog entries that are in a subdirectory that's not explicitly stated as part of the blog.sources template. #196 -* Fixed tag and year links in blog template. #195 -* An article's language can be set via the {lang} parameter in its sources URL template. #187 -* Tags that are just a number work now. #188 +* Avoid creating an empty-string collection when a post does not have a custom collection property set (#192). +* Fix blog sources matching blog entries that are in a subdirectory that's not explicitly stated as part of the blog.sources template (#196). +* Fixed tag and year links in blog template (#195). +* An article's language can be set via the {lang} parameter in its sources URL template (#187). +* Tags that are just a number work now (#188). ## 3.5.1 -* Remove a broken bracket in the blog template. #181 -* Fix transliteration of strings into URL slugs to still transliterate when it can but not smash multibyte chars. #183 -* Only match source URI templates if the date components match what a date would look like, and avoid throwing when companion files do not have an article. #184 -* Re-support spaces in blog article source paths. #185 +* Remove a broken bracket in the blog template (#181) +* Fix transliteration of strings into URL slugs to still transliterate when it can but not smash multibyte chars (#183) +* Only match source URI templates if the date components match what a date would look like, and avoid throwing when companion files do not have an article (#184). +* Re-support spaces in blog article source paths (#185). ## 3.5.0 -* Add support for internationalization and locale-specific articles. #156 +* Add support for internationalization and locale-specific articles (#156). * Drop support for Ruby 1.8 and Middleman 3.0. * Removed backwards compatibility patch that set instance variables for tag and calendar pages. Use locals instead. * Templated paths like :sources, :taglink, :year_link, :month_link, :day_link, :page_link, and custom_collections links can now be optionally expressed as RFC 6570 URI templates. * Arbitrary data from page frontmatter can be used in the :permalink template. Simply add a key to your :permalink template that matches a field from your frontmatter. * Data extracted from the :sources URL template can be used in the :permalink template. This information can also be used from templates via current_article.metadata[:page][]. -* UTF-8 strings substituted into URLs are now preserved rather than being omitted. #176 +* UTF-8 strings substituted into URLs are now preserved rather than being omitted (#176) * "middleman article" command now works even when there are multiple blogs. Specify the blog you want using "--blog". * The template used to generate new articles via "middleman article" can be overridden by setting :new_article_template. * Removed `:blog_name`, `:blog_author`, `:blog_avatar` options and the `page_title` helper. ## 3.4.1 -* Require Middleman 3.2 +* Require Middleman 3.2. ## 3.4.0 -* Add `inspect` methods to `BlogData` and `BlogArticle` to avoid hangs on exceptions. #157 -* Generated feed.xml now works on blogs with no posts. #155 +* Add `inspect` methods to `BlogData` and `BlogArticle` to avoid hangs on exceptions (#157). +* Generated feed.xml now works on blogs with no posts (#155). * No longer depend on `middleman-more`. -* Don't try to replace tokens that don't exist in the source path. #161 -* Support for including arbitrary frontmatter data in blog permalinks. #164 -* When using multiblog, fail immediately if the blog name isn't specified. #168 +* Don't try to replace tokens that don't exist in the source path (#161). +* Support for including arbitrary frontmatter data in blog permalinks (#164). +* When using multiblog, fail immediately if the blog name isn't specified (#168). ## 3.3.0 @@ -92,19 +98,19 @@ * Add `:blog_name`, `:blog_author`, `:blog_avatar` options and a `page_title` helper that incorporates `:blog_name`. * Allow options.sources to contain the same date component multiple - times. #112 -* Improve `feed.xml.builder` template to support `blog.prefix`. #126 -* Hide page numbers in template if only one page per index. #125 -* URLs in the feed.xml template are now absolute. #130 + times (#112). +* Improve `feed.xml.builder` template to support `blog.prefix` (#126). +* Hide page numbers in template if only one page per index (#125). +* URLs in the feed.xml template are now absolute (#130). * ASCII-8BIT text is reencoded to UTF-8 to avoid Nokogiri problems when generating summaries. * `summary` will no longer explode when encountering comments in the - article. #136 -* Fix setting time zone with `set :time_zone` in `config.rb`. #140 + article (#136). +* Fix setting time zone with `set :time_zone` in `config.rb` (#140). * Articles can omit their :title from the filename and specify it in frontmatter - instead. #148 + instead (#148). * Pages can choose which blog to use in multi-blog mode by specifying the correct - blog in frontmatter. #150 + blog in frontmatter (#150). ## 3.2.0 @@ -120,20 +126,20 @@ ## 3.1.1 -* Correctly handle time zone, allow setting time zone with `set :time_zone`. #76 -* Fix using `page_articles` in when `paginate` is false. #78 +* Correctly handle time zone, allow setting time zone with `set :time_zone` (#76). +* Fix using `page_articles` in when `paginate` is false (#78). ## 3.1.0 -* Don't publish future-dated articles. #74 -* Create summary from source instead of output. #70 -* Deprecate instance variables in templates in favor of locals. #66 +* Don't publish future-dated articles (#74). +* Create summary from source instead of output (#70). +* Deprecate instance variables in templates in favor of locals (#66). * Allow articles to set "published: false" in frontmatter and show up in preview but not in build/production. -* Allow articles to have their own layout set in the YAML front matter. #59 -* Per-article content subdirectories. #60 -* Allow article date to be in any order in permalink. #60 -* Use `link_to` in blog templates. #62 -* Pagination for index, tag, and calendar pages. #57 +* Allow articles to have their own layout set in the YAML front matter (#59). +* Per-article content subdirectories (#60). +* Allow article date to be in any order in permalink (#60). +* Use `link_to` in blog templates (#62). +* Pagination for index, tag, and calendar pages (#57). ## 3.0.0 diff --git a/Gemfile b/Gemfile index 5d1eca8..0f16a17 100644 --- a/Gemfile +++ b/Gemfile @@ -2,41 +2,28 @@ source 'https://rubygems.org' -git_source(:github) { |repo_name| "https://github.com/#{repo_name}" } - -# Middleman Gems -gem 'middleman-cli', github: 'middleman/middleman', branch: 'master' -gem 'middleman-core', github: 'middleman/middleman', branch: 'master' +gem 'middleman-core', git: 'https://github.com/middleman/middleman.git' +gem 'middleman-cli', git: 'https://github.com/middleman/middleman.git' # Specify your gem's dependencies in middleman-blog.gemspec gemspec # Build and doc tools -gem 'rake', '~> 12.3', require: false -gem 'yard', '~> 0.9.11', require: false +gem 'rake', '~> 13.1', require: false +gem 'yard', '~> 0.9', require: false # Test tools -gem 'aruba', '~> 0.14.0', require: false -gem 'byebug' -gem 'capybara', '~> 2.5.0', require: false +gem 'aruba', '~> 1.0', require: false +gem 'capybara', '~> 3', require: false gem 'cucumber', '~> 3.0', require: false gem 'rspec', '~> 3.0', require: false +gem 'timecop', '~> 0.6', require: false -# Pry tools -gem 'pry' -gem 'pry-rescue' -gem 'pry-stack_explorer' - +# Optional dependencies, included for tests gem 'kramdown' -gem 'nokogiri', '~> 1.9.1' -gem 'timecop', '~> 0.6.3' +gem 'nokogiri', RUBY_VERSION < '2.6' ? '~> 1.12.0' : '>= 0', require: false # Code Quality -gem 'rubocop', '~> 0.89', require: false -gem 'rubocop-performance', '~> 1.7', require: false -gem 'simplecov', '~> 0.10', require: false - -# Set the ruby platform - not windows -platforms :ruby do - gem 'redcarpet', '~> 3.1' # Latest 3.4.0 -end +gem 'rubocop', require: false +gem 'rubocop-performance', require: false +gem 'simplecov', require: false diff --git a/Gemfile-4.x b/Gemfile-4.x deleted file mode 100644 index ee12ad6..0000000 --- a/Gemfile-4.x +++ /dev/null @@ -1,39 +0,0 @@ - -source 'https://rubygems.org' - -# Middleman Gems -gem 'middleman-cli', '~> 4.4' -gem 'middleman-core', '~> 4.4' - -# Specify your gem's dependencies in middleman-blog.gemspec -gemspec - -# Build and doc tools -gem 'rake', '~> 12.3', require: false -gem 'yard', '~> 0.9.11', require: false - -# Test tools -gem 'aruba', '~> 0.14.0', require: false -gem 'byebug' -gem 'capybara', '~> 2.5.0', require: false -gem 'cucumber', '~> 3.0', require: false -gem 'rspec', '~> 3.0', require: false - -# Pry tools -gem 'pry' -gem 'pry-rescue' -gem 'pry-stack_explorer' - -gem 'kramdown' -gem 'nokogiri', '~> 1.9.1' -gem 'timecop', '~> 0.6.3' - -# Code Quality -gem 'rubocop', '~> 0.89', require: false -gem 'rubocop-performance', '~> 1.7', require: false -gem 'simplecov', '~> 0.10', require: false - -# Set the ruby platform - not windows -platforms :ruby do - gem 'redcarpet', '~> 3.1' # Latest 3.4.0 -end diff --git a/README.md b/README.md index 57e8caa..0c75227 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,10 @@ # Middleman-Blog extension -middleman-blog is an extension for the [Middleman] static site generator that -adds blog-specific functionality. This includes : +[![Gem Version](https://badge.fury.io/rb/middleman-blog.svg)][gem] +[![CI](https://github.com/middleman/middleman-blog/actions/workflows/ci.yml/badge.svg)](https://github.com/middleman/middleman-blog/actions/workflows/ci.yml) + +`middleman-blog` is an extension for the [Middleman] static site generator that +adds blog-specific functionality. This includes: - Handling blog articles - Helpers for listing articles @@ -17,8 +20,8 @@ gem install middleman middleman init MY_PROJECT --template=blog ``` -If you already have a Middleman project: Add `gem "middleman-blog"` to your -`Gemfile` and run `bundle install` +If you already have a Middleman project, add the `gem "middleman-blog"` line to your +`Gemfile` and then run `bundle install`. ## Configuration @@ -28,17 +31,10 @@ Within the config.rb of the middleman project, include the line activate :blog ``` -A more extensive guide can be found here : -[Middleman blogging guide](http://middlemanapp.com/basics/blogging/) it includes -more detailed information on configuring and using the blog extension. +A more extensive guide can be found in the [Middleman blogging guide](http://middlemanapp.com/basics/blogging/). Additionally, up-to-date generated code documentation is available on [RubyDoc]. -## Build & Dependency Status - -[![Gem Version](https://badge.fury.io/rb/middleman-blog.svg)][gem] -[![Build Status](https://travis-ci.org/middleman/middleman-blog.svg)][travis] - ## Community Please also visit the the official [Middleman community forum](http://forum.middlemanapp.com) @@ -59,22 +55,14 @@ you are submitting. ## Testing -Our internal tests are passed through Travis, testing against the following -Ruby versions on Linux : - -- ruby-head -- 2.7 -- 2.6 -- 2.5 - -### Running tests +You can run all the tests by: 1. Checkout Repository: `git clone https://github.com/middleman/middleman-blog.git` 2. Install Bundler: `gem install bundler` 3. Run `bundle install` inside the project root to install the gem dependencies. 4. Run test cases: `bundle exec rake test` -NB// To run an individual test use : +To run an individual test use: 1. `bundle exec cucumber features/blog_sources.feature` @@ -86,7 +74,7 @@ If you have suggestions for testing practices please submit a request. ## Donate -[Click here to lend your support to Middleman](https://plasso.com/s/4dXbHBorC3) +[Click here to lend your support to Middleman](https://github.com/sponsors/tdreyno) ## License @@ -94,6 +82,5 @@ Copyright (c) 2010-2017 Thomas Reynolds. MIT Licensed, see [LICENSE] for details [middleman]: http://middlemanapp.com [gem]: https://rubygems.org/gems/middleman-blog -[travis]: http://travis-ci.org/middleman/middleman-blog [rubydoc]: http://rubydoc.info/github/middleman/middleman-blog/master [LICENSE]: https://github.com/middleman/middleman-blog/blob/master/LICENSE.md diff --git a/Rakefile b/Rakefile index 135f835..03ea409 100644 --- a/Rakefile +++ b/Rakefile @@ -4,25 +4,18 @@ require 'bundler' Bundler::GemHelper.install_tasks require 'cucumber/rake/task' - require 'middleman-core' Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t| - ENV['TEST'] = 'true' - exempt_tags = '' - exempt_tags = "#{exempt_tags} --tags 'not @nojava'" if RUBY_PLATFORM == 'java' - - t.cucumber_opts = "--color --tags 'not @wip' #{exempt_tags} --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" + exempt_tags << "--tags 'not @nojava'" if RUBY_PLATFORM == 'java' + t.cucumber_opts = "--color --tags 'not @wip' #{exempt_tags} --strict --format pretty" end -require 'rake/clean' - desc 'Run tests, both RSpec and Cucumber' -task test: %i[rubocop spec cucumber] +task test: %i[spec cucumber] require 'rspec/core/rake_task' - desc 'Run RSpec' RSpec::Core::RakeTask.new do |spec| spec.pattern = 'spec/**/*_spec.rb' diff --git a/features/support/time_steps.rb b/features/support/time_steps.rb index cbccce3..64fd5bb 100644 --- a/features/support/time_steps.rb +++ b/features/support/time_steps.rb @@ -11,13 +11,13 @@ Given /the (date|time|date and time) is (.+?)$/ do |datetime, value| time = case datetime - when 'date' - Date.parse(value) - when 'time' - Time.parse(value) - when 'date and time' - Time.zone.parse(value) - end + when 'date' + Date.parse(value) + when 'time' + Time.parse(value) + when 'date and time' + Time.zone.parse(value) + end Timecop.travel time end diff --git a/lib/middleman-blog/blog_article.rb b/lib/middleman-blog/blog_article.rb index 1582edd..3cda121 100644 --- a/lib/middleman-blog/blog_article.rb +++ b/lib/middleman-blog/blog_article.rb @@ -206,10 +206,10 @@ def date # First get the date from frontmatter @_date = if frontmatter_date.is_a? Time - frontmatter_date.in_time_zone - else - Time.zone.parse(frontmatter_date.to_s) - end + frontmatter_date.in_time_zone + else + Time.zone.parse(frontmatter_date.to_s) + end # Next figure out the date from the filename source_vars = blog_data.source_template.variables diff --git a/lib/middleman-blog/blog_data.rb b/lib/middleman-blog/blog_data.rb index 4865c3c..7174dfb 100644 --- a/lib/middleman-blog/blog_data.rb +++ b/lib/middleman-blog/blog_data.rb @@ -51,7 +51,7 @@ def initialize(app, controller, options) # @return [Array] ## def articles - @_articles.select(&(options.filter || proc { |a| a })).sort_by(&:date).reverse + @_articles.select(&options.filter || proc { |a| a }).sort_by(&:date).reverse end ## diff --git a/lib/middleman-blog/calendar_pages.rb b/lib/middleman-blog/calendar_pages.rb index 4c5d7a9..4136220 100644 --- a/lib/middleman-blog/calendar_pages.rb +++ b/lib/middleman-blog/calendar_pages.rb @@ -33,12 +33,12 @@ def initialize(app, blog_controller) # @return [String] def link(year, month = nil, day = nil) template = if day - @day_link_template - elsif month - @month_link_template - else - @year_link_template - end + @day_link_template + elsif month + @month_link_template + else + @year_link_template + end apply_uri_template template, date_to_params(Date.new(year, month || 1, day || 1)) end diff --git a/lib/middleman-blog/commands/article.rb b/lib/middleman-blog/commands/article.rb index 53b2926..f7cc48a 100644 --- a/lib/middleman-blog/commands/article.rb +++ b/lib/middleman-blog/commands/article.rb @@ -79,10 +79,10 @@ def article end blog_inst = if options[:blog] - app.extensions[:blog].find { |_key, instance| instance.options[:name] == options[:blog] }[ 1 ] - else - app.extensions[:blog].values.first - end + app.extensions[:blog].find { |_key, instance| instance.options[:name] == options[:blog] }[ 1 ] + else + app.extensions[:blog].values.first + end unless blog_inst msg = 'Could not find an active blog instance' diff --git a/lib/middleman-blog/extension.rb b/lib/middleman-blog/extension.rb index d16c258..8d95582 100644 --- a/lib/middleman-blog/extension.rb +++ b/lib/middleman-blog/extension.rb @@ -81,18 +81,18 @@ def initialize(app, options_hash = {}, &block) end # If "prefix" option is specified, all other paths are relative to it. - if options.prefix - options.prefix = "/#{options.prefix}" unless options.prefix.start_with? '/' - options.permalink = File.join(options.prefix, options.permalink) - options.sources = File.join(options.prefix, options.sources) - options.taglink = File.join(options.prefix, options.taglink) - options.year_link = File.join(options.prefix, options.year_link) - options.month_link = File.join(options.prefix, options.month_link) - options.day_link = File.join(options.prefix, options.day_link) - - options.custom_collections.each do |_key, opts| - opts[:link] = File.join(options.prefix, opts[:link]) - end + return unless options.prefix + + options.prefix = "/#{options.prefix}" unless options.prefix.start_with? '/' + options.permalink = File.join(options.prefix, options.permalink) + options.sources = File.join(options.prefix, options.sources) + options.taglink = File.join(options.prefix, options.taglink) + options.year_link = File.join(options.prefix, options.year_link) + options.month_link = File.join(options.prefix, options.month_link) + options.day_link = File.join(options.prefix, options.day_link) + + options.custom_collections.each do |_key, opts| + opts[:link] = File.join(options.prefix, opts[:link]) end end diff --git a/lib/middleman-blog/helpers.rb b/lib/middleman-blog/helpers.rb index d21636f..736af73 100644 --- a/lib/middleman-blog/helpers.rb +++ b/lib/middleman-blog/helpers.rb @@ -61,7 +61,7 @@ def blog(blog_name = nil) # Determine whether the currently rendering template is a {BlogArticle}. # This can be useful in layouts and helpers. # @return [Boolean] - def is_blog_article? # rubocop:disable Naming/PredicateName + def is_blog_article? !current_article.nil? end diff --git a/lib/middleman-blog/truncate_html.rb b/lib/middleman-blog/truncate_html.rb index e2d022d..e4dd679 100644 --- a/lib/middleman-blog/truncate_html.rb +++ b/lib/middleman-blog/truncate_html.rb @@ -50,7 +50,7 @@ def truncate(max_length, ellipsis) module TextNode def truncate(max_length, ellipsis) # Don't break in the middle of a word - trimmed_content = content.match(/(.{1,#{max_length}}[\w]*)/m).to_s + trimmed_content = content.match(/(.{1,#{max_length}}\w*)/m).to_s trimmed_content << ellipsis if trimmed_content.length < content.length Nokogiri::XML::Text.new(trimmed_content, parent) diff --git a/lib/middleman-blog/uri_templates.rb b/lib/middleman-blog/uri_templates.rb index 6f4043c..d82e55c 100644 --- a/lib/middleman-blog/uri_templates.rb +++ b/lib/middleman-blog/uri_templates.rb @@ -60,7 +60,7 @@ def safe_parameterize(str, sep = '-') # Reimplementation of http://api.rubyonrails.org/classes/ActiveSupport/Inflector.html#method-i-parameterize that preserves un-transliterate-able multibyte chars. parameterized_string = ::ActiveSupport::Inflector.transliterate(str.to_s).downcase - parameterized_string.gsub!(/[^a-z0-9\-_\?]+/, sep) + parameterized_string.gsub!(/[^a-z0-9\-_?]+/, sep) # Check for multibytes and sub back in parameterized_string.chars.to_a.each_with_index do |char, i| diff --git a/middleman-blog.gemspec b/middleman-blog.gemspec index cf4c509..3fadd07 100644 --- a/middleman-blog.gemspec +++ b/middleman-blog.gemspec @@ -1,9 +1,6 @@ -# -*- encoding: utf-8 -*- -$:.push File.expand_path( "../lib", __FILE__ ) -require "middleman-blog/version" +require "./lib/middleman-blog/version" Gem::Specification.new do | s | - s.name = "middleman-blog" s.version = Middleman::Blog::VERSION s.platform = Gem::Platform::RUBY @@ -16,10 +13,7 @@ Gem::Specification.new do | s | s.files = `git ls-files -z`.split( "\0" ) s.test_files = `git ls-files -z -- {fixtures,features}/*`.split( "\0" ) s.require_paths = [ "lib" ] - s.required_ruby_version = '>= 2.3.0' - - s.add_dependency( "middleman-core", [ ">= 4.0.0" ] ) - s.add_dependency( "tzinfo", [ ">= 0.3.0" ] ) - s.add_dependency( "addressable", [ "~> 2.3" ] ) - + s.add_dependency("middleman-core", ">= 4.0.0") + s.add_dependency("tzinfo", ">= 0.3.0") + s.add_dependency("addressable", "~> 2.3") end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index c4a73dc..ef66f35 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ # frozen_string_literal: true require 'simplecov' -SimpleCov.root(File.expand_path(File.dirname(__FILE__) + '/..')) +SimpleCov.root(File.expand_path("#{File.dirname(__FILE__)}/.."))