rfam 0.1.0-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7ef788d2bb36b1a69085a0353cb59d9e39527c1731e8691b11802ef8bda671be
4
+ data.tar.gz: 3cc54609a4e0ab9cc3fe9a3178568f7ad951750665465571b48e80fd6106b87a
5
+ SHA512:
6
+ metadata.gz: c8480e079f6c7ad4f911daef96ce2ed5229ecd8b2a70343faba9e85d06cd9a444c6750377643594d1d37b7802ac116639799d687a6041fa0d856f7e874a19de5
7
+ data.tar.gz: 8a890f412ea7bb4cb3cdd6e412802e5419aa33100a8ae41d1490efdd79e49d0ee386467c85d7ee3c5fcbd4adb851dd590fa8aa8d80506542a500b755e7aaf09a
data/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ FROM jruby:9.2.7.0
2
+
3
+ RUN apt-get update -qq \
4
+ && apt-get install -y \
5
+ vim less emacs-nox
6
+
7
+ WORKDIR /usr/src/rfam
8
+
9
+ COPY . .
10
+ RUN gem install bundler -v '2.0.1' \
11
+ && bundle install \
12
+ && rake rfam:install
13
+
14
+ CMD ["/bin/bash"]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rfam.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'jars/installer'
4
+ desc "Install JAR dependencies"
5
+ task :install_jars do
6
+ Jars::Installer.vendor_jars!
7
+ end
8
+
9
+ desc "Install rfam gem and JAR dependencies"
10
+ task "rfam:install" => [:install, :install_jars]
data/bin/rfam ADDED
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ require 'rfam'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+ parser = OptionParser.new do |opts|
8
+ opts.banner = "Usage: rfam [options]"
9
+
10
+ opts.on("-p", "--path PATH", "Path to monitor") do |v|
11
+ options[:path] = v
12
+ end
13
+
14
+ opts.on("-i", "--interval [MILLISECONDS]", Integer, "Interval to check/notify") do |v|
15
+ options[:interval] = v
16
+ end
17
+ end
18
+ parser.parse! ARGV
19
+
20
+ Rfam::Monitor.start(**options)
@@ -0,0 +1,47 @@
1
+ module Rfam
2
+ class Listener
3
+ include Rfam::FileAlterationListener
4
+
5
+ def onDirectoryChange(path)
6
+ emit Alteration.new(path, :directory, :change, now)
7
+ end
8
+
9
+ def onDirectoryCreate(path)
10
+ emit Alteration.new(path, :directory, :create, now)
11
+ end
12
+
13
+ def onDirectoryDelete(path)
14
+ emit Alteration.new(path, :directory, :delete, now)
15
+ end
16
+
17
+ def onFileChange(path)
18
+ emit Alteration.new(path, :file, :change, now)
19
+ end
20
+
21
+ def onFileCreate(path)
22
+ emit Alteration.new(path, :file, :create, now)
23
+ end
24
+
25
+ def onFileDelete(path)
26
+ emit Alteration.new(path, :file, :delete, now)
27
+ end
28
+
29
+ def onStart(observer)
30
+ # no-op
31
+ end
32
+
33
+ def onStop(observer)
34
+ # no-op
35
+ end
36
+
37
+ private
38
+
39
+ def emit(alteration)
40
+ puts JSON.dump(alteration.to_h)
41
+ end
42
+
43
+ def now
44
+ Time.now
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ require 'rfam/listener'
2
+
3
+ module Rfam
4
+ class Monitor
5
+
6
+ DEFAULT_INTERVAL = 1000
7
+
8
+ def self.start(*args)
9
+ new(*args).start
10
+ end
11
+
12
+ def self.run(*args)
13
+ new(*args).run
14
+ end
15
+
16
+ attr_reader :path, :interval, :observer, :listener, :monitor
17
+
18
+ def initialize(path:, interval: nil)
19
+ @path = path
20
+ @interval = interval || DEFAULT_INTERVAL
21
+ @listener = Listener.new
22
+ @observer = Rfam::FileAlterationObserver.new(path)
23
+ @observer.addListener(@listener)
24
+ @monitor = Rfam::FileAlterationMonitor.new(@interval, @observer)
25
+ end
26
+
27
+ def start
28
+ monitor.start
29
+ end
30
+
31
+ def stop
32
+ monitor.stop(0)
33
+ end
34
+
35
+ def run
36
+ begin
37
+ start
38
+ sleep
39
+ ensure
40
+ stop
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,3 @@
1
+ module Rfam
2
+ VERSION = "0.1.0"
3
+ end
data/lib/rfam.rb ADDED
@@ -0,0 +1,12 @@
1
+ require 'rfam/version'
2
+ # require 'java'
3
+ require 'rfam_jars'
4
+ require 'json'
5
+
6
+ module Rfam
7
+ include_package 'org.apache.commons.io.monitor'
8
+
9
+ Alteration = Struct.new(:path, :filetype, :alteration, :timestamp)
10
+ end
11
+
12
+ require 'rfam/monitor'
data/lib/rfam_jars.rb ADDED
@@ -0,0 +1,10 @@
1
+ # this is a generated file, to avoid over-writing it just delete this comment
2
+ begin
3
+ require 'jar_dependencies'
4
+ rescue LoadError
5
+ require 'commons-io/commons-io/2.6/commons-io-2.6.jar'
6
+ end
7
+
8
+ if defined? Jars
9
+ require_jar 'commons-io', 'commons-io', '2.6'
10
+ end
data/rfam.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ lib = File.expand_path("../lib", __FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+ require "rfam/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "rfam"
7
+ spec.version = Rfam::VERSION
8
+ spec.authors = ["David Chandek-Stark"]
9
+ spec.email = ["david.chandek.stark@duke.edu"]
10
+
11
+ spec.summary = "JRuby library wrapping Apache Commons IO File Monitor."
12
+ spec.homepage = "https://gitlab.oit.duke.edu/dc"
13
+ spec.license = "MIT"
14
+ spec.platform = "java"
15
+
16
+ # Specify which files should be added to the gem when it is released.
17
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
18
+ # spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
19
+ # `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ # end
21
+
22
+ spec.files = Dir['lib/**/*.rb']
23
+ spec.files += Dir['lib/**/*.jar']
24
+ spec.files += Dir['*file']
25
+ spec.files += Dir['*.gemspec']
26
+
27
+ spec.executables = ["rfam"]
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.requirements << "jar commons-io, commons-io, 2.6"
31
+
32
+ spec.add_development_dependency "bundler", "~> 2.0"
33
+ spec.add_development_dependency "rake", "~> 12.0"
34
+ # spec.add_development_dependency "rspec", "~> 3.0"
35
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rfam
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: java
6
+ authors:
7
+ - David Chandek-Stark
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - "~>"
17
+ - !ruby/object:Gem::Version
18
+ version: '2.0'
19
+ name: bundler
20
+ prerelease: false
21
+ type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - "~>"
31
+ - !ruby/object:Gem::Version
32
+ version: '12.0'
33
+ name: rake
34
+ prerelease: false
35
+ type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '12.0'
41
+ description:
42
+ email:
43
+ - david.chandek.stark@duke.edu
44
+ executables:
45
+ - rfam
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - Dockerfile
50
+ - Gemfile
51
+ - Rakefile
52
+ - bin/rfam
53
+ - lib/commons-io/commons-io/2.6/commons-io-2.6.jar
54
+ - lib/rfam.rb
55
+ - lib/rfam/listener.rb
56
+ - lib/rfam/monitor.rb
57
+ - lib/rfam/version.rb
58
+ - lib/rfam_jars.rb
59
+ - rfam.gemspec
60
+ homepage: https://gitlab.oit.duke.edu/dc
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - ">="
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements:
79
+ - jar commons-io, commons-io, 2.6
80
+ rubyforge_project:
81
+ rubygems_version: 2.7.6
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: JRuby library wrapping Apache Commons IO File Monitor.
85
+ test_files: []