nugem 0.8.0 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +2 -3
  3. data/CHANGELOG.md +31 -9
  4. data/Gemfile +26 -0
  5. data/README.md +29 -12
  6. data/exe/nugem +5 -0
  7. data/lib/nugem/cli/cli_gem.rb +6 -7
  8. data/lib/nugem/cli/cli_jekyll.rb +15 -15
  9. data/lib/nugem/cli/cli_rails.rb +3 -4
  10. data/lib/nugem/cli.rb +53 -39
  11. data/lib/nugem/git.rb +61 -59
  12. data/lib/nugem/version.rb +1 -1
  13. data/lib/nugem.rb +7 -22
  14. data/lib/util.rb +27 -0
  15. data/nugem.gemspec +23 -12
  16. data/templates/common/LICENCE.txt.tt +21 -0
  17. data/templates/common/executable_scaffold/exe/%gem_name%.tt +5 -0
  18. data/templates/common/executable_scaffold/lib/%gem_name%/cli.rb.tt +13 -0
  19. data/templates/common/gem_scaffold/%gem_name%.gemspec.tt +57 -0
  20. data/templates/common/gem_scaffold/.bundle/config +2 -0
  21. data/templates/common/gem_scaffold/.gitignore.tt +27 -0
  22. data/templates/common/gem_scaffold/.markdownlint.json +8 -0
  23. data/templates/common/gem_scaffold/.rspec +4 -0
  24. data/templates/common/gem_scaffold/.rubocop.yml.tt +80 -0
  25. data/templates/common/gem_scaffold/.shellcheckrc +5 -0
  26. data/templates/common/gem_scaffold/.vscode/%gem_name%.json.code-snippets.tt +19 -0
  27. data/templates/common/gem_scaffold/.vscode/extensions.json +22 -0
  28. data/templates/common/gem_scaffold/.vscode/launch.json +31 -0
  29. data/templates/common/gem_scaffold/.vscode/settings.json +5 -0
  30. data/templates/common/gem_scaffold/CHANGELOG.md.tt +5 -0
  31. data/templates/common/gem_scaffold/Gemfile.tt +44 -0
  32. data/templates/common/gem_scaffold/README.md.tt +102 -0
  33. data/templates/common/gem_scaffold/Rakefile.tt +51 -0
  34. data/templates/common/gem_scaffold/bin/attach +35 -0
  35. data/templates/common/gem_scaffold/bin/build +7 -0
  36. data/templates/common/gem_scaffold/bin/console.tt +10 -0
  37. data/templates/common/gem_scaffold/bin/rake +13 -0
  38. data/templates/common/gem_scaffold/bin/reset +4 -0
  39. data/templates/common/gem_scaffold/bin/setup.tt +27 -0
  40. data/templates/common/gem_scaffold/lib/%gem_name%/version.rb.tt +3 -0
  41. data/templates/common/gem_scaffold/lib/%gem_name%.rb.tt +14 -0
  42. data/templates/common/gem_scaffold/test/%gem_name%_test.rb.tt +11 -0
  43. data/templates/common/gem_scaffold/test/test_helper.rb.tt +96 -0
  44. data/templates/jekyll/block_no_arg_scaffold/lib/%block_name%.rb.tt +23 -0
  45. data/templates/jekyll/block_scaffold/lib/%block_name%.rb.tt +50 -0
  46. data/templates/jekyll/common_scaffold/spec/%gem_name%_spec.rb.tt +13 -0
  47. data/templates/jekyll/common_scaffold/spec/spec_helper.rb +79 -0
  48. data/templates/jekyll/demo/demo/Gemfile.tt +22 -0
  49. data/templates/jekyll/demo/demo/_bin/debug +71 -0
  50. data/templates/jekyll/demo/demo/_config.yml.tt +48 -0
  51. data/templates/jekyll/demo/demo/_drafts/2022/2022-05-01-test2.html +15 -0
  52. data/templates/jekyll/demo/demo/_includes/block_tag_template_wrapper +9 -0
  53. data/templates/jekyll/demo/demo/_layouts/default.html.tt +67 -0
  54. data/templates/jekyll/demo/demo/_posts/2022/2022-01-02-redact-test.html +12 -0
  55. data/templates/jekyll/demo/demo/assets/css/style.css +218 -0
  56. data/templates/jekyll/demo/demo/assets/images/404-error.png +0 -0
  57. data/templates/jekyll/demo/demo/assets/images/404-error.webp +0 -0
  58. data/templates/jekyll/demo/demo/assets/images/favicon.png +0 -0
  59. data/templates/jekyll/demo/demo/assets/images/jekyll.png +0 -0
  60. data/templates/jekyll/demo/demo/assets/images/jekyll.webp +0 -0
  61. data/templates/jekyll/demo/demo/assets/js/clipboard.min.js +7 -0
  62. data/templates/jekyll/demo/demo/assets/js/jquery-3.4.1.min.js +2 -0
  63. data/templates/jekyll/demo/demo/blog/blogsByDate.html +22 -0
  64. data/templates/jekyll/demo/demo/blog/index.html +36 -0
  65. data/templates/jekyll/demo/demo/index.html.tt +5 -0
  66. data/templates/jekyll/filter_scaffold/lib/%filter_name%.rb.tt +30 -0
  67. data/templates/jekyll/generator_scaffold/lib/%generator_name%.rb.tt +34 -0
  68. data/templates/jekyll/hooks_scaffold/lib/dumpers.rb +172 -0
  69. data/templates/jekyll/hooks_scaffold/lib/hooks.rb.tt +238 -0
  70. data/templates/jekyll/tag_no_arg_scaffold/lib/%tag_name%.rb.tt +18 -0
  71. data/templates/jekyll/tag_scaffold/lib/%tag_name%.rb.tt +43 -0
  72. data/templates/rails/engine_scaffold/app/assets/images/%gem_name%/.keep +0 -0
  73. data/templates/rails/engine_scaffold/app/assets/javascripts/%gem_name%/.keep +0 -0
  74. data/templates/rails/engine_scaffold/app/assets/stylesheets/%gem_name%/.keep +0 -0
  75. data/templates/rails/engine_scaffold/app/controllers/.keep +0 -0
  76. data/templates/rails/engine_scaffold/app/helpers/.keep +0 -0
  77. data/templates/rails/engine_scaffold/app/mailers/.keep +0 -0
  78. data/templates/rails/engine_scaffold/app/models/.keep +0 -0
  79. data/templates/rails/engine_scaffold/app/views/.keep +0 -0
  80. data/templates/rails/engine_scaffold/bin/rails.tt +15 -0
  81. data/templates/rails/engine_scaffold/config/routes.rb.tt +6 -0
  82. data/templates/rails/engine_scaffold/lib/%gem_name%/engine.rb.tt +7 -0
  83. data/templates/rails/engine_scaffold/test/integration/navigation_test.rb +7 -0
  84. data/templates/rails/mountable_scaffold/app/assets/javascripts/%gem_name%/application.js +13 -0
  85. data/templates/rails/mountable_scaffold/app/assets/stylesheets/%gem_name%/application.css +15 -0
  86. data/templates/rails/mountable_scaffold/app/controllers/%gem_name%/application_controller.rb.tt +5 -0
  87. data/templates/rails/mountable_scaffold/app/helpers/%gem_name%/application_helper.rb.tt +4 -0
  88. data/templates/rails/mountable_scaffold/app/views/layouts/%gem_name%/application.html.erb.tt +14 -0
  89. data/templates/rails/plugin_scaffold/.envrc +1 -0
  90. data/templates/rails/plugin_scaffold/.simplecov.tt +18 -0
  91. data/templates/rails/plugin_scaffold/.travis.yml +4 -0
  92. data/templates/rails/plugin_scaffold/test/dummy/.envrc +1 -0
  93. data/templates/rails/plugin_scaffold/test/dummy/README.rdoc +28 -0
  94. data/templates/rails/plugin_scaffold/test/dummy/Rakefile +6 -0
  95. data/templates/rails/plugin_scaffold/test/dummy/app/assets/images/.keep +0 -0
  96. data/templates/rails/plugin_scaffold/test/dummy/app/assets/javascripts/application.js +13 -0
  97. data/templates/rails/plugin_scaffold/test/dummy/app/assets/stylesheets/application.sass +0 -0
  98. data/templates/rails/plugin_scaffold/test/dummy/app/controllers/application_controller.rb +7 -0
  99. data/templates/rails/plugin_scaffold/test/dummy/app/controllers/concerns/.keep +0 -0
  100. data/templates/rails/plugin_scaffold/test/dummy/app/helpers/application_helper.rb +2 -0
  101. data/templates/rails/plugin_scaffold/test/dummy/app/mailers/application_mailer.rb +4 -0
  102. data/templates/rails/plugin_scaffold/test/dummy/app/models/.keep +0 -0
  103. data/templates/rails/plugin_scaffold/test/dummy/app/models/concerns/.keep +0 -0
  104. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/application.html.erb +14 -0
  105. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/mailer.html.erb +9 -0
  106. data/templates/rails/plugin_scaffold/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  107. data/templates/rails/plugin_scaffold/test/dummy/bin/bundle +4 -0
  108. data/templates/rails/plugin_scaffold/test/dummy/bin/rails +5 -0
  109. data/templates/rails/plugin_scaffold/test/dummy/bin/rake +6 -0
  110. data/templates/rails/plugin_scaffold/test/dummy/bin/setup +30 -0
  111. data/templates/rails/plugin_scaffold/test/dummy/config/application.rb.tt +26 -0
  112. data/templates/rails/plugin_scaffold/test/dummy/config/boot.rb +5 -0
  113. data/templates/rails/plugin_scaffold/test/dummy/config/database.yml +25 -0
  114. data/templates/rails/plugin_scaffold/test/dummy/config/environment.rb +5 -0
  115. data/templates/rails/plugin_scaffold/test/dummy/config/environments/development.rb +41 -0
  116. data/templates/rails/plugin_scaffold/test/dummy/config/environments/production.rb +79 -0
  117. data/templates/rails/plugin_scaffold/test/dummy/config/environments/test.rb +42 -0
  118. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/assets.rb +11 -0
  119. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  120. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  121. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  122. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/inflections.rb +16 -0
  123. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/mime_types.rb +4 -0
  124. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/session_store.rb +3 -0
  125. data/templates/rails/plugin_scaffold/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  126. data/templates/rails/plugin_scaffold/test/dummy/config/locales/en.yml +23 -0
  127. data/templates/rails/plugin_scaffold/test/dummy/config/routes.rb.tt +5 -0
  128. data/templates/rails/plugin_scaffold/test/dummy/config/secrets.yml +22 -0
  129. data/templates/rails/plugin_scaffold/test/dummy/config.ru +4 -0
  130. data/templates/rails/plugin_scaffold/test/dummy/db/seeds.rb +7 -0
  131. data/templates/rails/plugin_scaffold/test/dummy/lib/assets/.keep +0 -0
  132. data/templates/rails/plugin_scaffold/test/dummy/log/.keep +0 -0
  133. data/templates/rails/plugin_scaffold/test/dummy/public/404.html +67 -0
  134. data/templates/rails/plugin_scaffold/test/dummy/public/422.html +67 -0
  135. data/templates/rails/plugin_scaffold/test/dummy/public/500.html +66 -0
  136. data/templates/rails/plugin_scaffold/test/dummy/public/favicon.ico +0 -0
  137. data/templates/rails/rails_scaffold/lib/tasks/%gem_name%_tasks.rake.tt +4 -0
  138. data/templates/rails/rails_scaffold/test/dummy/.envrc +1 -0
  139. data/templates/rails/rails_scaffold/test/dummy/README.rdoc +28 -0
  140. data/templates/rails/rails_scaffold/test/dummy/Rakefile +6 -0
  141. data/templates/rails/rails_scaffold/test/dummy/app/assets/images/.keep +0 -0
  142. data/templates/rails/rails_scaffold/test/dummy/app/assets/javascripts/application.js +13 -0
  143. data/templates/rails/rails_scaffold/test/dummy/app/assets/stylesheets/application.sass +0 -0
  144. data/templates/rails/rails_scaffold/test/dummy/app/controllers/application_controller.rb +7 -0
  145. data/templates/rails/rails_scaffold/test/dummy/app/controllers/concerns/.keep +0 -0
  146. data/templates/rails/rails_scaffold/test/dummy/app/helpers/application_helper.rb +2 -0
  147. data/templates/rails/rails_scaffold/test/dummy/app/mailers/application_mailer.rb +4 -0
  148. data/templates/rails/rails_scaffold/test/dummy/app/models/.keep +0 -0
  149. data/templates/rails/rails_scaffold/test/dummy/app/models/concerns/.keep +0 -0
  150. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/application.html.erb +14 -0
  151. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/mailer.html.erb +9 -0
  152. data/templates/rails/rails_scaffold/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  153. data/templates/rails/rails_scaffold/test/dummy/bin/bundle +4 -0
  154. data/templates/rails/rails_scaffold/test/dummy/bin/rails +5 -0
  155. data/templates/rails/rails_scaffold/test/dummy/bin/rake +6 -0
  156. data/templates/rails/rails_scaffold/test/dummy/bin/setup +30 -0
  157. data/templates/rails/rails_scaffold/test/dummy/config/application.rb.tt +26 -0
  158. data/templates/rails/rails_scaffold/test/dummy/config/boot.rb +5 -0
  159. data/templates/rails/rails_scaffold/test/dummy/config/database.yml +25 -0
  160. data/templates/rails/rails_scaffold/test/dummy/config/environment.rb +5 -0
  161. data/templates/rails/rails_scaffold/test/dummy/config/environments/development.rb +41 -0
  162. data/templates/rails/rails_scaffold/test/dummy/config/environments/production.rb +79 -0
  163. data/templates/rails/rails_scaffold/test/dummy/config/environments/test.rb +42 -0
  164. data/templates/rails/rails_scaffold/test/dummy/config/initializers/assets.rb +11 -0
  165. data/templates/rails/rails_scaffold/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  166. data/templates/rails/rails_scaffold/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  167. data/templates/rails/rails_scaffold/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  168. data/templates/rails/rails_scaffold/test/dummy/config/initializers/inflections.rb +16 -0
  169. data/templates/rails/rails_scaffold/test/dummy/config/initializers/mime_types.rb +4 -0
  170. data/templates/rails/rails_scaffold/test/dummy/config/initializers/session_store.rb +3 -0
  171. data/templates/rails/rails_scaffold/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  172. data/templates/rails/rails_scaffold/test/dummy/config/locales/en.yml +23 -0
  173. data/templates/rails/rails_scaffold/test/dummy/config/routes.rb.tt +5 -0
  174. data/templates/rails/rails_scaffold/test/dummy/config/secrets.yml +22 -0
  175. data/templates/rails/rails_scaffold/test/dummy/config.ru +4 -0
  176. data/templates/rails/rails_scaffold/test/dummy/db/seeds.rb +7 -0
  177. data/templates/rails/rails_scaffold/test/dummy/lib/assets/.keep +0 -0
  178. data/templates/rails/rails_scaffold/test/dummy/log/.keep +0 -0
  179. data/templates/rails/rails_scaffold/test/dummy/public/404.html +67 -0
  180. data/templates/rails/rails_scaffold/test/dummy/public/422.html +67 -0
  181. data/templates/rails/rails_scaffold/test/dummy/public/500.html +66 -0
  182. data/templates/rails/rails_scaffold/test/dummy/public/favicon.ico +0 -0
  183. metadata +187 -3
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ # Change to parent directory of this script
4
+ SOURCE=${BASH_SOURCE[0]}
5
+ while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
7
+ SOURCE=$(readlink "$SOURCE")
8
+ [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
9
+ done
10
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
11
+ cd "$DIR/.."
12
+
13
+ # Requires the target project contains a script called _bin/debug.
14
+ # See https://www.mslinn.com/blog/2022/02/21/jekyll-debugging.html
15
+
16
+ if [ -z "$1" ]; then
17
+ echo "Error: Please provide the project directory to run the test from."
18
+ exit 1
19
+ fi
20
+
21
+ if [ ! -f "$1/_bin/debug" ]; then
22
+ echo "Error: $1/_bin/debug does not exist."
23
+ exit 1
24
+ fi
25
+
26
+ GIT_ROOT="$( git rev-parse --show-toplevel )"
27
+ cd "${GIT_ROOT}"
28
+
29
+ bin/build
30
+
31
+ set -e
32
+
33
+ cd "$1" > /dev/null || exit 1
34
+ shift
35
+ _bin/debug "$@"
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ NAME="$( basename -s .git "$( git remote get-url origin )" )"
4
+
5
+ gem uninstall "$NAME" -aIx --user-install --force
6
+
7
+ bundle exec rake install
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require_relative '../lib/<%= @gem_name %>'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ require 'irb'
10
+ IRB.start
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # The application 'rake' is installed as part of a gem, and
4
+ # this file is here to facilitate running it.
5
+
6
+ require 'pathname'
7
+
8
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', Pathname.new(__dir__).realpath)
9
+
10
+ require 'rubygems'
11
+ require 'bundler/setup'
12
+
13
+ load Gem.bin_path('rake', 'rake')
@@ -0,0 +1,4 @@
1
+ #!/bin/bash
2
+
3
+ git checkout . # restores project
4
+ git clean -fd # Nukes untracked files and directories
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Change to parent directory of this script
4
+ SOURCE=${BASH_SOURCE[0]}
5
+ while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
7
+ SOURCE=$(readlink "$SOURCE")
8
+ [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
9
+ done
10
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
11
+ cd "$DIR/.." || exit
12
+
13
+ if [[ $(which apt) ]]; then
14
+ if [[ ! -f /usr/lib/x86_64-linux-gnu/libyaml.so ]]; then sudo apt install libyaml-dev; fi
15
+ fi
16
+
17
+ rm -f Gemfile.lock
18
+ if [[ -z "$( which bundle )" ]]; then gem install bundler; fi
19
+ BUNDLE_WITH="development" bundle
20
+
21
+ <%- if @jekyll -%>
22
+ bundle binstubs jekyll --force --path binstub
23
+ <%- end -%>
24
+ bundle binstubs rspec-core --force --path binstub
25
+ bundle binstubs rubocop --force --path binstub
26
+
27
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module <%= @class_name %>
2
+ VERSION = '0.1.0'.freeze unless defined? VERSION
3
+ end
@@ -0,0 +1,14 @@
1
+ <%- if @jekyll -%>
2
+ require 'jekyll'
3
+ require 'jekyll_plugin_logger'
4
+ require 'jekyll_plugin_support'
5
+
6
+ <%- end -%>
7
+ require_relative '<%= @gem_name %>/version'
8
+
9
+ # Require all Ruby files in 'lib/', except this file
10
+ Dir[File.join(__dir__, '*.rb')].each do |file|
11
+ require file unless file.end_with?('/<%= @gem_name %>.rb')
12
+ end
13
+
14
+ # Write the code for your gem here
@@ -0,0 +1,11 @@
1
+ require_relative 'test_helper'
2
+
3
+ class <%= @class_name %>Test < Minitest::Test
4
+ def test_it_is_a_module
5
+ assert_kind_of Module, <%= @class_name %>
6
+ end
7
+
8
+ def test_that_it_has_a_version_number
9
+ refute_nil ::<%= @class_name %>::VERSION
10
+ end
11
+ end
@@ -0,0 +1,96 @@
1
+ <%- unless @repository.private? -%>
2
+ require 'coveralls'
3
+ Coveralls.wear!
4
+ <%- end -%>
5
+
6
+ <%- unless @rails -%>
7
+ $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
8
+ require '<%= @gem_name %>'
9
+ <%- end -%>
10
+
11
+ require 'minitest/autorun'
12
+
13
+ require 'minitest/reporters'
14
+ <%- if @rails -%>
15
+ require 'minitest/reporters/screenshot_reporter'
16
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new,
17
+ Minitest::Reporters::JUnitReporter.new,
18
+ Minitest::Reporters::ScreenshotReporter.new]
19
+ <%- else -%>
20
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
21
+ <%- end -%>
22
+
23
+ # Filter out Minitest backtrace while allowing backtrace from other libraries to be shown.
24
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
25
+
26
+ <%- if @rails -%>
27
+ require File.expand_path('../test/dummy/config/environment.rb', __dir__)
28
+ ActiveRecord::Migrator.migrations_paths = [File.expand_path('../test/dummy/db/migrate', __dir__)]
29
+ <%- if @mountable -%>
30
+ ActiveRecord::Migrator.migrations_paths << File.expand_path('../db/migrate', __dir__)
31
+ <%- end -%>
32
+ require 'rails/test_help'
33
+
34
+ # Load support files
35
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
36
+
37
+ # Load fixtures from the engine
38
+ if ActiveSupport::TestCase.respond_to?(:fixture_path=)
39
+ ActiveSupport::TestCase.fixture_path = File.expand_path('fixtures', __dir__)
40
+ ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
41
+ ActiveSupport::TestCase.fixtures :all
42
+ end
43
+
44
+ # default test class for unit tests
45
+ class UnitTest < ActiveSupport::TestCase
46
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
47
+ fixtures :all
48
+ end
49
+
50
+ # configure webtests with capybara and poltergeist (headless)
51
+ require 'capybara/rails'
52
+ require 'capybara_minitest_spec'
53
+ require 'capybara/poltergeist'
54
+
55
+ CAPYBARA_WINDOW_SIZE = [1024, 768]
56
+
57
+ if ENV['HEADLESS'] == 'true'
58
+ # headless driver configuration
59
+ Capybara.register_driver :poltergeist do |app|
60
+ poltergeist_options = { debug: false, timeout: 30, js_errors: true, window_size: CAPYBARA_WINDOW_SIZE }
61
+ Capybara::Poltergeist::Driver.new(app, poltergeist_options)
62
+ end
63
+ Capybara.default_driver = :poltergeist
64
+ else
65
+ # chrome browser driver configuration
66
+ Capybara.register_driver :selenium do |app|
67
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
68
+ end
69
+ Capybara.default_driver = :selenium
70
+ Capybara.current_session.driver.browser.manage.window.resize_to CAPYBARA_WINDOW_SIZE[0], CAPYBARA_WINDOW_SIZE[1]
71
+ end
72
+ Capybara.default_max_wait_time = 5 # how long should capybara wait for elements to appear on the page (ajax)
73
+
74
+ # use database_cleaner to clean the database after every test with truncation, instead of using transactional fixtures
75
+ require 'database_cleaner'
76
+ DatabaseCleaner.strategy = :truncation
77
+
78
+ # default test class for webtests
79
+ class WebTest < ActionDispatch::IntegrationTest
80
+ include Capybara::DSL
81
+ extend Minitest::Spec::DSL
82
+ include Minitest::Reporters::Screenshot
83
+
84
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
85
+ fixtures :all
86
+
87
+ # disable transactional fixtures, as we use DatabaseCleaner
88
+ self.use_transactional_fixtures = false
89
+
90
+ # clean database after each test with database_cleaner
91
+ def after_teardown
92
+ super
93
+ DatabaseCleaner.clean
94
+ end
95
+ end
96
+ <%- end -%>
@@ -0,0 +1,23 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative '<%= @gem_name %>/version.rb'
3
+
4
+ module <%= @class_name %>
5
+ PLUGIN_NAME = '<%= @block_name %>'.freeze unless defined? PLUGIN_NAME
6
+
7
+ # This class implements the Jekyll block tag functionality
8
+ class <%= @jekyll_class_name %> < JekyllBlock
9
+ VERSION = <%= @class_name %>::VERSION
10
+
11
+ def initialize(tag_name, argument_string, parse_context)
12
+ class << self
13
+ include NoArgParsing
14
+ end
15
+
16
+ super
17
+ @logger.debug { "#{self.class}: respond_to?(:o_arg_parsing) #{respond_to?(:no_arg_parsing) ? 'yes' : 'no'}." }
18
+ rescue StandardError => e
19
+ @logger.error { "#{self.class} died with a #{e.full_message}" }
20
+ exit 2
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ require 'jekyll_plugin_support'
2
+ require_relative '<%= @gem_name %>/version.rb'
3
+
4
+ # This Jekyll block tag plugin is a minimal example.
5
+ #
6
+ # See https://www.mslinn.com/jekyll/10200-jekyll-plugin-background.html
7
+ # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html
8
+ #
9
+ # @example Heading for this example
10
+ # Describe what this example does
11
+ # {% my_block_tag param1="value1" %}
12
+ # Hello, world!
13
+ # {% endmy_block_tag %}
14
+ #
15
+ # The Jekyll log level defaults to :info, which means all the Jekyll.logger statements below will not generate output.
16
+ # You can control the log level when you start Jekyll.
17
+ # To set the log level to :debug, write an entery into _config.yml, like this:
18
+ # plugin_loggers:
19
+ # MyBlockTag: debug
20
+
21
+ module <%= @class_name %>
22
+ # This class implements the Jekyll block tag functionality
23
+ class <%= @jekyll_class_name %> < JekyllSupport::JekyllBlock
24
+ PLUGIN_NAME = '<%= @block_name %>'.freeze
25
+ VERSION = <%= @class_name %>::VERSION
26
+
27
+ # Put your plugin logic here.
28
+ # The following variables are predefined:
29
+ # @argument_string, @block_name, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site and @theme
30
+ #
31
+ # @return [String]
32
+ def render_impl(content)
33
+ <%= parse_jekyll_parameters %>
34
+
35
+ # Compute the return value of this Jekyll tag
36
+ <<~HEREDOC
37
+ <pre class="example">
38
+ content = '#{content}'
39
+ <%= dump_jekyll_parameters %>
40
+ Remaining markup: '#{@helper.remaining_markup}'.
41
+ </pre>
42
+ HEREDOC
43
+ rescue StandardError => e
44
+ @logger.error { "#{self.class} died with a #{e.full_message}" }
45
+ exit 3
46
+ end
47
+
48
+ JekyllPluginHelper.register(self, PLUGIN_NAME)
49
+ end
50
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../lib/<%= @gem_name %>'
2
+
3
+ RSpec.describe <%= @class_name %>::<%= @class_name %> do
4
+ let(:logger) do
5
+ PluginMetaLogger.instance.new_logger(self, PluginMetaLogger.instance.config)
6
+ end
7
+
8
+ let(:parse_context) { TestParseContext.new }
9
+
10
+ it 'has a test' do
11
+ expect(true).to be_true
12
+ end
13
+ end
@@ -0,0 +1,79 @@
1
+ require 'jekyll'
2
+ require 'jekyll_plugin_logger'
3
+ require 'liquid'
4
+ require 'fileutils'
5
+ require 'yaml'
6
+ require_relative '../lib/<%= @gem_name %>'
7
+
8
+ RSpec.configure do |config|
9
+ config.filter_run :focus
10
+ # config.order = 'random'
11
+ config.run_all_when_everything_filtered = true
12
+
13
+ # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
14
+ config.example_status_persistence_file_path = '../spec/status_persistence.txt'
15
+
16
+ config.filter_run_when_matching focus: true
17
+ end
18
+
19
+ Registers = Struct.new(:page, :site)
20
+
21
+ # Mock for Collections
22
+ class Collections
23
+ def values
24
+ []
25
+ end
26
+ end
27
+
28
+ # Mock for Site
29
+ class SiteMock
30
+ attr_reader :config
31
+
32
+ def initialize
33
+ @config = YAML.safe_load_file(File.read('../demo/_config.yml'))
34
+ @config['env'] = { 'JEKYLL_ENV' => 'development' }
35
+ end
36
+
37
+ def collections
38
+ Collections.new
39
+ end
40
+ end
41
+
42
+ class TestLiquidContext < Liquid::Context
43
+ def initialize
44
+ super
45
+
46
+ page = {
47
+ 'content' => 'blah blah',
48
+ 'description' => 'Jekyll plugin support demo',
49
+ 'dir' => '/',
50
+ 'excerpt' => nil,
51
+ 'layout' => 'default',
52
+ 'name' => 'index.html',
53
+ 'path' => 'index.html',
54
+ 'title' => 'Welcome',
55
+ 'url' => '/',
56
+ }
57
+
58
+ @content = 'Interior of the tag'
59
+ @registers = Registers.new(
60
+ page,
61
+ SiteMock.new
62
+ )
63
+ end
64
+ end
65
+
66
+ # Mock for Liquid::ParseContent
67
+ class TestParseContext < Liquid::ParseContext
68
+ attr_reader :line_number, :registers
69
+
70
+ def initialize
71
+ super
72
+ @line_number = 123
73
+
74
+ @registers = Registers.new(
75
+ { 'path' => 'path/to/page.html' },
76
+ SiteMock.new
77
+ )
78
+ end
79
+ end
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # gem 'ffi'
4
+ gem 'jekyll', '>= 4.3.2'
5
+ # gem 'nokogumbo', '=2.0.3'
6
+ # gem 'ptools'
7
+
8
+ group :jekyll_plugins do
9
+ gem '<%= @gem_name %>', path: '../' # use unreleased gem dependencies defined in the parent project
10
+ gem 'classifier-reborn'
11
+ gem 'html-proofer'
12
+ gem 'jekyll-assets', git: 'https://github.com/envygeeks/jekyll-assets'
13
+ gem 'jekyll-environment-variables'
14
+ gem 'jekyll-tagging'
15
+ end
16
+
17
+ group :test, :development do
18
+ gem 'debug', '>= 1.0.0', require: false
19
+ gem 'rspec-core', require: false
20
+ gem 'rubocop', require: false
21
+ gem 'rubocop-rspec', require: false
22
+ end
@@ -0,0 +1,71 @@
1
+ #!/bin/bash
2
+
3
+ # shellcheck disable=SC2086,SC2155,SC2059
4
+
5
+ function help {
6
+ echo "
7
+ $(basename $0) - Run the demo Jekyll website.
8
+ By default the demo Jekyll website runs without restriction under `debug`,
9
+ and listens on 0.0.0.0:1234.
10
+ Options:
11
+ -h Show this error message
12
+ -r Run freely, without a debugger
13
+ "
14
+ exit 1
15
+ }
16
+
17
+
18
+ unset RUN_FREE
19
+ while getopts "hr" OPT; do
20
+ case "$OPT" in
21
+ h) help ;;
22
+
23
+ r) export RUN_FREE=true
24
+ echo "The RUN_FREE option was specified (without a debugger)."
25
+ ;;
26
+
27
+ *) help ;;
28
+ esac
29
+ done
30
+ shift $((OPTIND-1))
31
+
32
+
33
+ # Change to parent directory of this script
34
+ SOURCE=${BASH_SOURCE[0]}
35
+ while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
36
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
37
+ SOURCE=$(readlink "$SOURCE")
38
+ [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
39
+ done
40
+ DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
41
+ cd "$DIR/.."
42
+
43
+ # dispatcher-port and dispatcher-port are arbitrarily chosen to prevent conflicts with other instances.
44
+
45
+ run="serve \
46
+ --livereload_port 25721 \
47
+ --force_polling \
48
+ --host 0.0.0.0 \
49
+ --port 4444 \
50
+ --future \
51
+ --incremental \
52
+ --livereload \
53
+ --drafts \
54
+ --unpublished"
55
+
56
+ ../bin/setup
57
+
58
+ rm -f Gemfile.lock
59
+ bundle
60
+ bundle exec ../binstub/jekyll clean # Ensure all hooks get called
61
+
62
+ if [ "$RUN_FREE" ]; then
63
+ bundle exec ../binstub/jekyll $run
64
+ else
65
+ bundle exec ../binstub/rdebug-ide \
66
+ --host 0.0.0.0 \
67
+ --port 1234 \
68
+ --dispatcher-port 26162 \
69
+ -- \
70
+ ../binstub/jekyll $run
71
+ fi
@@ -0,0 +1,48 @@
1
+ author: <%= @repository.user %>
2
+ compress_html:
3
+ blanklines: false
4
+ clippings: all
5
+ comments: ["<!-- ", " -->"]
6
+ endings: all
7
+ ignore:
8
+ envs: [development]
9
+ profile: false
10
+ startings: [html, head, body]
11
+ domain: bogus.jekylldemo.com
12
+ email: bogus@jekylldemo.com
13
+ exclude: # Wildcards are not supported yet https://github.com/jekyll/jekyll-watch/pull/93
14
+ - .git
15
+ - .github
16
+ - .gitignore
17
+ - .jekyll-cache
18
+ - .jekyll-metadata
19
+ - .ruby-version
20
+ - .vscode
21
+ - BingSiteAuth.xml
22
+ - Gemfile
23
+ - Gemfile.lock
24
+ - README.md
25
+ ignore_theme_config: true
26
+ liquid:
27
+ error_mode: strict
28
+ # strict_filters: true
29
+ # strict_variables: true
30
+ plugin_loggers:
31
+ PluginMetaLogger: info
32
+ CleanHook: warn
33
+ DocumentHooks: warn
34
+ MyBlock: warn
35
+ PageHooks: warn
36
+ PostHooks: warn
37
+ SiteHooks: warn
38
+ permalink: "/blog/:year/:month/:day/:title:output_ext"
39
+ plugins: # Use file name of the plugin entry point, not the gem name
40
+ - classifier-reborn
41
+ - jekyll
42
+ - jekyll_plugin_logger
43
+ - html-proofer
44
+ - <%= @gem_name %>
45
+ sass:
46
+ style: compressed
47
+ title: <%= gem_name %> Demonstration
48
+ url: https://bogus.jekylldemo.com
@@ -0,0 +1,15 @@
1
+ ---
2
+ categories: [Jekyll]
3
+ description: Just a draft test post I wrote
4
+ date: 2022-03-28
5
+ last_modified_at: 2022-04-12
6
+ layout: default
7
+ front_matter_variable: Provided in front matter
8
+ title: Test Draft Post
9
+ ---
10
+ <h2>Hello, World!</h2>
11
+
12
+ <h3>The Future Is So Bright</h3>
13
+ <p>
14
+ Plugins <b>may</b> receive variables as arguments, if they are enclosed in double curly braces.
15
+ </p>
@@ -0,0 +1,9 @@
1
+ {% assign include_variable = "variable set in _includes/block_tag_template_wrapper" %}
2
+ {% block_tag_template param1='{{include_variable}}'
3
+ param2='{{include.param2}}'
4
+ param3='{{include.param3}}'
5
+ param4='{{page.last_modified_at}}'
6
+ param5='{{layout.compress}}'
7
+ remainder of invocation string %}
8
+ Hello, world!
9
+ {% endblock_tag_template %}
@@ -0,0 +1,67 @@
1
+ ---
2
+ layout: compress
3
+ ---
4
+ <!DOCTYPE html>
5
+ <html lang="{{ site.lang | default: "en-US" }}">
6
+ <head>
7
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
8
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
9
+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
10
+ {% capture description %}{{ page.description | default: page.title | default: page.subtitle }}{% endcapture %}
11
+ {% capture page.title %}{{ page.title | default: page.subtitle }}{% endcapture %}
12
+ {% assign nowMillis = site.time | date: '%s' %}
13
+ <link rel="stylesheet" href="{{ '/assets/css/style.css?v=' | append: nowMillis }}" type="text/css">
14
+
15
+ {% assign csses = page.css | default: layout.css %}
16
+ {% for css in csses %}
17
+ <link rel="stylesheet" href="{{css | append: '?v=' | append: nowMillis }}" type="text/css">
18
+ {% endfor %}
19
+
20
+ <link rel="icon" type="image/png" href="/assets/images/favicon.png">
21
+ <!--[if lt IE 9]>
22
+ <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
23
+ <![endif]-->
24
+ <title>{{ page.title-override | default: page.title | default: page.subtitle }}</title>
25
+ {% if page.keywords %}<meta name="keywords" content="{{page.keywords}}">{% endif %}
26
+ </head>
27
+ <body id="body">
28
+ <header>
29
+ <div class="inner">
30
+ <a href="/index.html">
31
+ <div class="h1">{{ site.title }}</div>
32
+ </a>
33
+ {% capture Title %}{{ page.title | default: layout.title }}{% endcapture %}
34
+ {% capture Subtitle %}{{ page.subtitle | default: layout.subtitle }}{% endcapture %}
35
+ <h1 id="headerH1">{{ Title | default: Subtitle }}</h1>
36
+ </div>
37
+ </header>
38
+ <div id="content-wrapper">
39
+ <div class="inner clearfix">
40
+ <nav id="sidebar">
41
+ <ul>
42
+ <li><a href="/index.html">Tests</a></li>
43
+ <li><a href="/blog/blogsByDate.html">Blog</a></li>
44
+ </ul>
45
+ </nav>
46
+ <section id="main-content">
47
+ {{ content }}
48
+
49
+ <p class="copyright" id="copyright" xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
50
+ <a rel="license" style="float: left; margin-right: 1em; padding-top: 9px; padding-bottom: 2em;"
51
+ href="http://creativecommons.org/publicdomain/zero/1.0/">
52
+ <img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
53
+ </a>
54
+ To the extent possible under law,
55
+ <a rel="dct:publisher"
56
+ href="https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html">
57
+ <span property="dct:title"><%= @repository.user_name %></span></a>
58
+ has waived all copyright and related or neighboring rights to
59
+ <span property="dct:title"><%= @gem_name %> Demonstration</span>.
60
+ This work is published from <span property="vcard:Country" datatype="dct:ISO3166" content="CA"
61
+ about="https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html">Canada</span>.
62
+ </p>
63
+ </section>
64
+ </div>
65
+ </div>
66
+ </body>
67
+ </html>
@@ -0,0 +1,12 @@
1
+ ---
2
+ categories: [Jekyll, Ruby]
3
+ description: Another test.
4
+ date: 2022-12-15
5
+ last_modified_at: 2022-12-15
6
+ layout: default
7
+ title: Another Test
8
+ ---
9
+ <h2>Bogus Confidential Memo</h2>
10
+ <p>
11
+ Coca-Cola announced a merger with Pepsi that will happen on December 15th, 2222 for 200 trillion pounds of sugar.
12
+ </p>