Class: EmbulkJavundler::JavaPlugin
- Inherits:
-
Object
- Object
- EmbulkJavundler::JavaPlugin
- Defined in:
- lib/embulk_javundler/java_plugin.rb
Defined Under Namespace
Classes: BuildFailure, GitError
Instance Attribute Summary collapse
-
#classpathdir ⇒ Object
readonly
Returns the value of attribute classpathdir.
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#github ⇒ Object
readonly
Returns the value of attribute github.
-
#install_dir ⇒ Object
readonly
Returns the value of attribute install_dir.
-
#libdir ⇒ Object
readonly
Returns the value of attribute libdir.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#sha1 ⇒ Object
readonly
Returns the value of attribute sha1.
Instance Method Summary collapse
- #build_gem ⇒ Object
- #checkout ⇒ Object
- #fetch ⇒ Object
-
#initialize(name:, install_dir:, git: nil, github: nil, commit: "master", libdir: nil, classpathdir: nil) ⇒ JavaPlugin
constructor
A new instance of JavaPlugin.
- #to_h ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(name:, install_dir:, git: nil, github: nil, commit: "master", libdir: nil, classpathdir: nil) ⇒ JavaPlugin
Returns a new instance of JavaPlugin.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/embulk_javundler/java_plugin.rb', line 10 def initialize(name:, install_dir:, git: nil, github: nil, commit: "master", libdir: nil, classpathdir: nil) @name = name @install_dir = install_dir @git = git @github = github @repo = if git git elsif github "https://github.com/#{github}.git" else raise ArgumentError, "Need git or github param" end @commit = commit @libdir = libdir ? install_dir.join(libdir) : install_dir.join("lib") @classpathdir = classpathdir ? install_dir.join(classpathdir) : install_dir.join("classpath") end |
Instance Attribute Details
#classpathdir ⇒ Object (readonly)
Returns the value of attribute classpathdir.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def classpathdir @classpathdir end |
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def commit @commit end |
#git ⇒ Object (readonly)
Returns the value of attribute git.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def git @git end |
#github ⇒ Object (readonly)
Returns the value of attribute github.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def github @github end |
#install_dir ⇒ Object (readonly)
Returns the value of attribute install_dir.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def install_dir @install_dir end |
#libdir ⇒ Object (readonly)
Returns the value of attribute libdir.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def libdir @libdir end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def name @name end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def repo @repo end |
#sha1 ⇒ Object (readonly)
Returns the value of attribute sha1.
8 9 10 |
# File 'lib/embulk_javundler/java_plugin.rb', line 8 def sha1 @sha1 end |
Instance Method Details
#build_gem ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/embulk_javundler/java_plugin.rb', line 82 def build_gem Bundler.with_clean_env do puts "Build #{name}" log, result_status = Open3.capture2e("./gradlew", "gem", chdir: install_dir.to_s) puts log unless result_status.success? raise BuildFailure end end end |
#checkout ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/embulk_javundler/java_plugin.rb', line 55 def checkout log, result_status = Open3.capture2e("git", "checkout", commit, chdir: install_dir.to_s) unless result_status.success? puts log raise GitError end sha1 = IO.popen(["git", "rev-parse", "HEAD", {chdir: install_dir.to_s}]) do |io| io.read.chomp end @sha1 = sha1 end |
#fetch ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/embulk_javundler/java_plugin.rb', line 39 def fetch if cloned? puts "Using #{name}" else print "Fetch #{name} from #{repo} ... " log, result_status = Open3.capture2e("git", "clone", repo, install_dir.to_s) unless result_status.success? puts log raise GitError end print "OK\n" end checkout end |
#to_h ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/embulk_javundler/java_plugin.rb', line 27 def to_h { name: name, install_dir: install_dir, git: git, github: github, commit: sha1 || commit, libdir: libdir, classpathdir: classpathdir, } end |
#update ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/embulk_javundler/java_plugin.rb', line 68 def update return fetch unless cloned? print "Update #{name} from #{repo} ... " log, result_status = Open3.capture2e("git", "pull", "origin", "--all", "--ff-only", chdir: install_dir.to_s) unless result_status.success? puts log raise GitError end print "OK\n" checkout end |