adaptation 0.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.
Files changed (64) hide show
  1. data/CHANGELOG +1 -0
  2. data/README +90 -0
  3. data/bin/about +5 -0
  4. data/bin/adaptation +19 -0
  5. data/bin/destroy +5 -0
  6. data/bin/generate +5 -0
  7. data/bin/mom +8 -0
  8. data/bin/subscribe +8 -0
  9. data/configs/boot.rb +10 -0
  10. data/configs/databases/mysql.yml +48 -0
  11. data/configs/empty.log +0 -0
  12. data/configs/mom.yml +8 -0
  13. data/dispatches/dispatch.rb +8 -0
  14. data/dispatches/publish.rb +11 -0
  15. data/doc/README_FOR_APP +2 -0
  16. data/fresh_rakefile +10 -0
  17. data/helpers/publish.rb +24 -0
  18. data/helpers/test_helper.rb +6 -0
  19. data/lib/adaptation/adaptor.rb +32 -0
  20. data/lib/adaptation/base.rb +70 -0
  21. data/lib/adaptation/message.rb +328 -0
  22. data/lib/adaptation/mom.rb +70 -0
  23. data/lib/adaptation/oapdaemon.rb +38 -0
  24. data/lib/adaptation/test/test_help.rb +282 -0
  25. data/lib/adaptation/version.rb +9 -0
  26. data/lib/adaptation.rb +5 -0
  27. data/lib/commands/about.rb +3 -0
  28. data/lib/commands/destroy.rb +6 -0
  29. data/lib/commands/generate.rb +6 -0
  30. data/lib/commands/mom.rb +8 -0
  31. data/lib/commands/subscribe.rb +11 -0
  32. data/lib/commands.rb +17 -0
  33. data/lib/rails_generator/base.rb +262 -0
  34. data/lib/rails_generator/commands.rb +582 -0
  35. data/lib/rails_generator/generated_attribute.rb +42 -0
  36. data/lib/rails_generator/generators/applications/app/USAGE +13 -0
  37. data/lib/rails_generator/generators/applications/app/app_generator.rb +133 -0
  38. data/lib/rails_generator/generators/components/adaptor/USAGE +25 -0
  39. data/lib/rails_generator/generators/components/adaptor/adaptor_generator.rb +21 -0
  40. data/lib/rails_generator/generators/components/adaptor/templates/adaptor.rb +6 -0
  41. data/lib/rails_generator/generators/components/adaptor/templates/functional_test.rb +16 -0
  42. data/lib/rails_generator/generators/components/message/USAGE +16 -0
  43. data/lib/rails_generator/generators/components/message/message_generator.rb +28 -0
  44. data/lib/rails_generator/generators/components/message/templates/fixtures.xml +3 -0
  45. data/lib/rails_generator/generators/components/message/templates/message.rb +2 -0
  46. data/lib/rails_generator/generators/components/message/templates/unit_test.rb +25 -0
  47. data/lib/rails_generator/generators/components/model/USAGE +26 -0
  48. data/lib/rails_generator/generators/components/model/model_generator.rb +38 -0
  49. data/lib/rails_generator/generators/components/model/templates/fixtures.yml +11 -0
  50. data/lib/rails_generator/generators/components/model/templates/migration.rb +13 -0
  51. data/lib/rails_generator/generators/components/model/templates/model.rb +2 -0
  52. data/lib/rails_generator/generators/components/model/templates/unit_test.rb +10 -0
  53. data/lib/rails_generator/lookup.rb +209 -0
  54. data/lib/rails_generator/manifest.rb +53 -0
  55. data/lib/rails_generator/options.rb +143 -0
  56. data/lib/rails_generator/scripts/destroy.rb +7 -0
  57. data/lib/rails_generator/scripts/generate.rb +7 -0
  58. data/lib/rails_generator/scripts/update.rb +12 -0
  59. data/lib/rails_generator/scripts.rb +85 -0
  60. data/lib/rails_generator/simple_logger.rb +46 -0
  61. data/lib/rails_generator/spec.rb +44 -0
  62. data/lib/rails_generator.rb +43 -0
  63. data/lib/ruby_version_check.rb +17 -0
  64. metadata +142 -0
@@ -0,0 +1,143 @@
1
+ require 'optparse'
2
+
3
+ module Rails
4
+ module Generator
5
+ module Options
6
+ def self.included(base)
7
+ base.extend(ClassMethods)
8
+ class << base
9
+ if respond_to?(:inherited)
10
+ alias_method :inherited_without_options, :inherited
11
+ end
12
+ alias_method :inherited, :inherited_with_options
13
+ end
14
+ end
15
+
16
+ module ClassMethods
17
+ def inherited_with_options(sub)
18
+ inherited_without_options(sub) if respond_to?(:inherited_without_options)
19
+ sub.extend(Rails::Generator::Options::ClassMethods)
20
+ end
21
+
22
+ def mandatory_options(options = nil)
23
+ if options
24
+ write_inheritable_attribute(:mandatory_options, options)
25
+ else
26
+ read_inheritable_attribute(:mandatory_options) or write_inheritable_attribute(:mandatory_options, {})
27
+ end
28
+ end
29
+
30
+ def default_options(options = nil)
31
+ if options
32
+ write_inheritable_attribute(:default_options, options)
33
+ else
34
+ read_inheritable_attribute(:default_options) or write_inheritable_attribute(:default_options, {})
35
+ end
36
+ end
37
+
38
+ # Merge together our class options. In increasing precedence:
39
+ # default_options (class default options)
40
+ # runtime_options (provided as argument)
41
+ # mandatory_options (class mandatory options)
42
+ def full_options(runtime_options = {})
43
+ default_options.merge(runtime_options).merge(mandatory_options)
44
+ end
45
+
46
+ end
47
+
48
+ # Each instance has an options hash that's populated by #parse.
49
+ def options
50
+ @options ||= {}
51
+ end
52
+ attr_writer :options
53
+
54
+ protected
55
+ # Convenient access to class mandatory options.
56
+ def mandatory_options
57
+ self.class.mandatory_options
58
+ end
59
+
60
+ # Convenient access to class default options.
61
+ def default_options
62
+ self.class.default_options
63
+ end
64
+
65
+ # Merge together our instance options. In increasing precedence:
66
+ # default_options (class default options)
67
+ # options (instance options)
68
+ # runtime_options (provided as argument)
69
+ # mandatory_options (class mandatory options)
70
+ def full_options(runtime_options = {})
71
+ self.class.full_options(options.merge(runtime_options))
72
+ end
73
+
74
+ # Parse arguments into the options hash. Classes may customize
75
+ # parsing behavior by overriding these methods:
76
+ # #banner Usage: ./script/generate [options]
77
+ # #add_options! Options:
78
+ # some options..
79
+ # #add_general_options! General Options:
80
+ # general options..
81
+ def parse!(args, runtime_options = {})
82
+ self.options = {}
83
+
84
+ @option_parser = OptionParser.new do |opt|
85
+ opt.banner = banner
86
+ add_options!(opt)
87
+ add_general_options!(opt)
88
+ opt.parse!(args)
89
+ end
90
+
91
+ return args
92
+ ensure
93
+ self.options = full_options(runtime_options)
94
+ end
95
+
96
+ # Raise a usage error. Override usage_message to provide a blurb
97
+ # after the option parser summary.
98
+ def usage(message = usage_message)
99
+ raise UsageError, "#{@option_parser}\n#{message}"
100
+ end
101
+
102
+ def usage_message
103
+ ''
104
+ end
105
+
106
+ # Override with your own usage banner.
107
+ def banner
108
+ "Usage: #{$0} [options]"
109
+ end
110
+
111
+ # Override to add your options to the parser:
112
+ # def add_options!(opt)
113
+ # opt.on('-v', '--verbose') { |value| options[:verbose] = value }
114
+ # end
115
+ def add_options!(opt)
116
+ end
117
+
118
+ # Adds general options like -h and --quiet. Usually don't override.
119
+ def add_general_options!(opt)
120
+ opt.separator ''
121
+ opt.separator 'Adaptation Info:'
122
+ opt.on('-v', '--version', 'Show the Rails version number and quit.')
123
+ opt.on('-h', '--help', 'Show this help message and quit.') { |v| options[:help] = v }
124
+
125
+ opt.separator ''
126
+ opt.separator 'General Options:'
127
+
128
+ opt.on('-p', '--pretend', 'Run but do not make any changes.') { |v| options[:pretend] = v }
129
+ opt.on('-f', '--force', 'Overwrite files that already exist.') { options[:collision] = :force }
130
+ opt.on('-s', '--skip', 'Skip files that already exist.') { options[:collision] = :skip }
131
+ opt.on('-q', '--quiet', 'Suppress normal output.') { |v| options[:quiet] = v }
132
+ opt.on('-t', '--backtrace', 'Debugging: show backtrace on errors.') { |v| options[:backtrace] = v }
133
+ opt.on('-c', '--svn', 'Modify files with subversion. (Note: svn must be in path)') do
134
+ options[:svn] = `svn status`.inject({}) do |opt, e|
135
+ opt[e.chomp[7..-1]] = true
136
+ opt
137
+ end
138
+ end
139
+ end
140
+
141
+ end
142
+ end
143
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../scripts'
2
+
3
+ module Rails::Generator::Scripts
4
+ class Destroy < Base
5
+ mandatory_options :command => :destroy
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../scripts'
2
+
3
+ module Rails::Generator::Scripts
4
+ class Generate < Base
5
+ mandatory_options :command => :create
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../scripts'
2
+
3
+ module Rails::Generator::Scripts
4
+ class Update < Base
5
+ mandatory_options :command => :update
6
+
7
+ protected
8
+ def banner
9
+ "Usage: #{$0} [options] scaffold"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,85 @@
1
+ require File.dirname(__FILE__) + '/options'
2
+
3
+ module Rails
4
+ module Generator
5
+ module Scripts
6
+
7
+ # Generator scripts handle command-line invocation. Each script
8
+ # responds to an invoke! class method which handles option parsing
9
+ # and generator invocation.
10
+ class Base
11
+ include Options
12
+ default_options :collision => :ask, :quiet => false
13
+
14
+ # Run the generator script. Takes an array of unparsed arguments
15
+ # and a hash of parsed arguments, takes the generator as an option
16
+ # or first remaining argument, and invokes the requested command.
17
+ def run(args = [], runtime_options = {})
18
+ begin
19
+ parse!(args.dup, runtime_options)
20
+ rescue OptionParser::InvalidOption => e
21
+ # Don't cry, script. Generators want what you think is invalid.
22
+ end
23
+
24
+ # Generator name is the only required option.
25
+ unless options[:generator]
26
+ usage if args.empty?
27
+ options[:generator] ||= args.shift
28
+ end
29
+
30
+ # Look up generator instance and invoke command on it.
31
+ Rails::Generator::Base.instance(options[:generator], args, options).command(options[:command]).invoke!
32
+ rescue => e
33
+ puts e
34
+ puts " #{e.backtrace.join("\n ")}\n" if options[:backtrace]
35
+ raise SystemExit
36
+ end
37
+
38
+ protected
39
+ # Override with your own script usage banner.
40
+ def banner
41
+ "Usage: #{$0} generator [options] [args]"
42
+ end
43
+
44
+ def usage_message
45
+ usage = "\nInstalled Generators\n"
46
+ Rails::Generator::Base.sources.each do |source|
47
+ label = source.label.to_s.capitalize
48
+ names = source.names
49
+ usage << " #{label}: #{names.join(', ')}\n" unless names.empty?
50
+ end
51
+
52
+ #usage << <<end_blurb
53
+
54
+ #More are available at http://rubyonrails.org/show/Generators
55
+ # 1. Download, for example, login_generator.zip
56
+ # 2. Unzip to directory #{Dir.user_home}/.rails/generators/login
57
+ # to use the generator with all your Rails apps
58
+ #end_blurb
59
+
60
+ # if Object.const_defined?(:RAILS_ROOT)
61
+ # usage << <<end_blurb
62
+ # or to #{File.expand_path(RAILS_ROOT)}/generators/login
63
+ # to use with this app only.
64
+ #end_blurb
65
+ # end
66
+
67
+ usage << <<end_blurb
68
+
69
+ Run generate with no arguments for usage information
70
+ #{$0} adaptor
71
+ end_blurb
72
+
73
+ #Generator gems are also available:
74
+ # 1. gem search -r generator
75
+ # 2. gem install login_generator
76
+ # 3. #{$0} login
77
+
78
+ #end_blurb
79
+ return usage
80
+ end
81
+ end # Base
82
+
83
+ end
84
+ end
85
+ end
@@ -0,0 +1,46 @@
1
+ module Rails
2
+ module Generator
3
+ class SimpleLogger # :nodoc:
4
+ attr_reader :out
5
+ attr_accessor :quiet
6
+
7
+ def initialize(out = $stdout)
8
+ @out = out
9
+ @quiet = false
10
+ @level = 0
11
+ end
12
+
13
+ def log(status, message, &block)
14
+ @out.print("%12s %s%s\n" % [status, ' ' * @level, message]) unless quiet
15
+ indent(&block) if block_given?
16
+ end
17
+
18
+ def indent(&block)
19
+ @level += 1
20
+ if block_given?
21
+ begin
22
+ block.call
23
+ ensure
24
+ outdent
25
+ end
26
+ end
27
+ end
28
+
29
+ def outdent
30
+ @level -= 1
31
+ if block_given?
32
+ begin
33
+ block.call
34
+ ensure
35
+ indent
36
+ end
37
+ end
38
+ end
39
+
40
+ private
41
+ def method_missing(method, *args, &block)
42
+ log(method.to_s, args.first, &block)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,44 @@
1
+ module Rails
2
+ module Generator
3
+ # A spec knows where a generator was found and how to instantiate it.
4
+ # Metadata include the generator's name, its base path, and the source
5
+ # which yielded it (PathSource, GemSource, etc.)
6
+ class Spec
7
+ attr_reader :name, :path, :source
8
+
9
+ def initialize(name, path, source)
10
+ @name, @path, @source = name, path, source
11
+ end
12
+
13
+ # Look up the generator class. Require its class file, find the class
14
+ # in ObjectSpace, tag it with this spec, and return.
15
+ def klass
16
+ unless @klass
17
+ require class_file
18
+ @klass = lookup_class
19
+ @klass.spec = self
20
+ end
21
+ @klass
22
+ end
23
+
24
+ def class_file
25
+ "#{path}/#{name}_generator.rb"
26
+ end
27
+
28
+ def class_name
29
+ "#{name.camelize}Generator"
30
+ end
31
+
32
+ private
33
+ # Search for the first Class descending from Rails::Generator::Base
34
+ # whose name matches the requested class name.
35
+ def lookup_class
36
+ ObjectSpace.each_object(Class) do |obj|
37
+ return obj if obj.ancestors.include?(Rails::Generator::Base) and
38
+ obj.name.split('::').last == class_name
39
+ end
40
+ raise NameError, "Missing #{class_name} class in #{class_file}"
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,43 @@
1
+ #--
2
+ # Copyright (c) 2004 Jeremy Kemper
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ $:.unshift(File.dirname(__FILE__))
25
+ $:.unshift(File.dirname(__FILE__) + "/../../activesupport/lib")
26
+
27
+ begin
28
+ require 'active_support'
29
+ rescue LoadError
30
+ require 'rubygems'
31
+ gem 'activesupport'
32
+ end
33
+
34
+ require 'rails_generator/base'
35
+ require 'rails_generator/lookup'
36
+ require 'rails_generator/commands'
37
+
38
+ Rails::Generator::Base.send(:include, Rails::Generator::Lookup)
39
+ Rails::Generator::Base.send(:include, Rails::Generator::Commands)
40
+
41
+ # Set up a default logger for convenience.
42
+ require 'rails_generator/simple_logger'
43
+ Rails::Generator::Base.logger = Rails::Generator::SimpleLogger.new(STDOUT)
@@ -0,0 +1,17 @@
1
+ min_release = "1.8.2 (2004-12-25)"
2
+ ruby_release = "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE})"
3
+ if ruby_release =~ /1\.8\.3/
4
+ abort <<-end_message
5
+
6
+ Adaptation does not work with Ruby version 1.8.3.
7
+ Please upgrade to version 1.8.4 or downgrade to 1.8.2.
8
+
9
+ end_message
10
+ elsif ruby_release < min_release
11
+ abort <<-end_message
12
+
13
+ Adaptation requires Ruby version #{min_release} or later.
14
+ You're running #{ruby_release}; please upgrade to continue.
15
+
16
+ end_message
17
+ end
metadata ADDED
@@ -0,0 +1,142 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.4
3
+ specification_version: 1
4
+ name: adaptation
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2007-04-30 00:00:00 +02:00
8
+ summary: Framework to facilitate web-application interaction.
9
+ require_paths:
10
+ - lib
11
+ email: xavi@oaproject.net
12
+ homepage: http://www.oaproject.net
13
+ rubyforge_project:
14
+ description: Adaptation is a framework for building "adaptors" for web-applications, so they can interact with other web-applications publishing messages and being subscribed to a message queue.
15
+ autorequire: adaptation
16
+ default_executable: adaptation
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Xavi Vila Morell
31
+ files:
32
+ - bin/destroy
33
+ - bin/adaptation
34
+ - bin/about
35
+ - bin/subscribe
36
+ - bin/mom
37
+ - bin/generate
38
+ - lib/commands
39
+ - lib/adaptation
40
+ - lib/rails_generator.rb
41
+ - lib/commands.rb
42
+ - lib/ruby_version_check.rb
43
+ - lib/adaptation.rb
44
+ - lib/rails_generator
45
+ - lib/commands/about.rb
46
+ - lib/commands/mom.rb
47
+ - lib/commands/destroy.rb
48
+ - lib/commands/generate.rb
49
+ - lib/commands/subscribe.rb
50
+ - lib/adaptation/version.rb
51
+ - lib/adaptation/base.rb
52
+ - lib/adaptation/message.rb
53
+ - lib/adaptation/mom.rb
54
+ - lib/adaptation/adaptor.rb
55
+ - lib/adaptation/oapdaemon.rb
56
+ - lib/adaptation/test
57
+ - lib/adaptation/test/test_help.rb
58
+ - lib/rails_generator/scripts
59
+ - lib/rails_generator/base.rb
60
+ - lib/rails_generator/lookup.rb
61
+ - lib/rails_generator/commands.rb
62
+ - lib/rails_generator/simple_logger.rb
63
+ - lib/rails_generator/scripts.rb
64
+ - lib/rails_generator/manifest.rb
65
+ - lib/rails_generator/generated_attribute.rb
66
+ - lib/rails_generator/options.rb
67
+ - lib/rails_generator/generators
68
+ - lib/rails_generator/spec.rb
69
+ - lib/rails_generator/scripts/destroy.rb
70
+ - lib/rails_generator/scripts/generate.rb
71
+ - lib/rails_generator/scripts/update.rb
72
+ - lib/rails_generator/generators/components
73
+ - lib/rails_generator/generators/applications
74
+ - lib/rails_generator/generators/components/model
75
+ - lib/rails_generator/generators/components/message
76
+ - lib/rails_generator/generators/components/adaptor
77
+ - lib/rails_generator/generators/components/model/USAGE
78
+ - lib/rails_generator/generators/components/model/model_generator.rb
79
+ - lib/rails_generator/generators/components/model/templates
80
+ - lib/rails_generator/generators/components/model/templates/unit_test.rb
81
+ - lib/rails_generator/generators/components/model/templates/migration.rb
82
+ - lib/rails_generator/generators/components/model/templates/model.rb
83
+ - lib/rails_generator/generators/components/model/templates/fixtures.yml
84
+ - lib/rails_generator/generators/components/message/message_generator.rb
85
+ - lib/rails_generator/generators/components/message/USAGE
86
+ - lib/rails_generator/generators/components/message/templates
87
+ - lib/rails_generator/generators/components/message/templates/unit_test.rb
88
+ - lib/rails_generator/generators/components/message/templates/message.rb
89
+ - lib/rails_generator/generators/components/message/templates/fixtures.xml
90
+ - lib/rails_generator/generators/components/adaptor/USAGE
91
+ - lib/rails_generator/generators/components/adaptor/adaptor_generator.rb
92
+ - lib/rails_generator/generators/components/adaptor/templates
93
+ - lib/rails_generator/generators/components/adaptor/templates/functional_test.rb
94
+ - lib/rails_generator/generators/components/adaptor/templates/adaptor.rb
95
+ - lib/rails_generator/generators/applications/app
96
+ - lib/rails_generator/generators/applications/app/USAGE
97
+ - lib/rails_generator/generators/applications/app/app_generator.rb
98
+ - helpers/test_helper.rb
99
+ - helpers/publish.rb
100
+ - doc/README_FOR_APP
101
+ - configs/databases
102
+ - configs/empty.log
103
+ - configs/boot.rb
104
+ - configs/mom.yml
105
+ - configs/databases/mysql.yml
106
+ - dispatches/dispatch.rb
107
+ - dispatches/publish.rb
108
+ - README
109
+ - CHANGELOG
110
+ - fresh_rakefile
111
+ test_files: []
112
+
113
+ rdoc_options:
114
+ - --main
115
+ - README
116
+ extra_rdoc_files:
117
+ - README
118
+ executables:
119
+ - adaptation
120
+ extensions: []
121
+
122
+ requirements: []
123
+
124
+ dependencies:
125
+ - !ruby/object:Gem::Dependency
126
+ name: roxml
127
+ version_requirement:
128
+ version_requirements: !ruby/object:Gem::Version::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: "1.1"
133
+ version:
134
+ - !ruby/object:Gem::Dependency
135
+ name: activerecord
136
+ version_requirement:
137
+ version_requirements: !ruby/object:Gem::Version::Requirement
138
+ requirements:
139
+ - - ">"
140
+ - !ruby/object:Gem::Version
141
+ version: 0.0.0
142
+ version: