-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
packaging as rubygems #51
Conversation
# RubyGems | ||
/.bundle/ | ||
/.yardoc | ||
/_yardoc/ | ||
/coverage/ | ||
/pkg/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bundlerでgemのテンプレートを作った時に生成される.gitignoreから持ってきました
# Specify your gem's dependencies in pandoc2review.gemspec | ||
gemspec | ||
|
||
gem "rake", "~> 12.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gemにする場合、依存ライブラリは*.gemspec
から持ってくるようになるのでGemfileには直接書かなくなります
ふぉー、ありがとうございます。こういうラッパーだけなgemってrubygemsに入れるのはありなんですかね? |
@@ -1,5 +1,5 @@ | |||
#!/usr/bin/env ruby | |||
# -*- coding: utf-8 -*- | |||
# Copyright 2020 Kenshi Muto | |||
require_relative 'pandoc2review-lib' | |||
require 'pandoc2review' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
実行ファイルはexe
以下、ライブラリはlib
以下に収めることになるので少し変更しています
@@ -6,7 +6,7 @@ | |||
require 'open3' | |||
|
|||
def main | |||
bindir = Pathname.new(__FILE__).realpath.dirname | |||
luadir = Pathname.new(__FILE__).realpath.dirname |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*.luaもlib
に収めるようにしています(それが一番シンプルそうだったので。本当は専用ディレクトリを用意した方がよいかも?)
Gem::Specification.new do |spec| | ||
spec.name = "pandoc2review" | ||
# spec.version = Pandoc2review::VERSION | ||
spec.version = "1.1.0" | ||
spec.authors = ["kmuto"] | ||
spec.email = ["[email protected]"] | ||
|
||
spec.summary = %q{Re:VIEW Filter/Writer for Pandoc.} | ||
spec.description = %q{Re:VIEW Filter/Writer for Pandoc.} | ||
spec.homepage = "https://github.com/kmuto/pandoc2review" | ||
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0") | ||
|
||
spec.metadata["homepage_uri"] = spec.homepage | ||
spec.metadata["source_code_uri"] = "https://github.com/kmuto/pandoc2review" | ||
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here." | ||
|
||
# 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. | ||
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do | ||
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) } | ||
end | ||
spec.bindir = "exe" | ||
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency('unicode-eaw') | ||
spec.add_development_dependency('simplecov') | ||
spec.add_development_dependency('test-unit') | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この辺もbundlerが生成するものをベースにしています
require 'simplecov' | ||
SimpleCov.start | ||
require 'test/unit' | ||
require_relative '../pandoc2review-lib' | ||
require 'pandoc2review' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test::Unitのおすすめがlib
を$LOADPATHに突っ込む方式だったので、それに合わせています
lib/pandoc2review.rbはクラスかモジュールにするのが定番なのですが、とりあえずはそのままにしてあります。 |
はい、gem化するならクラス化しようかなと思っておりました。 |
スクリプトを配布する標準の方式がRubyGemsしかないので、ラッパーでも何でもrubygemsにしておくのが良さそうではあります。 |
ひととおり確認しました、ありがとうございます! |
マージして、アドバイスをもとに修正してみます |
なるほどです。 $LOAD_PATH.unshift(File.realpath('../lib', __dir__)) で実行ファイルからlib以下のファイルにパスを通せそうな気がしました(という話はRe:VIEWのリポジトリでやるべきか)。 |
こんな感じでgemにできるはずです