marmottawrapper 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0ab551c3416a281241e942fbfbf3d2bfb1d7689e
4
- data.tar.gz: debc2199615e70f3a0ef97bb687231f52cae6127
3
+ metadata.gz: 48644a9a81da54e2dc29ab534bf662ea620bce38
4
+ data.tar.gz: 8bd2be3debd7eee2165524231fec03812529524d
5
5
  SHA512:
6
- metadata.gz: 18253cd1ed816e0b33c01f8918b32b24b8f09eba56291cd07f71e1dee24deac67e847a8bbcce2a7ae8022b00ff8c8e00f19e59550f48e10b2c85b15e18117cfe
7
- data.tar.gz: 971177a4d6076c638413019bd0732e7cf8b014c5029fc4efc421d5f7327775ffba3a57e324535f208f72f23315b51b495330e0927971382373a5b3d0b9aa5970
6
+ metadata.gz: 4bc65cb8b5fe2795ab99679ff3f5504c60e1efe334fb406a9cc51dd3a0d2ae9ba545642a245ae4f41c0aac4acaa4102b3bd65ebf522376eee1a47fde47a8ba96
7
+ data.tar.gz: e52d0def019dfc89c11610a738ae1a65511ddb2d2a5eed06eab6fd0354dfa4229d8fc9ab1a912cb9979d002a2ae61b39fddf2a0f2e17483e9874df747ce59f34
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  .extract/*
2
2
  marmotta/target/*
3
3
  Gemfile.lock
4
- .vagrant
4
+ .vagrant
5
+ *.gem
6
+ tomcat/*
data/README.md CHANGED
@@ -1,15 +1,33 @@
1
- marmotta-webapp
1
+ marmottawrapper
2
2
  ===============
3
3
 
4
4
  This project creates rake tasks to easily start up [Apache Marmotta](http://marmotta.apache.org/) in Tomcat 7.
5
5
 
6
6
  To install:
7
7
 
8
- git clone https://github.com/dpla/marmotta-webapp
9
- cd marmotta-webapp
8
+ git clone https://github.com/dpla/marmottawrapper
9
+ cd marmottawrapper
10
10
  bundle install
11
11
 
12
+ Download and install Marmotta:
13
+
14
+ rake marmotta:fetch
15
+ rake marmotta:install
16
+
12
17
  * To start a Marmotta app in Tomcat 7 on port `8080`: `rake marmotta:start`
18
+ * To stop Tomcat: `rake marmotta:stop`
19
+
20
+ Use in Rails Projects
21
+ ----------------------
22
+
23
+ A railtie is included to make the tasks available to Rails applications. To use
24
+ the railtie add `marmottawrapper` to your Gemfile and run `bundle install`.
25
+
26
+ `rake -T` should now reveal that the marmotta tasks are available:
27
+
28
+ rake marmotta:fetch
29
+ rake marmotta:install
30
+ rake marmotta:start
13
31
 
14
32
  Virtual Machine
15
33
  ---------------
@@ -24,9 +42,8 @@ Marmotta should now be available on your host machine at port `8087`.
24
42
 
25
43
  TODO:
26
44
  -----
27
- * [ ] Use a runnable/downloadable JAR file: `mvn clean package -Prunnable-war`, `java -jar target/marmotta-webapp-3.2.1-0.0.1-war-exec.jar`
28
- * [ ] Add task to download JAR, to make this easier to use in projects.
29
45
  * [ ] Make Tomcat port configurable.
46
+ * [ ] Make Marmotta configurable.
30
47
  * [ ] Wait for Tomcat to start before quitting `start` task.
31
48
 
32
49
  License: Apache 2.0
@@ -0,0 +1,12 @@
1
+ require 'marmottawrapper'
2
+ require 'rails'
3
+
4
+ module MarmottaWrapper
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :marmottawrapper
7
+
8
+ rake_tasks do
9
+ load "marmottawrapper/tasks/marmottawrapper.rake"
10
+ end
11
+ end
12
+ end
@@ -1,15 +1,18 @@
1
1
  namespace :marmotta do
2
2
 
3
- desc "remove the marmotta jar and recreate it"
3
+ desc "remove the Marmotta data directory and recreate it"
4
4
  task :clean do
5
5
  Marmottawrapper.clean
6
6
  end
7
7
 
8
- desc "rebuild the marmotta jar"
9
- task :build do
8
+ desc "fetch the Marmotta and Tomcat distribution"
9
+ task :fetch do
10
+ Marmottawrapper.fetch
11
+ end
10
12
 
11
- dir = Marmottawrapper.build
12
- puts "Marmotta jar created at #{dir}"
13
+ desc "Install the Marmotta and Tomcat distribution"
14
+ task :install do
15
+ Marmottawrapper.install
13
16
  end
14
17
 
15
18
  desc "Start Marmotta/Tomcat"
@@ -1,3 +1,3 @@
1
1
  class Marmottawrapper
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -1,7 +1,9 @@
1
1
  require 'fileutils'
2
- require 'childprocess'
3
2
 
4
3
  class Marmottawrapper
4
+
5
+ require 'marmottawrapper/railtie' if defined?(Rails)
6
+
5
7
  class << self
6
8
  def app_root
7
9
  return @app_root if @app_root
@@ -9,108 +11,61 @@ class Marmottawrapper
9
11
  @app_root ||= '.'
10
12
  end
11
13
 
14
+ def url
15
+ @url ||= defined?(ZIP_URL) ? ZIP_URL : "https://github.com/dpla/marmotta-webapp/releases/download/v0.0.4/tomcat-marmotta.zip"
16
+ end
17
+
12
18
  def marmotta_dir
13
19
  File.join(app_root, 'marmotta')
14
20
  end
15
21
 
16
- def build_dir
17
- File.join(marmotta_dir, 'target')
22
+ def tmp_dir
23
+ File.join(app_root, 'tmp')
24
+ end
25
+
26
+ def tomcat_dir
27
+ File.join(app_root, 'tomcat')
18
28
  end
19
29
 
20
30
  def clean
21
- system "rm -r #{build_dir}" if File.directory?(build_dir)
22
- build
31
+ system "rm -r #{tomcat_dir}" if File.directory?(tomcat_dir)
32
+ system "rm -r #{tmp_dir}" if File.directory?(tmp_dir)
33
+ system "rm -r #{marmotta_dir}" if File.directory?(marmotta_dir)
23
34
  end
24
35
 
25
36
  ##
26
- # Build a runnable .jar file for marmotta
27
- def build
28
- Dir.chdir(marmotta_dir) {
29
- system "mvn clean package -Prunnable-war"
37
+ # Fetch the Tomcat/Marmotta distribution
38
+ def fetch
39
+ FileUtils.makedirs(tmp_dir) unless File.directory?(tmp_dir)
40
+ FileUtils.makedirs(marmotta_dir) unless File.directory?(marmotta_dir)
41
+ Dir.chdir(tmp_dir) {
42
+ system "curl -L #{url} -o tomcat-marmotta.zip"
30
43
  }
31
44
  end
32
45
 
46
+ def install
47
+ fetch unless File.exists?(File.join(tmp_dir, 'tomcat-marmotta.zip'))
48
+ system "unzip #{tmp_dir}/tomcat-marmotta.zip"
49
+ File.delete(File.join(tmp_dir, 'tomcat-marmotta.zip'))
50
+ end
51
+
33
52
  ##
34
- # Start the Tomcat server with Marmotta on port 8080
53
+ # Start the Tomcat server with Marmotta
35
54
  def start
36
- if pid
37
- if is_running?
38
- raise("Server is already running with PID #{pid}")
39
- else
40
- puts "Removing stale PID file at #{pid_path}"
41
- File.delete(pid_path)
42
- end
43
- end
44
-
45
- Dir.chdir(marmotta_dir) {
46
- process.start
47
- }
48
-
49
- FileUtils.makedirs(pid_dir) unless File.directory?(pid_dir)
50
- File::open(pid_path, 'w') do |f|
51
- f.puts "#{process.pid}"
52
- end
53
-
54
- process.pid
55
+ system "#{tomcat_dir}/bin/startup.sh"
55
56
  end
56
57
 
57
58
  ##
58
59
  # Stop Tomcat/Marmotta
59
60
  def stop
60
- raise "No pid found in #{pid_path}" unless pid or @process
61
- if @process
62
- @process.stop
63
- else
64
- Process.kill("KILL", pid) rescue nil
65
- end
66
-
67
- begin
68
- File.delete(pid_path)
69
- rescue
70
- end
61
+ system "#{tomcat_dir}/bin/shutdown.sh"
71
62
  end
72
63
 
73
64
  def restart
74
65
  stop
66
+ sleep 2
75
67
  start
76
68
  end
77
69
 
78
- def process
79
- @process ||= begin
80
- process = ChildProcess.build('mvn', 'clean', 'tomcat7:run')
81
- # TODO: When use this instead of the above
82
- # java -jar #{build_dir}/marmotta-webapp-3.2.1-0.0.1-war-exec.jar
83
- process.detach = true
84
- process
85
- end
86
- end
87
-
88
- def is_running?
89
- begin
90
- return Process.getpgid(pid) != -1
91
- rescue Errno::ESRCH
92
- return false
93
- end
94
- end
95
-
96
- def pid
97
- File.open( pid_path ) { |f| return f.gets.to_i } if File.exist?(pid_path)
98
- end
99
-
100
- def pid_path
101
- @path = File.join(pid_dir, pid_file)
102
- end
103
-
104
- def pid_dir
105
- File.expand_path(File.join(app_root, 'tmp', 'pids'))
106
- end
107
-
108
- def pid_file
109
- 'marmotta.pid'
110
- end
111
-
112
- def pid_file?
113
- File.exist?(pid_path)
114
- end
115
70
  end
116
71
  end
data/marmotta/.gitkeep ADDED
File without changes
@@ -9,15 +9,13 @@ Gem::Specification.new do |s|
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.authors = ["Mark Matienzo", "Tom Johnson"]
11
11
  s.email = ["tech@dp.la"]
12
- s.homepage = "https://github.com/dpla/marmotta-webapp"
13
- s.summary = %q{Convenience tasks for working with marmotta from within a ruby project.}
14
- s.description = %q{Convenience tasks for working with marmotta from within a ruby project.}
12
+ s.homepage = "https://github.com/dpla/marmottawrapper"
13
+ s.summary = %q{Convenience tasks for working with Apache Marmotta from within a Ruby project.}
14
+ s.description = %q{Convenience tasks for working with Apache Marmotta from within a Ruby project.}
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.test_files = `git ls-files -- {spec}/*`.split("\n")
17
17
  s.require_paths = ["lib"]
18
18
  s.license = 'APACHE 2'
19
-
20
- s.add_dependency 'childprocess'
21
19
 
22
20
  s.add_dependency 'rake'
23
21
  s.add_development_dependency 'pry'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: marmottawrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Matienzo
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-10-07 00:00:00.000000000 Z
12
+ date: 2014-10-14 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: childprocess
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: rake
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -53,7 +39,8 @@ dependencies:
53
39
  - - ">="
54
40
  - !ruby/object:Gem::Version
55
41
  version: '0'
56
- description: Convenience tasks for working with marmotta from within a ruby project.
42
+ description: Convenience tasks for working with Apache Marmotta from within a Ruby
43
+ project.
57
44
  email:
58
45
  - tech@dp.la
59
46
  executables: []
@@ -68,30 +55,12 @@ files:
68
55
  - Vagrantfile
69
56
  - bin/setup
70
57
  - lib/marmottawrapper.rb
58
+ - lib/marmottawrapper/railtie.rb
71
59
  - lib/marmottawrapper/tasks/marmottawrapper.rake
72
60
  - lib/marmottawrapper/version.rb
73
- - marmotta/pom.xml
74
- - marmotta/src/main/resources/META-INF/beans.xml
75
- - marmotta/src/main/resources/config-defaults.properties
76
- - marmotta/src/main/resources/config-descriptions.properties
77
- - marmotta/src/main/resources/logback.xml
78
- - marmotta/src/main/webapp/META-INF/context.xml
79
- - marmotta/src/main/webapp/META-INF/jetty-web.xml
80
- - marmotta/src/main/webapp/WEB-INF/jetty-web.xml
81
- - marmotta/src/main/webapp/WEB-INF/templates/404.ftl
82
- - marmotta/src/main/webapp/WEB-INF/templates/admin.ftl
83
- - marmotta/src/main/webapp/WEB-INF/templates/rdfhtml.ftl
84
- - marmotta/src/main/webapp/WEB-INF/web.xml
85
- - marmotta/src/main/webapp/index.jsp
86
- - marmotta/src/test/resources/META-INF/beans.xml
87
- - marmotta/src/test/resources/WEB-INF/test-web.xml
88
- - marmotta/src/test/resources/jndi.properties
89
- - marmotta/src/test/resources/logback.xml
90
- - marmotta/src/test/resources/test-config.properties
91
- - marmotta/src/test/resources/verification.xml
61
+ - marmotta/.gitkeep
92
62
  - marmottawrapper.gemspec
93
- - pom.xml
94
- homepage: https://github.com/dpla/marmotta-webapp
63
+ homepage: https://github.com/dpla/marmottawrapper
95
64
  licenses:
96
65
  - APACHE 2
97
66
  metadata: {}
@@ -114,6 +83,6 @@ rubyforge_project:
114
83
  rubygems_version: 2.2.1
115
84
  signing_key:
116
85
  specification_version: 4
117
- summary: Convenience tasks for working with marmotta from within a ruby project.
86
+ summary: Convenience tasks for working with Apache Marmotta from within a Ruby project.
118
87
  test_files: []
119
88
  has_rdoc: