Skip to content

Commit

Permalink
Merge pull request #1 from RoleModel/update-gemspec
Browse files Browse the repository at this point in the history
Update Gemspec
  • Loading branch information
BlaineIrvin authored Aug 14, 2024
2 parents 5bf9653 + b3c1615 commit 683f1de
Show file tree
Hide file tree
Showing 11 changed files with 129 additions and 41 deletions.
12 changes: 12 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Why?

Why were the changes needed? What issues were the changes addressing?
(Note: some changes may seem unrelated to the ticket, this is a great place to explain further.)

## What Changed

What changed in this PR?

* [ ] Change 1
* [ ] Change 2
* [ ] ...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@
/pkg/
/spec/reports/
/tmp/

.history
80 changes: 75 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,78 @@
AllCops:
TargetRubyVersion: 3.0
Exclude:
- bin/**/*
- db/**/*
- vendor/**/*
- config/**/*
- tmp/**/*
- env.rb
NewCops: enable

Style/StringLiterals:
EnforcedStyle: double_quotes
Metrics:
Severity: refactor

Style/StringLiteralsInInterpolation:
EnforcedStyle: double_quotes
# Hard to make this pass always and want to keep flexibility
Layout/ArrayAlignment:
Enabled: false

# Best Practices for readability
Layout:
Severity: refactor

Layout/ArgumentAlignment:
EnforcedStyle: with_fixed_indentation

Layout/FirstArrayElementIndentation:
EnforcedStyle: consistent

Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Layout/MultilineMethodCallIndentation:
EnforcedStyle: indented

Layout/MultilineOperationIndentation:
EnforcedStyle: indented

Lint/UnusedMethodArgument:
Severity: refactor
AutoCorrect: false

Lint/UnusedBlockArgument:
Severity: refactor
AutoCorrect: false

Lint/UselessAssignment:
Severity: refactor
AutoCorrect: false

Lint/UnderscorePrefixedVariableName:
Enabled: false

Lint/Loop:
Enabled: false

Lint/SuppressedException:
Enabled: false

Naming/BlockForwarding:
EnforcedStyle: explicit

Style:
Severity: refactor

Style/ClassAndModuleChildren:
Enabled: false

Style/Documentation:
Enabled: false

Style/HashAsLastArrayItem:
Enabled: false

Style/HashSyntax:
Enabled: false

# It is ok to use inject at times
Style/EachWithObject:
Enabled: false
8 changes: 4 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frozen_string_literal: true

source "https://rubygems.org"
source 'https://rubygems.org'

# Specify your gem's dependencies in chromium-pdf.gemspec
gemspec

gem "rake", "~> 13.0"
gem 'rake', '~> 13.0'

gem "minitest", "~> 5.16"
gem 'minitest', '~> 5.16'

gem "rubocop", "~> 1.21"
gem 'rubocop', '~> 1.21'
6 changes: 3 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# frozen_string_literal: true

require "bundler/gem_tasks"
require "minitest/test_task"
require 'bundler/gem_tasks'
require 'minitest/test_task'

Minitest::TestTask.create

require "rubocop/rake_task"
require 'rubocop/rake_task'

RuboCop::RakeTask.new

Expand Down
32 changes: 18 additions & 14 deletions chromium-pdf.gemspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
# frozen_string_literal: true

require_relative "lib/chromium/pdf/version"
require_relative 'lib/chromium/pdf/version'

Gem::Specification.new do |spec|
spec.name = "chromium-pdf"
spec.name = 'chromium-pdf'
spec.version = Chromium::Pdf::VERSION
spec.authors = ["RoleModel Software"]
spec.email = ["[email protected]"]
spec.authors = ['RoleModel Software']
spec.email = ['[email protected]']

spec.summary = "A wrapper around headless Chrome's print-to-pdf functionality."
spec.description = "TODO: Write a longer description or delete this line."
spec.homepage = "TODO: Put your gem's website or public repo URL here."
spec.license = "MIT"
spec.required_ruby_version = ">= 3.0.0"
spec.homepage = 'https://github.com/RoleModel/chromium-pdf'
spec.license = 'MIT'
spec.required_ruby_version = '>= 3.0.0'

spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.' unless spec.respond_to?(:metadata)

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
spec.metadata['allowed_push_host'] = "Set to 'http://mygemserver.com'"

spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/RoleModel/chromium-pdf'
spec.metadata['changelog_uri'] = 'https://github.com/RoleModel/chromium-pdf'

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
Expand All @@ -29,13 +32,14 @@ Gem::Specification.new do |spec|
f.start_with?(*%w[bin/ test/ spec/ features/ .git .github appveyor Gemfile])
end
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

# Uncomment to register a new dependency of your gem
# spec.add_dependency "example-gem", "~> 1.0"

# For more information and examples about making a new gem, check out our
# guide at: https://bundler.io/guides/creating_gem.html
spec.metadata['rubygems_mfa_required'] = 'true'
end
5 changes: 2 additions & 3 deletions lib/chromium/pdf.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# frozen_string_literal: true

require_relative "pdf/version"
require_relative 'pdf/version'

module Chromium
module Pdf

##
# @param unescaped_filename [String] The filename to save the PDF as.
# @param print_url [String] The URL of the page you want to be processed.
Expand All @@ -18,7 +17,7 @@ def generate_pdf!(unescaped_filename, print_url, arguments: ['--headless --disab
Dir.mktmpdir do |path|
filepath = "#{path}/#{filename}"

system("LD_PRELOAD='' #{chrome_path} --print-to-pdf='#{filepath}' #{arguments.join(' ')} #{print_url} 2> /dev/null"
system("LD_PRELOAD='' #{chrome_path} --print-to-pdf='#{filepath}' #{arguments.join(' ')} #{print_url}")

File.open(filepath) do |file|
yield file, filename
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require 'rails/generators/base'
require 'rails/generators/active_record'

module Chromium
module Pdf
module Generators
class InstallGenerator < Rails::Generators::Base

end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/chromium/pdf/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module Chromium
module Pdf
VERSION = "0.1.0"
VERSION = '0.1.0'
end
end
14 changes: 7 additions & 7 deletions test/chromium/test_pdf.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# frozen_string_literal: true

require "test_helper"
require 'test_helper'

class Chromium::TestPdf < Minitest::Test
def test_that_it_has_a_version_number
refute_nil ::Chromium::Pdf::VERSION
end
# def test_that_it_has_a_version_number
# refute_nil ::Chromium::Pdf::VERSION
# end

def test_it_does_something_useful
assert false
end
# def test_it_does_something_useful
# assert false
# end
end
6 changes: 3 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

$LOAD_PATH.unshift File.expand_path("../lib", __dir__)
require "chromium/pdf"
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'chromium/pdf'

require "minitest/autorun"
require 'minitest/autorun'

0 comments on commit 683f1de

Please sign in to comment.