nailgun 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ .idea/
5
+ .idea/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in acts_as_flying_saucer.gemspec
4
+ gemspec
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,84 @@
1
+ Nailgun
2
+ =======
3
+ [Nailgun][1] is server that preloads JVM so no need to load JVM on each request.
4
+
5
+
6
+ nailgun is a ruby wrapper of nailgun server and it's command.
7
+
8
+
9
+ Make sure before installing You have to set **classpath environment variable**
10
+ which is point to jre/lib path.
11
+
12
+
13
+ [1]:http://martiansoftware.com/nailgun
14
+ Install
15
+ =======
16
+
17
+ <code>./script/plugin install git://github.com/amardaxini/nailgun.git</code>
18
+
19
+ <code>rake nailgun</code>
20
+
21
+ OR
22
+ <code> sudo gem insatll nailgun </code>
23
+
24
+
25
+
26
+ Configuration
27
+ ==============
28
+
29
+ These are the default settings which can be overwritten in your enviroment configuration file:
30
+ <code>
31
+
32
+
33
+ Nailgun::NailgunConfig.options =
34
+ {
35
+ :java_bin => "java",
36
+ :server_address =>'localhost',
37
+ :port_no=>'2113'
38
+ }
39
+
40
+
41
+ </code>
42
+ Example
43
+ =======
44
+ Run Rake Task
45
+
46
+ Install as a plugin
47
+
48
+ <code>
49
+ rake nailgun
50
+ </code>
51
+
52
+ To start nailgun server(if you want you can overwrite default configuration)
53
+
54
+ <code> script/nailgun start</code>
55
+
56
+ To stop nailgun server
57
+
58
+ <code>script/nailgun stop</code>
59
+
60
+ Install as a Gem
61
+ It will generate local configuration for nailgun_config
62
+ update nailgun configuration and manage nailgun
63
+
64
+ To start nailgun server(if you want you can overwrite default configuration)
65
+
66
+ <code> nailgun start</code>
67
+
68
+ To stop nailgun server
69
+
70
+ <code>nailgun stop</code>
71
+
72
+ To add client side jar
73
+
74
+ <code>Nailgun::NgCommand.ng_cp(absolute jar path)</code>
75
+
76
+ To create alias of class
77
+
78
+ <code>Nailgun::NgCommand.ng_alias(alias name,class name)</code>
79
+
80
+ Make sure that class name is exist in client side jar path and its contain main
81
+ To easy to use nailgun server best way is combine all jar to make one jar
82
+
83
+ Copyright (c) 2010 [amardaxini][1], released under the MIT license
84
+ [1]: http://railstech.com
@@ -0,0 +1,57 @@
1
+ Nailgun
2
+ =======
3
+ [Nailgun][1] is server that preloads JVM so no need to load JVM on each request.
4
+
5
+
6
+ nailgun is a ruby wrapper of nailgun server and it's command.
7
+
8
+
9
+ Make sure before installing You have to set **classpath environment variable**
10
+ which is point to jre/lib path.
11
+
12
+
13
+ [1]:http://martiansoftware.com/nailgun
14
+ Install
15
+ =======
16
+
17
+ <code>./script/plugin install git://github.com/amardaxini/nailgun.git</code>
18
+
19
+ Configuration
20
+ ==============
21
+
22
+ These are the default settings which can be overwritten in your enviroment configuration file:
23
+ <code>
24
+
25
+
26
+ Nailgun::NailgunConfig.options =
27
+ {
28
+ :java_bin => "java",
29
+ :server_address =>'localhost',
30
+ :port_no=>'2113'
31
+ }
32
+
33
+
34
+ </code>
35
+ Example
36
+ =======
37
+ To start nailgun server(if you want you can overwrite default configuration)
38
+
39
+ <code> script/nailgun start</code>
40
+
41
+ To stop nailgun server
42
+
43
+ <code>script/nailgun stop</code>
44
+
45
+ To add client side jar
46
+
47
+ <code>Nailgun::NgCommand.ng_cp(absolute jar path)</code>
48
+
49
+ To create alias of class
50
+
51
+ <code>Nailgun::NgCommand.ng_alias(alias name,class name)</code>
52
+
53
+ Make sure that class name is exist in client side jar path and its contain main
54
+ To easy to use nailgun server best way is combine all jar to make one jar
55
+
56
+ Copyright (c) 2010 [amardaxini][1], released under the MIT license
57
+ [1]: http://railstech.com
data/README~ ADDED
@@ -0,0 +1,36 @@
1
+ Nailgun
2
+ =======
3
+ Nailgun is server that preloads JVM so no need to load JVM on each request.
4
+ More you can read http://martiansoftware.com/nailgun
5
+ nailgun is a ruby wrapper of nailgun server and itc command
6
+ Make sure before installing You have to set class path environment variable
7
+ which is point to jre/lib path.
8
+
9
+ Install
10
+ =======
11
+ > ./script/plugin install
12
+ Configuration
13
+ ===========
14
+
15
+ These are the default settings which can be overwritten in your enviroment configuration file:
16
+
17
+ Nailgun::NailgunConfig.options = {
18
+ :java_bin => "java", # java binary
19
+ :server_address =>'localhost',
20
+ :port_no=>'2113'
21
+ }
22
+
23
+ Example
24
+ =======
25
+ To start nailgun server(if you want you can overwrite default configuration)
26
+ script/nailgun start
27
+ To start nailgun server
28
+ script/nailgun stop
29
+ To add client side jar
30
+ Nailgun::NgCommand.ng_cp(absolute jar path)
31
+ To create alias of class
32
+ Nailgun::NgCommand.ng_alias(alias name,class name)
33
+ Make sure that class name is exist in client side jar path and its contain main
34
+ To easy to use nailgun server best way is combine all jar to make one jar
35
+
36
+ Copyright (c) 2010 [amardaxini], released under the MIT license
@@ -0,0 +1,34 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'bundler'
5
+
6
+ #require File.expand_path('lib/tasks/acts_as_flying_saucer.rake')
7
+ Bundler::GemHelper.install_tasks
8
+ desc "Generate Nailgun script"
9
+ task :nailgun do
10
+ dest_file = File.expand_path(File.dirname(__FILE__))
11
+ src_file = File.expand_path(File.join(File.dirname(__FILE__),'lib','generator' ,'nailgun_binary'))
12
+ FileUtils.cp_r(src_file, dest_file)
13
+ File.chmod(0755,dest_file)
14
+ end
15
+ desc 'Default: run unit tests.'
16
+
17
+ task :default => :test
18
+
19
+ desc 'Test the nailgun plugin.'
20
+ Rake::TestTask.new(:test) do |t|
21
+ t.libs << 'lib'
22
+ t.libs << 'test'
23
+ t.pattern = 'test/**/*_test.rb'
24
+ t.verbose = true
25
+ end
26
+
27
+ desc 'Generate documentation for the nailgun plugin.'
28
+ Rake::RDocTask.new(:rdoc) do |rdoc|
29
+ rdoc.rdoc_dir = 'rdoc'
30
+ rdoc.title = 'Nailgun'
31
+ rdoc.options << '--line-numbers' << '--inline-source'
32
+ rdoc.rdoc_files.include('README')
33
+ rdoc.rdoc_files.include('lib/**/*.rb')
34
+ end
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'fileutils'
5
+ src_file = File.expand_path(File.join(File.dirname(__FILE__),'..','lib','generator' ,'nailgun_binary'))
6
+ FileUtils.cp_r(src_file, "nailgun_config")
7
+ puts "Nailgun Binary is generated as nailgun_config"
8
+ File.chmod(0755,"nailgun_config")
data/init.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'nailgun'
2
+
3
+
@@ -0,0 +1,6 @@
1
+ # Install hook code here
2
+ require 'rubygems'
3
+ dest_file = File.expand_path(File.join(File.dirname(__FILE__),'..','..','..', "script", 'nailgun'))
4
+ src_file = File.join('lib','generator' ,'nailgun')
5
+ FileUtils.cp_r(src_file, dest_file)
6
+ File.chmod(0755,dest_file)
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
4
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'vendor', 'plugins','nailgun','lib','nailgun.rb'))
5
+ Nailgun::NailgunServer.new(ARGV).daemonize
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'nailgun'
4
+
5
+ Nailgun::NailgunConfig.options =
6
+ {
7
+ :java_bin => "java",
8
+ :server_address =>'localhost',
9
+ :port_no=>'2114'
10
+ }
11
+
12
+ Nailgun::NailgunServer.new(ARGV).daemonize
Binary file
Binary file
Binary file
@@ -0,0 +1,35 @@
1
+ #require 'optparse'
2
+ require 'nailgun_config'
3
+ require 'ng_command'
4
+
5
+ module Nailgun
6
+ class NailgunServer
7
+ attr_accessor :args,:nailgun_options
8
+ def initialize(args)
9
+ raise ArgumentError,"please specify start|stop|-h" if args.empty?
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: #{File.basename($0)} start|stop"
12
+ opts.on('-h', '--help', 'Show this message') do
13
+ puts "Use: start to start server"
14
+ puts "Use: stop to stop server"
15
+ puts opts
16
+ exit 1
17
+ end
18
+ end
19
+ @args = opts.parse!(args)
20
+ end
21
+
22
+ def daemonize
23
+ if @args.include?('start')
24
+ Nailgun::NgCommand.start_server
25
+ elsif @args.include?('stop')
26
+ Nailgun::NgCommand.stop_server
27
+ end
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+
34
+
35
+
@@ -0,0 +1,15 @@
1
+ module Nailgun
2
+ class NailgunConfig
3
+ # default options
4
+ class << self
5
+ attr_accessor :options
6
+ end
7
+ NailgunConfig.options= {
8
+ :java_bin => "java",
9
+ :server_address => 'localhost',
10
+ :port_no=>'2113',
11
+ :run_mode => :once
12
+ }
13
+
14
+ end
15
+ end
@@ -0,0 +1,62 @@
1
+ #require 'nailgun_config'
2
+ module Nailgun
3
+ class NgCommand
4
+ if RUBY_PLATFORM =~ /linux/
5
+ if RUBY_PLATFORM =~ /x86_64/
6
+ OS_PLATFORM = 'linux64'
7
+ else
8
+ OS_PLATFORM = 'linux32'
9
+ end
10
+ elsif RUBY_PLATFORM =~ /darwin/
11
+ OS_PLATFORM = 'darwin'
12
+ else
13
+ OS_PLATFORM = 'win32'
14
+ end
15
+ begin
16
+ NGPATH = File.expand_path(File.join(File.dirname(__FILE__), 'java','bin',OS_PLATFORM,'ng'))
17
+ rescue Exception
18
+ puts "cant find os version"
19
+ end
20
+ JAVAPATH = Nailgun::NailgunConfig.options[:java_bin]
21
+ NGJAR = File.expand_path(File.join(File.dirname(__FILE__), 'java','jar','nailgun-0.7.1.jar'))
22
+
23
+ def self.start_server(port_no="",server_address="")
24
+ server_address = Nailgun::NailgunConfig.options[:server_address] if server_address.empty?
25
+ port_no = Nailgun::NailgunConfig.options[:port_no] if port_no.empty?
26
+ arguments = "#{server_address}:#{port_no}"
27
+ command= "nohup #{JAVAPATH} -jar #{NGJAR} #{arguments} > /dev/null 2>&1 &"
28
+ # puts command
29
+ system(command)
30
+ end
31
+
32
+ def self.stop_server(port_no="",server_address="")
33
+ server_address = Nailgun::NailgunConfig.options[:server_address] if server_address.empty?
34
+ port_no = Nailgun::NailgunConfig.options[:port_no] if port_no.empty?
35
+ command ="#{NGPATH} --nailgun-port #{port_no} --nailgun-server #{server_address} ng-stop"
36
+ # puts command
37
+ system(command)
38
+ end
39
+
40
+ def self.ng_cp(absolute_jar_path,port_no="",server_address="")
41
+ server_address = Nailgun::NailgunConfig.options[:server_address] if server_address.empty?
42
+ port_no = Nailgun::NailgunConfig.options[:port_no] if port_no.empty?
43
+ command ="#{NGPATH} --nailgun-port #{port_no} --nailgun-server #{server_address} ng-cp #{absolute_jar_path}"
44
+ # puts command
45
+ system(command)
46
+ end
47
+
48
+ def self.ng_alias(alias_name,class_name,port_no="",server_address="")
49
+ server_address = Nailgun::NailgunConfig.options[:server_address] if server_address.empty?
50
+ port_no = Nailgun::NailgunConfig.options[:port_no] if port_no.empty?
51
+ command = "#{NGPATH} --nailgun-port #{port_no} --nailgun-server #{server_address} ng-alias #{alias_name} #{class_name}"
52
+ #puts command
53
+ system(command)
54
+ end
55
+
56
+ def self.ng_version
57
+ command = "#{NGPATH} --nailgun-version"
58
+ # puts command
59
+ system(command)
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "nailgun"
6
+ s.version = "0.0.1"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Amar Daxini"]
9
+ s.email = ["amardaxini@gmail.com"]
10
+ s.homepage = "http://rubygems.org/gems/nailgun"
11
+ s.summary = %q{XHTML to PDF using Flying Saucer java library}
12
+ s.description = %q{XHTML to PDF using Flying Saucer java library}
13
+ s.rubyforge_project = "nailgun"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ end
@@ -0,0 +1,9 @@
1
+ desc "Generate nailgun script"
2
+
3
+ task :nailgun do
4
+ dest_file = File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','..', "script", 'nailgun'))
5
+ src_file = File.expand_path(File.join(File.dirname(__FILE__),'..','lib','generator' ,'nailgun'))
6
+ FileUtils.cp_r(src_file, dest_file)
7
+ File.chmod(0755,dest_file)
8
+ end
9
+
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class NailgunTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1 @@
1
+ # Uninstall hook code here
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nailgun
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Amar Daxini
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-25 00:00:00 +05:30
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: XHTML to PDF using Flying Saucer java library
23
+ email:
24
+ - amardaxini@gmail.com
25
+ executables:
26
+ - nailgun
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - MIT-LICENSE
35
+ - README.markdown
36
+ - README.markdown~
37
+ - README~
38
+ - Rakefile
39
+ - bin/nailgun
40
+ - init.rb
41
+ - install.rb
42
+ - lib/generator/nailgun
43
+ - lib/generator/nailgun_binary
44
+ - lib/java/bin/linux32/ng
45
+ - lib/java/bin/linux64/ng
46
+ - lib/java/bin/win32/ng.exe
47
+ - lib/java/jar/nailgun-0.7.1.jar
48
+ - lib/nailgun.rb
49
+ - lib/nailgun_config.rb
50
+ - lib/ng_command.rb
51
+ - nailgun.gemspec
52
+ - tasks/nailgun_tasks.rake
53
+ - test/nailgun_test.rb
54
+ - test/test_helper.rb
55
+ - uninstall.rb
56
+ has_rdoc: true
57
+ homepage: http://rubygems.org/gems/nailgun
58
+ licenses: []
59
+
60
+ post_install_message:
61
+ rdoc_options: []
62
+
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 3
71
+ segments:
72
+ - 0
73
+ version: "0"
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ hash: 3
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project: nailgun
86
+ rubygems_version: 1.3.7
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: XHTML to PDF using Flying Saucer java library
90
+ test_files: []
91
+