Permalink
Browse files

initial

  • Loading branch information...
0 parents commit a7bc96b456d3657e2a997ba176a6a730a741888a @kbrock committed Aug 15, 2008
Showing with 3,562 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +10 −0 Rakefile
  3. +15 −0 app/controllers/application.rb
  4. +36 −0 app/controllers/wsdl_controller.rb
  5. +172 −0 app/controllers/wsdls_controller.rb
  6. +150 −0 app/controllers/xsds_controller.rb
  7. +80 −0 app/helpers/application_helper.rb
  8. +32 −0 app/models/enumeration_def.rb
  9. +72 −0 app/models/field_def.rb
  10. +130 −0 app/models/fields_def.rb
  11. +415 −0 app/models/gen/code_gen.rb
  12. +29 −0 app/models/gen/code_template.rb
  13. +197 −0 app/models/gen/dot_gen.rb
  14. +23 −0 app/models/gen/png_gen.rb
  15. +64 −0 app/models/method_def.rb
  16. +125 −0 app/models/namespaced_node.rb
  17. +52 −0 app/models/simple_type_def.rb
  18. +49 −0 app/models/wsdl.rb
  19. +311 −0 app/models/wsdl_def.rb
  20. +36 −0 app/models/xsd.rb
  21. +14 −0 app/views/layouts/application.rhtml
  22. +70 −0 app/views/layouts/wsdls.rhtml
  23. +56 −0 app/views/layouts/xsds.rhtml
  24. +33 −0 app/views/shared/_complexelement.rhtml
  25. +17 −0 app/views/shared/_complextype.rhtml
  26. +10 −0 app/views/shared/_enumeration.rhtml
  27. +23 −0 app/views/shared/_fields_dscr.rhtml
  28. +29 −0 app/views/wsdl/index.rhtml
  29. +40 −0 app/views/wsdls/edit.rhtml
  30. +35 −0 app/views/wsdls/help.rhtml
  31. +2 −0 app/views/wsdls/meta.rhtml
  32. +57 −0 app/views/wsdls/old_show_dot.rhtml
  33. +21 −0 app/views/wsdls/show.rhtml
  34. +97 −0 app/views/wsdls/show_wsdl.rhtml
  35. +47 −0 app/views/wsdls/table.rhtml
  36. +27 −0 app/views/xsds/edit.rhtml
  37. +2 −0 app/views/xsds/meta.rhtml
  38. +39 −0 app/views/xsds/old_show_dot.rhtml
  39. +16 −0 app/views/xsds/show.rhtml
  40. +19 −0 app/views/xsds/show_xsd.rhtml
  41. +28 −0 app/views/xsds/table.rhtml
  42. +109 −0 config/boot.rb
  43. +14 −0 config/database.yml
  44. +73 −0 config/environment.rb
  45. +19 −0 config/environments/development.rb
  46. +22 −0 config/environments/production.rb
  47. +22 −0 config/environments/test.rb
  48. +10 −0 config/initializers/inflections.rb
  49. +5 −0 config/initializers/mime_types.rb
  50. +15 −0 config/initializers/new_rails_defaults.rb
  51. +25 −0 config/routes.rb
  52. +12 −0 db/migrate/001_create_wsdls.rb
  53. +12 −0 db/migrate/002_create_xsds.rb
  54. +12 −0 db/migrate/003_xsd_wsdl_relationship.rb
  55. +9 −0 db/migrate/004_wsdl_project.rb
  56. +24 −0 db/schema.rb
  57. BIN db/wsdls.sqlite3
  58. +64 −0 doc/wsdls.markdown
  59. +9 −0 lib/camel_case.rb
  60. +41 −0 lib/wsdlgen/spec/field_spec.rb
  61. +89 −0 lib/wsdlgen/spec/fields_spec.rb
  62. 0 lib/wsdlgen/spec/method_spec.rb
  63. +57 −0 lib/wsdlgen/spec/simple_type_spec.rb
  64. +30 −0 public/404.html
  65. +30 −0 public/422.html
  66. +30 −0 public/500.html
  67. 0 public/favicon.ico
  68. BIN public/images/rails.png
  69. +5 −0 public/robots.txt
  70. +17 −0 public/stylesheets/format.css
  71. +78 −0 public/stylesheets/scaffold.css
  72. +3 −0 script/about
  73. +3 −0 script/console
  74. +3 −0 script/dbconsole
  75. +3 −0 script/destroy
  76. +3 −0 script/generate
  77. +3 −0 script/performance/benchmarker
  78. +3 −0 script/performance/profiler
  79. +3 −0 script/performance/request
  80. +3 −0 script/plugin
  81. +3 −0 script/process/inspector
  82. +3 −0 script/process/reaper
  83. +3 −0 script/process/spawner
  84. +3 −0 script/runner
  85. +3 −0 script/server
@@ -0,0 +1,7 @@
+tmp
+log
+#db/*.sqlite3
+db/data.yml
+.DS_Store
+**/.DS_Store
+tmp/**/*
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,15 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => '5ef0b332ec9bb82622d79bf70898b570'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,36 @@
+class WsdlController < ApplicationController
+
+ caches_page :index, :show
+
+ def index
+ @wsdls=Wsdl.find(:all)
+ @xsds=Xsd.find(:all)
+ end
+
+# #TODO: for both, lookup mime_type :mime_type => Mime::Type["text/calendar"]
+
+ def show
+ if params[:format] == 'wsdl' or params[:format] == 'inline.wsdl'
+ wsdl
+ elsif params[:format]=='xsd'
+ xsd
+ else
+ raise "unknown format #{params[:format]}"
+ end
+ end
+
+ def wsdl
+ #wsdl is external: when .inline is in url, then embed the wsdl
+ external = params[:external]!='false' && params[:external]!=false
+
+ @wsdl=Wsdl.find_by_name(params[:id])
+ @code = @wsdl.code nil,external
+ render :template => 'wsdls/show_wsdl', :layout => false ,:content_type=>"application/xml"
+ end
+
+ def xsd
+ @xsd=Xsd.find_by_name(params[:id])
+ @code = @xsd.code
+ render :template => 'xsds/show_xsd', :layout => false, :content_type=>"application/xml"
+ end
+end
@@ -0,0 +1,172 @@
+class WsdlsController < ApplicationController
+
+ caches_page :index, :show, :meta, :table #, :java #,:new
+ #help shouldn't be in here...
+ caches_page :help
+
+ before_filter :lookup_wsdl, :except =>[:index,:new,:create, :help] #:only=>%w()
+ before_filter :expire_cache, :only=>%w(create destroy update)
+
+ # GET /wsdls
+ # GET /wsdls.xml
+ def index
+ respond_to do |format|
+ format.html { redirect_to :controller=>'wsdl'}
+ format.xml { @wsdls = Wsdl.find(:all) ; render :xml => @wsdls.to_xml }
+ end
+ end
+
+ # GET /wsdls/1
+ # GET /wsdls/1.xml
+ def show
+ begin
+ @code = @wsdl.code
+ rescue => e
+ #@code=@wsdl.contents
+ flash[:notice] = "Error in wsdl: #{e}"
+ end
+ respond_to do |format|
+ format.html # show.rhtml
+ format.xml { render :xml => @wsdl.to_xml }
+ format.wsdl { render :template => 'wsdls/show_wsdl', :layout => false }
+ format.dot { render :inline=> Gen::DotGen.new.wsdl_dot(@code,params[:ignore]), :layout => false }
+# format.dot { render :template => 'wsdls/show_dot', :layout => false }
+ format.png { png }
+ end
+ if params[:format] == 'table.html'
+ render :template => 'wsdls/table', :layout=>true
+ end
+ end
+
+ # GET /wsdls/1/java.zip
+ def java
+ #defaults to true, but otherwise false
+ external = params[:external]=='true' || params[:external]==true
+
+ @code = @wsdl.code(nil,external) #will raise exceptions - let it go through
+
+# render :text=>"e types #{@code.local_types.collect(){|t| t.name}.join(",")}"
+# return
+
+ file_name=@wsdl.zip_file_name
+ tmp_zipfile="#{RAILS_ROOT}/tmp/#{file_name}"
+ Gen::CodeGen.new.create_zip(@code,tmp_zipfile)
+ send_file tmp_zipfile, :filename=>file_name, :type=>'application/zip'
+ #File.delete(tmp_zipfile)
+ end
+
+ # GET /wsdls/1.png (called from show)
+ def png
+ #do dot
+ #put png directly into cache dir
+
+ tmp_pngfile=Gen::PngGen.new.dot_to_png("#{@wsdl.name}_wsdl", Gen::DotGen.new.wsdl_dot(@code,params[:ignore]))
+ send_file tmp_pngfile, :type=>'image/png', :disposition=>'inline'
+ #File.delete(tmp_pngfile)
+ end
+
+ def table
+ begin
+ @code = @wsdl.code
+ rescue => e
+ #@code=@wsdl.contents
+ flash[:notice] = "Error in wsdl: #{e}"
+ end
+ end
+
+# def meta
+# end
+
+ # GET /wsdls/new
+ def new
+ @wsdl = Wsdl.new
+ @wsdl.host='localhost'
+ @wsdl.application='app'
+ render :action => :edit
+ end
+
+ # GET /wsdls/1;edit
+ def edit
+ end
+
+ # POST /wsdls
+ # POST /wsdls.xml
+ def create
+ expire_page(:controller => 'wsdl', :action => 'show')
+ @wsdl = Wsdl.new(params[:wsdl])
+
+ respond_to do |format|
+ if @wsdl.save
+ flash[:notice] = 'Wsdl was successfully created.'
+ format.html { redirect_to wsdl_url(@wsdl) }
+ format.xml { head :created, :location => wsdl_url(@wsdl) }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @wsdl.errors.to_xml }
+ end
+ end
+ end
+
+ # PUT /wsdls/1
+ # PUT /wsdls/1.xml
+ def update
+ #ensure empty groups get cleared out
+ if !params['wsdl']['xsd_ids']
+ @wsdl.xsds.clear
+ end
+
+ respond_to do |format|
+ if @wsdl.update_attributes(params[:wsdl])
+ flash[:notice] = 'Wsdl was successfully updated.'
+ format.html { redirect_to wsdl_url(@wsdl) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @wsdl.errors.to_xml }
+ end
+ end
+ end
+
+ # DELETE /wsdls/1
+ # DELETE /wsdls/1.xml
+ # success was wsdls_url
+ def destroy
+ @wsdl.destroy
+
+ respond_to do |format|
+ format.html { redirect_to '/wsdl/' }
+ format.xml { head :ok }
+ end
+ end
+
+ # GET /wsdls/help.html
+ def help
+ end
+
+ protected
+
+ def lookup_wsdl
+# @wsdl = Wsdl.find_by_name(params[:id])
+ @wsdl = Wsdl.find(params[:id])
+ end
+
+ def expire_cache
+ #expire all my instances
+ unless @wsdl.nil? or @wsdl.id.nil?
+ expire_wsdl(@wsdl)
+ end
+ #aggrigate index page. (html version doesn't exist)
+ expire_page(:controller=>'wsdl', :action => 'index')
+ expire_page(:controller=>'wsdls', :action => 'index', :format => 'xml')
+ end
+
+ def expire_wsdl(wsdl)
+ expire_page(:controller=>'wsdls', :action => 'show', :id=>wsdl.id) #dot,png,html,...
+ expire_page(:controller=>'wsdls', :action => 'meta', :format => 'html', :id=>wsdl.id)
+ expire_page(:controller=>'wsdls', :action => 'table', :format => 'html', :id=>wsdl.id)
+ expire_page(:controller=>'wsdls', :action => 'java', :format => 'zip', :id=>wsdl.id)
+
+ expire_page(:controller=>'wsdl', :action => 'show', :id=>wsdl.name, :format => 'wsdl')
+ expire_page(:controller=>'wsdl', :action => 'show', :id=>wsdl.name, :format => 'inline.wsdl')
+ end
+end
@@ -0,0 +1,150 @@
+class XsdsController < ApplicationController
+ caches_page :index, :show, :meta, :table, :java #,:new
+
+ before_filter :lookup_xsd, :except =>[:index,:new,:create] #:only=>%w()
+
+ # GET /xsds
+ # GET /xsds.xml
+ def index
+ @xsds = Xsd.find(:all)
+ respond_to do |format|
+ format.html { redirect_to :controller=>'wsdl'}
+ format.xml { render :xml => @wsdls.to_xml }
+ end
+ end
+
+ # GET /xsds/1
+ # GET /xsds/1.xml
+ def show
+ begin
+ @code = @xsd.code
+ rescue => e
+ flash[:notice] = "Error in xsd: #{e}"
+ end
+ respond_to do |format|
+ format.html # show.rhtml
+ format.xml { render :xml => @xsd.to_xml }
+ format.xsd { render :template => 'xsds/show_xsd', :layout => false }
+ format.dot { render :inline=> Gen::DotGen.new.xsd_dot(@code,params[:ignore]), :layout => false }
+ format.png { png }
+ end
+ end
+
+ # GET /xsds/1/java
+ def java
+# if params[:layout] == "true"
+# layout=true
+# else #default to inlined code
+# layout=false
+# end
+#
+# @code = @xsd.code(nil,false) #will raise exceptions - let it go through
+ @code = @xsd.code #will raise exceptions - let it go through
+
+ file_name=@xsd.zip_file_name
+ tmp_zipfile="#{RAILS_ROOT}/tmp/#{file_name}"
+ Gen::CodeGen.new.create_zip(@code,tmp_zipfile)
+ send_file tmp_zipfile, :filename=>file_name, :type=>'application/zip'
+ #File.delete(tmp_zipfile)
+ end
+
+ # GET /xsds/1.png (called from show)
+ def png
+ tmp_pngfile=Gen::PngGen.new.dot_to_png("#{@xsd.name}_xsd",Gen::DotGen.new.xsd_dot(@code,params[:ignore]))
+ send_file tmp_pngfile, :type=>'image/png', :disposition=>'inline'
+ end
+
+ # GET /xsds/1/table.html
+ def table
+ begin
+ @code = @xsd.code
+ rescue => e
+ #@code=@wsdl.contents
+ flash[:notice] = "Error in xsd: #{e}"
+ end
+ end
+
+ # GET /xsds/new
+ def new
+ @xsd = Xsd.new
+ render :action => :edit
+ end
+
+ # GET /xsds/1/edit
+ def edit
+ end
+
+ # POST /xsds
+ # POST /xsds.xml
+ def create
+ @xsd = Xsd.new(params[:xsd])
+
+ respond_to do |format|
+ if @xsd.save
+ flash[:notice] = 'Xsd was successfully created.'
+ format.html { redirect_to xsd_url(@xsd) }
+ format.xml { head :created, :location => xsd_url(@xsd) }
+ else
+ format.html { render :action => "new" }
+ format.xml { render :xml => @xsd.errors.to_xml }
+ end
+ end
+ end
+
+ # PUT /xsds/1
+ # PUT /xsds/1.xml
+ def update
+
+ respond_to do |format|
+ if @xsd.update_attributes(params[:xsd])
+ flash[:notice] = 'Xsd was successfully updated.'
+ format.html { redirect_to xsd_url(@xsd) }
+ format.xml { head :ok }
+ else
+ format.html { render :action => "edit" }
+ format.xml { render :xml => @xsd.errors.to_xml }
+ end
+ end
+ end
+
+ # DELETE /xsds/1
+ # DELETE /xsds/1.xml
+ # success was xsds_url
+ def destroy
+ @xsd.destroy
+
+ respond_to do |format|
+ format.html { redirect_to '/wsdl/' }
+ format.xml { head :ok }
+ end
+ end
+
+ protected
+
+ def lookup_xsd
+ @xsd = Xsd.find_by_id(params[:id])
+ end
+
+ def expire_cache
+ #expire all my instances
+ expire_xsd(@xds)
+ unless @xsd.nil? or @xsd.id.nil? or @xsd.wsdls.nil?
+ @xsd.wsdls.each do |w|
+ # WsdlsController.expire_wsdl(w)
+ expire_page(:controller=>'wsdl', :action => 'show', :id=>wsdl.name, :format => 'inline.wsdl')
+ end
+ end
+ #move to wsdl?
+ #aggrigate index page. (html version doesn't exist)
+ expire_page(:controller=>'wsdl', :action => 'index')
+ expire_page(:controller=>'xsds', :action => 'index', :format => 'xml')
+ end
+
+ def expire_xsd(xsd)
+ expire_page(:controller=>'xsds', :action => 'show', :id=>xsd.id) #dot,png,html,...
+ expire_page(:controller=>'xsds', :action => 'meta', :format => 'html', :id=>xsd.id)
+ expire_page(:controller=>'xsds', :action => 'table', :format => 'html', :id=>xsd.id)
+ expire_page(:controller=>'xsds', :action => 'java', :format => 'zip', :id=>xsd.id)
+ expire_page(:controller=>'wsdl', :action => 'show', :id=>xsd.name, :format => 'xsd')
+ end
+end
Oops, something went wrong.

0 comments on commit a7bc96b

Please sign in to comment.