Permalink
Browse files

WIP:gemifying, commandifying, examplifying

moved example app to examples,
changed lib to be a ruby gem style rb lib
started working on a cli

doesn't completely work yet,
but it properly copies templates

try
   cd /tmp
   ./path-to-dubious/bin/dubious init foobar

pretty neat?
  • Loading branch information...
1 parent 15a06b3 commit e079b2ecb86e69f2e7b667323809feb7af31b6a5 @baroquebobcat baroquebobcat committed Jul 23, 2010
Showing with 6,520 additions and 135 deletions.
  1. +78 −0 bin/dubious
  2. +138 −0 examples/contacts/Rakefile
  3. 0 { → examples/contacts}/WEB-INF/appengine-web.xml
  4. BIN examples/contacts/WEB-INF/lib/appengine-api.jar
  5. BIN examples/contacts/WEB-INF/lib/application.jar
  6. BIN examples/contacts/WEB-INF/lib/dubious.jar
  7. BIN examples/contacts/WEB-INF/lib/dubydatastore.jar
  8. 0 { → examples/contacts}/WEB-INF/web.xml
  9. 0 { → examples/contacts}/app.yaml
  10. 0 { → examples/contacts}/app/controllers/application_controller.duby
  11. 0 { → examples/contacts}/app/controllers/contacts_controller.duby
  12. 0 { → examples/contacts}/app/controllers/info_properties_controller.duby
  13. 0 { → examples/contacts}/app/controllers/shout_controller.duby
  14. 0 { → examples/contacts}/app/controllers/source_controller.duby
  15. 0 { → examples/contacts}/app/models/contacts.duby
  16. 0 { → examples/contacts}/app/views/contacts/edit.html.erb
  17. 0 { → examples/contacts}/app/views/contacts/index.html.erb
  18. 0 { → examples/contacts}/app/views/contacts/new.html.erb
  19. 0 { → examples/contacts}/app/views/contacts/show.html.erb
  20. 0 { → examples/contacts}/app/views/layouts/application.html.erb
  21. 0 { → examples/contacts}/app/views/layouts/contacts.html.erb
  22. 0 { → examples/contacts}/app/views/shout/list.html.erb
  23. 0 { → examples/contacts}/app/views/source/list.html.erb
  24. 0 { → examples/contacts}/app/views/source/show.html.erb
  25. BIN examples/contacts/build/controllers/ApplicationController.class
  26. BIN examples/contacts/build/controllers/ContactsController.class
  27. BIN examples/contacts/build/controllers/InfoPropertiesController.class
  28. BIN examples/contacts/build/controllers/Shout$Query.class
  29. BIN examples/contacts/build/controllers/Shout.class
  30. BIN examples/contacts/build/controllers/ShoutController.class
  31. BIN examples/contacts/build/controllers/SourceController.class
  32. BIN examples/contacts/build/dubious/ActionController.class
  33. BIN examples/contacts/build/dubious/AssetTimestampsCache.class
  34. BIN examples/contacts/build/dubious/FormHelper.class
  35. BIN examples/contacts/build/dubious/Inflection.class
  36. BIN examples/contacts/build/dubious/Inflections.class
  37. BIN examples/contacts/build/dubious/Params.class
  38. BIN examples/contacts/build/dubious/ScopedParameterMap.class
  39. BIN examples/contacts/build/dubious/TextHelper.class
  40. BIN examples/contacts/build/dubious/TimeConversion.class
  41. BIN examples/contacts/build/models/Contact$Query.class
  42. BIN examples/contacts/build/models/Contact.class
  43. BIN examples/contacts/build/models/Contacts.class
  44. BIN examples/contacts/build/stdlib/Array.class
  45. BIN examples/contacts/build/stdlib/Ha.class
  46. BIN examples/contacts/build/stdlib/Io.class
  47. BIN examples/contacts/build/testing/SimpleDuby.class
  48. BIN examples/contacts/build/testing/SimpleJava.class
  49. 0 { → examples/contacts}/config/application.properties
  50. 0 { → examples/contacts}/config/asset.properties
  51. +10 −0 examples/contacts/config/build.properties
  52. 0 { → examples/contacts}/public/404.html
  53. 0 { → examples/contacts}/public/422.html
  54. 0 { → examples/contacts}/public/500.html
  55. 0 { → examples/contacts}/public/favicon.ico
  56. BIN { → examples/contacts}/public/images/appengine_duby.png
  57. BIN { → examples/contacts}/public/images/back.gif
  58. BIN { → examples/contacts}/public/images/dir.gif
  59. BIN { → examples/contacts}/public/images/file.gif
  60. BIN { → examples/contacts}/public/images/silver-120x30.gif
  61. 0 { → examples/contacts}/public/index.html
  62. 0 { → examples/contacts}/public/javascripts/effects.js
  63. 0 { → examples/contacts}/public/javascripts/jquery.rails.min.js
  64. 0 { → examples/contacts}/public/javascripts/lang/sh_css.min.js
  65. 0 { → examples/contacts}/public/javascripts/lang/sh_duby.min.js
  66. 0 { → examples/contacts}/public/javascripts/lang/sh_erb.min.js
  67. 0 { → examples/contacts}/public/javascripts/lang/sh_html.min.js
  68. 0 { → examples/contacts}/public/javascripts/lang/sh_java.min.js
  69. 0 { → examples/contacts}/public/javascripts/lang/sh_js.min.js
  70. 0 { → examples/contacts}/public/javascripts/lang/sh_mirah.min.js
  71. 0 { → examples/contacts}/public/javascripts/lang/sh_properties.min.js
  72. 0 { → examples/contacts}/public/javascripts/lang/sh_rb.min.js
  73. 0 { → examples/contacts}/public/javascripts/lang/sh_sh.min.js
  74. 0 { → examples/contacts}/public/javascripts/lang/sh_xml.min.js
  75. 0 { → examples/contacts}/public/javascripts/lang/sh_yaml.min.js
  76. 0 { → examples/contacts}/public/javascripts/prototype.js
  77. 0 { → examples/contacts}/public/javascripts/sh_main.min.js
  78. 0 { → examples/contacts}/public/robots.txt
  79. 0 { → examples/contacts}/public/stylesheets/main.css
  80. 0 { → examples/contacts}/public/stylesheets/scaffold.css
  81. 0 { → examples/contacts}/public/stylesheets/sh_style.css
  82. 0 { → examples/contacts}/public/stylesheets/source.css
  83. +2 −0 lib/dubious.rb
  84. +23 −0 lib/dubious/cli.rb
  85. +138 −0 lib/dubious/templates/Rakefile
  86. 0 lib/dubious/templates/WEB-INF/.empty_directory
  87. +12 −0 lib/dubious/templates/app.yaml.tt
  88. 0 lib/dubious/templates/app/.empty_directory
  89. 0 lib/dubious/templates/app/controllers/.empty_directory
  90. 0 lib/dubious/templates/app/models/.empty_directory
  91. 0 lib/dubious/templates/app/views/.empty_directory
  92. +30 −0 lib/dubious/templates/public/404.html
  93. +30 −0 lib/dubious/templates/public/422.html
  94. +30 −0 lib/dubious/templates/public/500.html
  95. 0 lib/dubious/templates/public/favicon.ico
  96. BIN lib/dubious/templates/public/images/appengine_duby.png
  97. BIN lib/dubious/templates/public/images/back.gif
  98. BIN lib/dubious/templates/public/images/dir.gif
  99. BIN lib/dubious/templates/public/images/file.gif
  100. BIN lib/dubious/templates/public/images/silver-120x30.gif
  101. +116 −0 lib/dubious/templates/public/index.html
  102. +1,128 −0 lib/dubious/templates/public/javascripts/effects.js
  103. +117 −0 lib/dubious/templates/public/javascripts/jquery.rails.min.js
  104. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_css.min.js
  105. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_duby.min.js
  106. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_erb.min.js
  107. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_html.min.js
  108. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_java.min.js
  109. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_js.min.js
  110. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_mirah.min.js
  111. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_properties.min.js
  112. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_rb.min.js
  113. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_sh.min.js
  114. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_xml.min.js
  115. +1 −0 lib/dubious/templates/public/javascripts/lang/sh_yaml.min.js
  116. +4,320 −0 lib/dubious/templates/public/javascripts/prototype.js
  117. +4 −0 lib/dubious/templates/public/javascripts/sh_main.min.js
  118. 0 lib/dubious/templates/public/robots.txt
  119. +185 −0 lib/dubious/templates/public/stylesheets/main.css
  120. +54 −0 lib/dubious/templates/public/stylesheets/scaffold.css
  121. +66 −0 lib/dubious/templates/public/stylesheets/sh_style.css
  122. +27 −0 lib/dubious/templates/public/stylesheets/source.css
  123. +0 −13 script/asset_cache.rb
  124. +0 −54 script/build.sh
  125. +0 −64 script/environment.rb
  126. +0 −2 script/publish.sh
  127. +0 −2 script/server.sh
  128. 0 {lib → src}/dubious/Inflection.java
  129. 0 {lib → src}/dubious/ScopedParameterMap.java
  130. 0 {lib → src}/dubious/action_controller.duby
  131. 0 {lib → src}/dubious/asset_timestamps_cache.duby
  132. 0 {lib → src}/dubious/form_helper.duby
  133. 0 {lib → src}/dubious/inflections.duby
  134. 0 {lib → src}/dubious/params.duby
  135. 0 {lib → src}/dubious/text_helper.duby
  136. 0 {lib → src}/dubious/time_conversion.duby
  137. 0 {lib → src}/stdlib/array.duby
  138. 0 {lib → src}/stdlib/ha.duby
  139. 0 {lib → src}/stdlib/io.duby
  140. 0 {lib → src}/testing/SimpleDuby.duby
  141. 0 {lib → src}/testing/SimpleJava.java
View
@@ -0,0 +1,78 @@
+#!/usr/bin/env ruby
+require 'rubygems'
+require File.dirname(__FILE__) + '/../lib/dubious/cli'
+=begin
+require 'thor'
+require 'git'
+require 'yaml'
+
+class InitDubiousApp < Thor::Group
+ desc "init NAME","initialize a dubious project"
+ argument 'name'
+ include Thor::Actions
+
+
+ def mk_project_dir
+ mkdir name
+ end
+
+ def setup
+ destination_root = name
+ end
+
+ def mk_dirs
+ in_project do
+ mkdir "app"
+ mkdir "lib"
+ mkdir "config"
+ end
+ end
+
+ def application_controller
+ in_project do
+ '...'
+ end
+ end
+
+ def readme
+ in_project do
+ copy_file "README", "
+ end
+ end
+end
+
+class Dubiousness < Thor
+ include Thor::Actions
+
+ desc "init NAME", "initialize a dubious project"
+ def init name='.'
+ Git.clone 'http://github.com/mirah/dubious.git', name
+
+ end
+
+ def generate_controller name
+ end
+
+ def clear_app dir='.'
+ Dir.chdir dir do
+ rm_r 'app/models'
+ rm_r 'app/controllers'
+ rm_r 'app/views'
+ cfg = YAML.load_file('app.yaml')
+ cfg['handlers']=nil
+ cfg['application'] = '<changeme>'
+ File.open 'app.yaml', 'w' do |f|
+ YAML.dump cfg, f
+ end
+ end
+ end
+
+ def verify_tools
+ "which appcfg.sh
+ which dev_appserver.sh
+ which mirah
+ which jruby"
+ end
+end
+=end
+Dubious::CLI.start
@@ -0,0 +1,138 @@
+begin
+ require 'ant'
+rescue LoadError
+ puts 'This Rakefile requires JRuby. Please use jruby -S rake.'
+ exit 1
+end
+
+if ENV['MIRAH_HOME'] && File.exist?(ENV['MIRAH_HOME'] +'/lib/mirah.rb')
+ $: << File.expand_path(ENV['MIRAH_HOME'] +'/lib')
+end
+
+if File.exist?('../bitescript/lib/bitescript.rb')
+ $: << File.expand_path('../bitescript/lib/')
+end
+
+require 'mirah/appengine_tasks'
+require 'rake/clean'
+
+CLEAN.include('build')
+CLOBBER.include("WEB-INF/lib/*.jar", 'WEB-INF/appengine-generated')
+
+def class_files_for files
+ files.map do |f|
+ explode = f.split('/')[1..-1]
+ explode.last.gsub!(/(^[a-z]|_[a-z])/) {|m|m.sub('_','').upcase}
+ explode.last.sub! /\.(duby|java|mirah)$/, '.class'
+ 'build/' + explode.join('/')
+ end
+end
+
+APP_SRC = Dir["app/**/{*.duby,*.mirah}"]
+APP_CLASSES = class_files_for APP_SRC
+APP_MODEL_CLASSES = APP_CLASSES.select {|app| app.include? '/models' }
+APP_CONTROLLER_CLASSES = APP_CLASSES.select {|app| app.include? '/controllers' }
+TEMPLATES = Dir["app/views/**/*.erb"]
+
+MODEL_JAR = "WEB-INF/lib/dubydatastore.jar"
+LIB_MIRAH_SRC = Dir["lib/**/*.duby"]
+LIB_JAVA_SRC = Dir["lib/**/*.java"]
+LIB_SRC = LIB_MIRAH_SRC + LIB_JAVA_SRC
+LIB_CLASSES = class_files_for LIB_SRC
+
+STDLIB_CLASSES= LIB_CLASSES.select{|l|l.include? 'stdlib'}
+
+CLASSPATH = [AppEngine::Rake::SERVLET, AppEngine::SDK::API_JAR].join(":")
+
+appengine_app :app, 'app', '' => ["WEB-INF/lib/application.jar",
+ "WEB-INF/lib/dubious.jar",
+ ]
+Duby.dest_paths << 'build'
+Duby.source_paths << 'lib'
+Duby.compiler_options << '--classpath' << [File.expand_path('build'),"WEB-INF/lib"].join(':')
+
+directory 'build'
+
+file "build/dubious/Inflection.class" => :'compile:java'
+file "build/dubious/ScopedParameterMap.class" => :'compile:java'
+file "build/dubious/ActionController.class" => ["build/dubious/Params.class", "build/dubious/FormHelper.class", "build/dubious/AssetTimestampsCache.class"]
+file "build/dubious/Inflections.class" => "build/dubious/Inflection.class"
+file "build/dubious/FormHelper.class" => ["build/dubious/Inflections.class", *STDLIB_CLASSES]
+file "build/dubious/Params.class" => "build/dubious/ScopedParameterMap.class"
+
+APP_CONTROLLER_CLASSES.each do |f|
+ file f => APP_MODEL_CLASSES + TEMPLATES
+end
+
+APP_CLASSES.each do |f|
+ file f => LIB_CLASSES
+end
+
+namespace :compile do
+ task :app => [:dubious, "WEB-INF/lib/application.jar"]
+ task :dubious => "WEB-INF/lib/dubious.jar"
+ task :java => 'build' do
+ ant.javac :srcdir=>'lib', :destdir=>'build', :classpath=>CLASSPATH
+ end
+end
+
+desc "compile app"
+task :compile => 'compile:app'
+
+file "WEB-INF/lib/dubious.jar" => [MODEL_JAR] + LIB_CLASSES do
+ includes = LIB_CLASSES.map {|d|d.sub 'build/',''}.join(',')
+ ant.jar :destfile=>"WEB-INF/lib/dubious.jar", :basedir=>'build',
+ :includes=>includes
+end
+
+file "WEB-INF/lib/application.jar" => APP_CLASSES do
+ includes = APP_CLASSES.map {|d|d.sub 'build/',''}.join(',')
+ ant.jar :destfile=>"WEB-INF/lib/application.jar", :basedir=>'build',
+ :includes=>includes
+end
+
+task :default => :server
+
+MIRAH_HOME = ENV['MIRAH_HOME'] ? ENV['MIRAH_HOME'] : Gem.find_files('mirah').first.sub(/lib\/mirah.rb/,'')
+
+MODEL_SRC_JAR = File.join(MIRAH_HOME, 'examples', 'appengine', 'war',
+ 'WEB-INF', 'lib', 'dubydatastore.jar')
+
+file MODEL_JAR => MODEL_SRC_JAR do |t|
+ cp MODEL_SRC_JAR, MODEL_JAR
+end
+
+task :generate_build_properties do
+ def git_data(dir, file='')
+ returning = nil
+ chdir dir do
+ # ["commit abc....123", "2010-06-23 12:58:06 -0700"]
+ IO.popen("git rev-list --pretty=format:%ci -1 HEAD #{file}") do |f|
+ returning = [f.gets.chomp, f.gets.chomp]
+ end
+ end
+ returning
+ end
+
+ dubious_data = git_data(".")
+ mirah_data = git_data(MIRAH_HOME)
+ bite_data = git_data(MIRAH_HOME + '/../bitescript')
+ model_data = git_data(File.dirname(MODEL_SRC_JAR),File.basename(MODEL_SRC_JAR))
+
+ prop_file = "config/build.properties"
+ File.open(prop_file, 'w') do |f|
+ f.write <<-EOF
+# the current build environment
+application.build.time=#{Time.now.xmlschema}
+dubious.version.commit=#{dubious_data[0][7..-1]}
+dubious.version.time=#{Time.parse(dubious_data[1]).xmlschema}
+mirah.version.commit=#{mirah_data[0][7..-1]}
+mirah.version.time=#{Time.parse(mirah_data[1]).xmlschema}
+bitescript.version.commit=#{bite_data[0][7..-1]}
+bitescript.version.time=#{Time.parse(bite_data[1]).xmlschema}
+model.version.commit=#{model_data[0][7..-1]}
+model.version.time=#{Time.parse(model_data[1]).xmlschema}
+ EOF
+ end
+
+end
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File renamed without changes.
File renamed without changes.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,10 @@
+# the current build environment
+application.build.time=2010-07-21T21:30:51-06:00
+dubious.version.commit=2304770c14a6b8c80900303392ae91df418c84f8
+dubious.version.time=2010-07-21T12:02:43-06:00
+mirah.version.commit=cb4d60b0f65353ced0211610493ad5635eba3d23
+mirah.version.time=2010-07-21T20:43:05-06:00
+bitescript.version.commit=3bb29885312ac46947876947114c2bca5948c871
+bitescript.version.time=2010-07-09T18:32:42-06:00
+model.version.commit=b333b7d814a859086797bcf3fbbb4cd8c7dc5385
+model.version.time=2010-07-15T15:37:21-06:00
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
View
@@ -0,0 +1,2 @@
+module Dubious
+end
View
@@ -0,0 +1,23 @@
+require 'thor'
+require 'thor/group'
+module Dubious
+ class Init < Thor::Group
+ include Thor::Actions
+ argument :name
+ source_root File.dirname(__FILE__)+"/templates"
+
+ def init
+ directory '.', "#{name}/"
+ end
+
+ def self.subcommand_help command_name
+'foo'
+ end
+ end
+
+ class CLI < Thor
+ desc "init NAME", "initializes a new dubious project in NAME"
+ subcommand :init, Init
+ end
+
+end
@@ -0,0 +1,138 @@
+begin
+ require 'ant'
+rescue LoadError
+ puts 'This Rakefile requires JRuby. Please use jruby -S rake.'
+ exit 1
+end
+
+if ENV['MIRAH_HOME'] && File.exist?(ENV['MIRAH_HOME'] +'/lib/mirah.rb')
+ $: << File.expand_path(ENV['MIRAH_HOME'] +'/lib')
+end
+
+if File.exist?((ENV['MIRAH_HOME'] +'/../bitescript/lib/bitescript.rb')
+ $: << File.expand_path('../bitescript/lib/')
+end
+
+require 'mirah/appengine_tasks'
+require 'rake/clean'
+
+CLEAN.include('build')
+CLOBBER.include("WEB-INF/lib/*.jar", 'WEB-INF/appengine-generated')
+
+def class_files_for files
+ files.map do |f|
+ explode = f.split('/')[1..-1]
+ explode.last.gsub!(/(^[a-z]|_[a-z])/) {|m|m.sub('_','').upcase}
+ explode.last.sub! /\.(duby|java|mirah)$/, '.class'
+ 'build/' + explode.join('/')
+ end
+end
+
+APP_SRC = Dir["app/**/{*.duby,*.mirah}"]
+APP_CLASSES = class_files_for APP_SRC
+APP_MODEL_CLASSES = APP_CLASSES.select {|app| app.include? '/models' }
+APP_CONTROLLER_CLASSES = APP_CLASSES.select {|app| app.include? '/controllers' }
+TEMPLATES = Dir["app/views/**/*.erb"]
+
+MODEL_JAR = "WEB-INF/lib/dubydatastore.jar"
+LIB_MIRAH_SRC = Dir["lib/**/*.duby"]
+LIB_JAVA_SRC = Dir["lib/**/*.java"]
+LIB_SRC = LIB_MIRAH_SRC + LIB_JAVA_SRC
+LIB_CLASSES = class_files_for LIB_SRC
+
+STDLIB_CLASSES= LIB_CLASSES.select{|l|l.include? 'stdlib'}
+
+CLASSPATH = [AppEngine::Rake::SERVLET, AppEngine::SDK::API_JAR].join(":")
+
+appengine_app :app, 'app', '' => ["WEB-INF/lib/application.jar",
+ "WEB-INF/lib/dubious.jar",
+ ]
+Duby.dest_paths << 'build'
+Duby.source_paths << 'lib'
+Duby.compiler_options << '--classpath' << [File.expand_path('build'),"WEB-INF/lib"].join(':')
+
+directory 'build'
+
+file "build/dubious/Inflection.class" => :'compile:java'
+file "build/dubious/ScopedParameterMap.class" => :'compile:java'
+file "build/dubious/ActionController.class" => ["build/dubious/Params.class", "build/dubious/FormHelper.class", "build/dubious/AssetTimestampsCache.class"]
+file "build/dubious/Inflections.class" => "build/dubious/Inflection.class"
+file "build/dubious/FormHelper.class" => ["build/dubious/Inflections.class", *STDLIB_CLASSES]
+file "build/dubious/Params.class" => "build/dubious/ScopedParameterMap.class"
+
+APP_CONTROLLER_CLASSES.each do |f|
+ file f => APP_MODEL_CLASSES + TEMPLATES
+end
+
+APP_CLASSES.each do |f|
+ file f => LIB_CLASSES
+end
+
+namespace :compile do
+ task :app => [:dubious, "WEB-INF/lib/application.jar"]
+ task :dubious => "WEB-INF/lib/dubious.jar"
+ task :java => 'build' do
+ ant.javac :srcdir=>'lib', :destdir=>'build', :classpath=>CLASSPATH
+ end
+end
+
+desc "compile app"
+task :compile => 'compile:app'
+
+file "WEB-INF/lib/dubious.jar" => [MODEL_JAR] + LIB_CLASSES do
+ includes = LIB_CLASSES.map {|d|d.sub 'build/',''}.join(',')
+ ant.jar :destfile=>"WEB-INF/lib/dubious.jar", :basedir=>'build',
+ :includes=>includes
+end
+
+file "WEB-INF/lib/application.jar" => APP_CLASSES do
+ includes = APP_CLASSES.map {|d|d.sub 'build/',''}.join(',')
+ ant.jar :destfile=>"WEB-INF/lib/application.jar", :basedir=>'build',
+ :includes=>includes
+end
+
+task :default => :server
+
+MIRAH_HOME = ENV['MIRAH_HOME'] ? ENV['MIRAH_HOME'] : Gem.find_files('mirah').first.sub(/lib\/mirah.rb/,'')
+
+MODEL_SRC_JAR = File.join(MIRAH_HOME, 'examples', 'appengine', 'war',
+ 'WEB-INF', 'lib', 'dubydatastore.jar')
+
+file MODEL_JAR => MODEL_SRC_JAR do |t|
+ cp MODEL_SRC_JAR, MODEL_JAR
+end
+
+task :generate_build_properties do
+ def git_data(dir, file='')
+ returning = nil
+ chdir dir do
+ # ["commit abc....123", "2010-06-23 12:58:06 -0700"]
+ IO.popen("git rev-list --pretty=format:%ci -1 HEAD #{file}") do |f|
+ returning = [f.gets.chomp, f.gets.chomp]
+ end
+ end
+ returning
+ end
+
+ dubious_data = git_data(".")
+ mirah_data = git_data(MIRAH_HOME)
+ bite_data = git_data(MIRAH_HOME + '/../bitescript')
+ model_data = git_data(File.dirname(MODEL_SRC_JAR),File.basename(MODEL_SRC_JAR))
+
+ prop_file = "config/build.properties"
+ File.open(prop_file, 'w') do |f|
+ f.write <<-EOF
+# the current build environment
+application.build.time=#{Time.now.xmlschema}
+dubious.version.commit=#{dubious_data[0][7..-1]}
+dubious.version.time=#{Time.parse(dubious_data[1]).xmlschema}
+mirah.version.commit=#{mirah_data[0][7..-1]}
+mirah.version.time=#{Time.parse(mirah_data[1]).xmlschema}
+bitescript.version.commit=#{bite_data[0][7..-1]}
+bitescript.version.time=#{Time.parse(bite_data[1]).xmlschema}
+model.version.commit=#{model_data[0][7..-1]}
+model.version.time=#{Time.parse(model_data[1]).xmlschema}
+ EOF
+ end
+
+end
Oops, something went wrong.

0 comments on commit e079b2e

Please sign in to comment.