trinidad_valve_extension 0.1

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.
data/History.txt ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Michael Leinartas
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.
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,156 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'date'
4
+
5
+ ## Credit
6
+ # Copied from https://github.com/trinidad/trinidad_init_services/blob/master/Rakefile
7
+ #############################################################################
8
+ #
9
+ # Helper functions
10
+ #
11
+ #############################################################################
12
+
13
+ def name
14
+ @name ||= Dir['*.gemspec'].first.split('.').first
15
+ end
16
+
17
+ def version
18
+ line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
19
+ line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
20
+ end
21
+
22
+ def date
23
+ Date.today.to_s
24
+ end
25
+
26
+ def rubyforge_project
27
+ name
28
+ end
29
+
30
+ def gemspec_file
31
+ "#{name}.gemspec"
32
+ end
33
+
34
+ def gem_file
35
+ "#{name}-#{version}.gem"
36
+ end
37
+
38
+ def replace_header(head, header_name)
39
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
40
+ end
41
+
42
+ #############################################################################
43
+ #
44
+ # Standard tasks
45
+ #
46
+ #############################################################################
47
+
48
+ task :default => :test
49
+
50
+ require 'rake/testtask'
51
+ Rake::TestTask.new(:test) do |test|
52
+ test.libs << 'lib' << 'test'
53
+ test.pattern = 'test/**/test_*.rb'
54
+ test.verbose = true
55
+ end
56
+
57
+ desc "Generate RCov test coverage and open in your browser"
58
+ task :coverage do
59
+ require 'rcov'
60
+ sh "rm -fr coverage"
61
+ sh "rcov test/test_*.rb"
62
+ sh "open coverage/index.html"
63
+ end
64
+
65
+ require 'rake/rdoctask'
66
+ Rake::RDocTask.new do |rdoc|
67
+ rdoc.rdoc_dir = 'rdoc'
68
+ rdoc.title = "#{name} #{version}"
69
+ rdoc.rdoc_files.include('README*')
70
+ rdoc.rdoc_files.include('lib/**/*.rb')
71
+ end
72
+
73
+ desc "Open an irb session preloaded with this library"
74
+ task :console do
75
+ sh "irb -rubygems -r ./lib/#{name}.rb"
76
+ end
77
+
78
+ #############################################################################
79
+ #
80
+ # Custom tasks (add your own tasks here)
81
+ #
82
+ #############################################################################
83
+
84
+
85
+
86
+ #############################################################################
87
+ #
88
+ # Packaging tasks
89
+ #
90
+ #############################################################################
91
+
92
+ desc 'Release gem'
93
+ task :release => :build do
94
+ unless `git branch` =~ /^\* master$/
95
+ puts "You must be on the master branch to release!"
96
+ exit!
97
+ end
98
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
99
+ sh "git tag v#{version}"
100
+ sh "git push origin master"
101
+ sh "git push --tags"
102
+ sh "gem push pkg/#{gem_file}"
103
+ end
104
+
105
+ desc 'Build gem'
106
+ task :build => :gemspec do
107
+ sh "mkdir -p pkg"
108
+ sh "gem build #{gemspec_file}"
109
+ sh "mv #{gem_file} pkg"
110
+ end
111
+
112
+ desc 'Install gem'
113
+ task :install => :build do
114
+ sh "gem install pkg/#{gem_file}"
115
+ end
116
+
117
+ desc 'Create gemspec'
118
+ task :gemspec => :validate do
119
+ # read spec file and split out manifest section
120
+ spec = File.read(gemspec_file)
121
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
122
+
123
+ # replace name version and date
124
+ replace_header(head, :name)
125
+ replace_header(head, :version)
126
+ replace_header(head, :date)
127
+ #comment this out if your rubyforge_project has a different name
128
+ replace_header(head, :rubyforge_project)
129
+
130
+ # determine file list from git ls-files
131
+ files = `git ls-files`.
132
+ split("\n").
133
+ sort.
134
+ reject { |file| file =~ /^\./ }.
135
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
136
+ map { |file| " #{file}" }.
137
+ join("\n")
138
+
139
+ # piece file back together and write
140
+ manifest = " s.files = %w[\n#{files}\n ]\n"
141
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
142
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
143
+ puts "Updated #{gemspec_file}"
144
+ end
145
+
146
+ task :validate do
147
+ libfiles = Dir['lib/*'] - ["lib/#{name}.rb", "lib/#{name}"]
148
+ unless libfiles.empty?
149
+ puts "Directory `lib` should only contain a `#{name}.rb` file and `#{name}` dir."
150
+ exit!
151
+ end
152
+ unless Dir['VERSION*'].empty?
153
+ puts "A `VERSION` file at root level violates Gem best practices."
154
+ exit!
155
+ end
156
+ end
@@ -0,0 +1,50 @@
1
+ module Trinidad
2
+ module Extensions
3
+ module Valve
4
+ VERSION = '0.1'
5
+ end
6
+
7
+ class ValveWebAppExtension < WebAppExtension
8
+ def configure(tomcat, app_context)
9
+ @logger = app_context.getLogger()
10
+
11
+ @options[:valves] ||= Array.new
12
+
13
+ if not @options[:valves].empty?
14
+ @options[:valves].each do |valve_properties|
15
+ valve_properties = valve_properties.clone
16
+ class_name = valve_properties.delete 'className'
17
+
18
+ if not class_name
19
+ logger.warn("Tomcat valve defined without a 'className' attribute. Skipping definition: #{valve_properties.inspect}")
20
+ next
21
+ end
22
+
23
+ begin
24
+ valve = get_valve(class_name)
25
+ rescue NameError => e,
26
+ logger.warn("Tomcat valve '#{class_name}' not found. Ensure valve exists in your classpath")
27
+ next
28
+ end
29
+
30
+ set_valve_properties(valve, valve_properties)
31
+
32
+ # Add the valve to the context using the suggested getPipeline()
33
+ app_context.getPipeline().addValve(valve)
34
+ end
35
+ end
36
+ end
37
+
38
+ def get_valve(valve_name)
39
+ valve_class = Java::JavaClass.for_name "org.apache.catalina.valves.AccessLogValve"
40
+ valve_instance = valve_class.constructor.new_instance.to_java
41
+ end
42
+
43
+ def set_valve_properties(valve_instance, properties)
44
+ properties.each do |option,value|
45
+ valve_instance.send("#{option}=", value)
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,69 @@
1
+ ## This is the rakegem gemspec template. Make sure you read and understand
2
+ ## all of the comments. Some sections require modification, and others can
3
+ ## be deleted if you don't need them. Once you understand the contents of
4
+ ## this file, feel free to delete any comments that begin with two hash marks.
5
+ ## You can find comprehensive Gem::Specification documentation, at
6
+ ## http://docs.rubygems.org/read/chapter/20
7
+ Gem::Specification.new do |s|
8
+ s.specification_version = 2 if s.respond_to? :specification_version=
9
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
+ s.rubygems_version = '1.3.5'
11
+
12
+ ## Leave these as is they will be modified for you by the rake gemspec task.
13
+ ## If your rubyforge_project name is different, then edit it and comment out
14
+ ## the sub! line in the Rakefile
15
+ s.name = 'trinidad_valve_extension'
16
+ s.version = '0.1'
17
+ s.date = '2011-08-19'
18
+ s.rubyforge_project = 'trinidad_valve_extension'
19
+
20
+ ## Make sure your summary is short. The description may be as long
21
+ ## as you like.
22
+ s.summary = "Trinidad extension to add and configure Tomcat valves"
23
+ s.description = "Trinidad extension to add and configure Tomcat valves. Built-in Tomcat valves are always available but any valve existing in the classpath can be used"
24
+
25
+ ## List the primary authors. If there are a bunch of authors, it's probably
26
+ ## better to set the email to an email list or something. If you don't have
27
+ ## a custom homepage, consider using your GitHub URL or the like.
28
+ s.authors = ["Michael Leinartas"]
29
+ s.email = 'mleinartas@gmail.com'
30
+ s.homepage = 'http://github.com/mleinart/trinidad_valve_extension'
31
+
32
+ ## This gets added to the $LOAD_PATH so that 'lib/NAME.rb' can be required as
33
+ ## require 'NAME.rb' or'/lib/NAME/file.rb' can be as require 'NAME/file.rb'
34
+ s.require_paths = %w[lib]
35
+
36
+ ## If your gem includes any executables, list them here.
37
+ s.executables = []
38
+ #s.default_executable = ''
39
+
40
+ ## Specify any RDoc options here. You'll want to add your README and
41
+ ## LICENSE files to the extra_rdoc_files list.
42
+ s.rdoc_options = ["--charset=UTF-8"]
43
+ s.extra_rdoc_files = %w[README LICENSE]
44
+
45
+ ## List your runtime dependencies here. Runtime dependencies are those
46
+ ## that are needed for an end user to actually USE your code.
47
+ s.add_dependency('trinidad', '>=1.1.0')
48
+
49
+ ## Leave this section as-is. It will be automatically generated from the
50
+ ## contents of your Git repository via the gemspec task. DO NOT REMOVE
51
+ ## THE MANIFEST COMMENTS, they are used as delimiters by the task.
52
+ # = MANIFEST =
53
+ s.files = %w[
54
+ History.txt
55
+ LICENSE
56
+ README
57
+ Rakefile
58
+ lib/trinidad_valve_extension.rb
59
+ trinidad_valve_extension.gemspec
60
+ ]
61
+ # = MANIFEST =
62
+
63
+ ## Test files will be grabbed from the file list. Make sure the path glob
64
+ ## matches what you actually use.
65
+ ## s.test_files = s.files.select { |path| path =~ /^test\/test_.*\.rb/ }
66
+
67
+ #s.post_install_message = <<TEXT
68
+ #TEXT
69
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trinidad_valve_extension
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ version: "0.1"
9
+ platform: ruby
10
+ authors:
11
+ - Michael Leinartas
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+
16
+ date: 2011-08-19 00:00:00 -05:00
17
+ default_executable:
18
+ dependencies:
19
+ - !ruby/object:Gem::Dependency
20
+ name: trinidad
21
+ prerelease: false
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ segments:
27
+ - 1
28
+ - 1
29
+ - 0
30
+ version: 1.1.0
31
+ type: :runtime
32
+ version_requirements: *id001
33
+ description: Trinidad extension to add and configure Tomcat valves. Built-in Tomcat valves are always available but any valve existing in the classpath can be used
34
+ email: mleinartas@gmail.com
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README
41
+ - LICENSE
42
+ files:
43
+ - History.txt
44
+ - LICENSE
45
+ - README
46
+ - Rakefile
47
+ - lib/trinidad_valve_extension.rb
48
+ - trinidad_valve_extension.gemspec
49
+ has_rdoc: true
50
+ homepage: http://github.com/mleinart/trinidad_valve_extension
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options:
55
+ - --charset=UTF-8
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ segments:
63
+ - 0
64
+ version: "0"
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ segments:
70
+ - 0
71
+ version: "0"
72
+ requirements: []
73
+
74
+ rubyforge_project: trinidad_valve_extension
75
+ rubygems_version: 1.3.6
76
+ signing_key:
77
+ specification_version: 2
78
+ summary: Trinidad extension to add and configure Tomcat valves
79
+ test_files: []
80
+