wagon 0.10.5 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,8 @@
1
+ build.xml.data.CRC32=47afb14d
2
+ build.xml.script.CRC32=21ac335f
3
+ build.xml.stylesheet.CRC32=958a1d3e@1.32.1.45
4
+ # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5
+ # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6
+ nbproject/build-impl.xml.data.CRC32=47afb14d
7
+ nbproject/build-impl.xml.script.CRC32=3d0a5dd7
8
+ nbproject/build-impl.xml.stylesheet.CRC32=576378a2@1.32.1.45
@@ -0,0 +1,3 @@
1
+ compile.on.save=true
2
+ jaxbwiz.endorsed.dirs=C:\\Program Files\\NetBeans 6.8\\ide12\\modules\\ext\\jaxb\\api
3
+ user.properties.file=C:\\Documents and Settings\\Devin Christensen\\.netbeans\\6.8\\build.properties
@@ -0,0 +1,67 @@
1
+ build.classes.dir=${build.dir}/classes
2
+ build.classes.excludes=**/*.java,**/*.form
3
+ # This directory is removed when the project is cleaned:
4
+ build.dir=build
5
+ build.generated.dir=${build.dir}/generated
6
+ build.generated.sources.dir=${build.dir}/generated-sources
7
+ # Only compile against the classpath explicitly listed here:
8
+ build.sysclasspath=ignore
9
+ build.test.classes.dir=${build.dir}/test/classes
10
+ build.test.results.dir=${build.dir}/test/results
11
+ # Uncomment to specify the preferred debugger connection transport:
12
+ #debug.transport=dt_socket
13
+ debug.classpath=\
14
+ ${run.classpath}
15
+ debug.test.classpath=\
16
+ ${run.test.classpath}
17
+ # This directory is removed when the project is cleaned:
18
+ dist.dir=dist
19
+ dist.jar=${dist.dir}/Wagon.jar
20
+ dist.javadoc.dir=${dist.dir}/javadoc
21
+ excludes=
22
+ file.reference.gui-src=src
23
+ file.reference.jruby-complete.jar=lib\\java\\jruby-complete.jar
24
+ file.reference.monkeybars-1.0.4.jar=lib\\java\\monkeybars-1.0.4.jar
25
+ includes=**
26
+ jar.compress=false
27
+ javac.classpath=\
28
+ ${file.reference.jruby-complete.jar}:\
29
+ ${file.reference.monkeybars-1.0.4.jar}
30
+ # Space-separated list of extra javac options
31
+ javac.compilerargs=
32
+ javac.deprecation=false
33
+ javac.source=1.5
34
+ javac.target=1.5
35
+ javac.test.classpath=\
36
+ ${javac.classpath}:\
37
+ ${build.classes.dir}:\
38
+ ${libs.junit.classpath}:\
39
+ ${libs.junit_4.classpath}
40
+ javadoc.additionalparam=
41
+ javadoc.author=false
42
+ javadoc.encoding=${source.encoding}
43
+ javadoc.noindex=false
44
+ javadoc.nonavbar=false
45
+ javadoc.notree=false
46
+ javadoc.private=false
47
+ javadoc.splitindex=true
48
+ javadoc.use=true
49
+ javadoc.version=false
50
+ javadoc.windowtitle=
51
+ jaxbwiz.endorsed.dirs="${netbeans.home}/../ide12/modules/ext/jaxb/api"
52
+ main.class=org.rubyforge.rawr.Main
53
+ manifest.file=manifest.mf
54
+ meta.inf.dir=${src.dir}/META-INF
55
+ platform.active=default_platform
56
+ run.classpath=\
57
+ ${javac.classpath}:\
58
+ ${build.classes.dir}
59
+ # Space-separated list of JVM arguments used when running the project
60
+ # (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
61
+ # or test-sys-prop.name=value to set system properties for unit tests):
62
+ run.jvmargs=
63
+ run.test.classpath=\
64
+ ${javac.test.classpath}:\
65
+ ${build.test.classes.dir}
66
+ source.encoding=UTF-8
67
+ src.dir=${file.reference.gui-src}
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project xmlns="http://www.netbeans.org/ns/project/1">
3
+ <type>org.netbeans.modules.java.j2seproject</type>
4
+ <configuration>
5
+ <data xmlns="http://www.netbeans.org/ns/j2se-project/3">
6
+ <name>Wagon</name>
7
+ <source-roots>
8
+ <root id="src.dir"/>
9
+ </source-roots>
10
+ <test-roots/>
11
+ </data>
12
+ </configuration>
13
+ </project>
@@ -0,0 +1,4 @@
1
+ class ApplicationController < Monkeybars::Controller
2
+ # Add content here that you want to be available to all the controllers
3
+ # in your application
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationView < Monkeybars::View
2
+ # Add content here that you want to be available to all the views in your application
3
+ end
@@ -0,0 +1,52 @@
1
+ #===============================================================================
2
+ # Much of the platform specific code should be called before Swing is touched.
3
+ # The useScreenMenuBar is an example of this.
4
+ require 'rbconfig'
5
+ require 'java'
6
+
7
+ #===============================================================================
8
+ # Platform specific operations, feel free to remove or override any of these
9
+ # that don't work for your platform/application
10
+
11
+ case Config::CONFIG["host_os"]
12
+ when /darwin/i # OSX specific code
13
+ java.lang.System.set_property("apple.laf.useScreenMenuBar", "true")
14
+ when /^win|mswin/i # Windows specific code
15
+ when /linux/i # Linux specific code
16
+ end
17
+
18
+ # End of platform specific code
19
+ #===============================================================================
20
+ $LOAD_PATH << File.expand_path(File.dirname(__FILE__))
21
+ require 'manifest'
22
+
23
+ # Set up global error handling so that it is consistantly logged or outputed
24
+ # You will probably want to replace the puts with your application's logger
25
+ def show_error_dialog_and_exit(exception, thread=nil)
26
+ puts "Error in application"
27
+ puts "#{exception.class} - #{exception}"
28
+ if exception.kind_of? Exception
29
+ puts exception.backtrace.join("\n")
30
+ else
31
+ # Workaround for JRuby issue #2673, getStackTrace returning an empty array
32
+ output_stream = java.io.ByteArrayOutputStream.new
33
+ exception.printStackTrace(java.io.PrintStream.new(output_stream))
34
+ puts output_stream.to_string
35
+ end
36
+
37
+ # Your error handling code goes here
38
+
39
+ # Show error dialog informing the user that there was an error
40
+ title = "Application Error"
41
+ message = "The application has encountered an error and must shut down."
42
+
43
+ javax.swing.JOptionPane.show_message_dialog(nil, message, title, javax.swing.JOptionPane::DEFAULT_OPTION)
44
+ java.lang.System.exit(0)
45
+ end
46
+ GlobalErrorHandler.on_error {|exception, thread| show_error_dialog_and_exit(exception, thread) }
47
+
48
+ begin
49
+ # Your application code goes here
50
+ rescue => e
51
+ show_error_dialog_and_exit(e)
52
+ end
@@ -0,0 +1,58 @@
1
+ $LOAD_PATH.clear #ensure load path is cleared so system gems and libraries are not used (only project gems/libs)
2
+ # Load current and subdirectories in src onto the load path
3
+ $LOAD_PATH << File.dirname(__FILE__)
4
+ Dir.glob(File.expand_path(File.dirname(__FILE__) + "/**/*").gsub('%20', ' ')).each do |directory|
5
+ # File.directory? is broken in current JRuby for dirs inside jars
6
+ # http://jira.codehaus.org/browse/JRUBY-2289
7
+ $LOAD_PATH << directory unless directory =~ /\.\w+$/
8
+ end
9
+ # Some JRuby $LOAD_PATH path bugs to check if you're having trouble:
10
+ # http://jira.codehaus.org/browse/JRUBY-2518 - Dir.glob and Dir[] doesn't work
11
+ # for starting in a dir in a jar
12
+ # (such as Active-Record migrations)
13
+ # http://jira.codehaus.org/browse/JRUBY-3247 - Compiled Ruby classes produce
14
+ # word substitutes for characters
15
+ # like - and . (to minus and dot).
16
+ # This is problematic with gems
17
+ # like ActiveSupport and Prawn
18
+
19
+ #===============================================================================
20
+ # Monkeybars requires, this pulls in the requisite libraries needed for
21
+ # Monkeybars to operate.
22
+
23
+ require 'resolver'
24
+
25
+ case Monkeybars::Resolver.run_location
26
+ when Monkeybars::Resolver::IN_FILE_SYSTEM
27
+ add_to_classpath '../lib/java/monkeybars-1.0.2.jar'
28
+ end
29
+
30
+ require 'monkeybars'
31
+ require 'application_controller'
32
+ require 'application_view'
33
+
34
+ # End of Monkeybars requires
35
+ #===============================================================================
36
+ #
37
+ # Add your own application-wide libraries below. To include jars, append to
38
+ # $CLASSPATH, or use add_to_classpath, for example:
39
+ #
40
+ # $CLASSPATH << File.expand_path(File.dirname(__FILE__) + "/../lib/java/swing-layout-1.0.3.jar")
41
+ #
42
+ # is equivalent to
43
+ #
44
+ # add_to_classpath "../lib/java/swing-layout-1.0.3.jar"
45
+ #
46
+ # There is also a helper for adding to your load path and avoiding issues with file: being
47
+ # appended to the load path (useful for JRuby libs that need your jar directory on
48
+ # the load path).
49
+ #
50
+ # add_to_load_path "../lib/java"
51
+ #
52
+
53
+ case Monkeybars::Resolver.run_location
54
+ when Monkeybars::Resolver::IN_FILE_SYSTEM
55
+ # Files to be added only when running from the file system go here
56
+ when Monkeybars::Resolver::IN_JAR_FILE
57
+ # Files to be added only when run from inside a jar file
58
+ end
@@ -0,0 +1,67 @@
1
+ package org.rubyforge.rawr;
2
+
3
+ import java.io.BufferedReader;
4
+ import java.io.InputStreamReader;
5
+ import java.io.InputStream;
6
+ import java.io.IOException;
7
+ import java.net.URL;
8
+
9
+
10
+ import java.util.ArrayList;
11
+ import org.jruby.Ruby;
12
+ import org.jruby.RubyInstanceConfig;
13
+ import org.jruby.javasupport.JavaEmbedUtils;
14
+
15
+ public class Main
16
+ {
17
+ public static void main(String[] args) throws Exception
18
+ {
19
+ RubyInstanceConfig config = new RubyInstanceConfig();
20
+ config.setArgv(args);
21
+ Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
22
+ String mainRubyFile = "main";
23
+
24
+ ArrayList<String> config_data = new ArrayList<String>();
25
+ try{
26
+ java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
27
+ if (ins == null ) {
28
+ System.err.println("Did not find configuration file 'run_configuration', using defaults.");
29
+ } else {
30
+ config_data = getConfigFileContents(ins);
31
+ }
32
+ }
33
+ catch(IOException ioe)
34
+ {
35
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
36
+ }
37
+ catch(java.lang.NullPointerException npe)
38
+ {
39
+ System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
40
+ }
41
+
42
+ for(String line : config_data) {
43
+ String[] parts = line.split(":");
44
+ if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
45
+ mainRubyFile = parts[1].replaceAll(" ", "");
46
+ }
47
+ }
48
+
49
+ runtime.evalScriptlet("require '" + mainRubyFile + "'");
50
+ }
51
+
52
+ public static URL getResource(String path) {
53
+ return Main.class.getClassLoader().getResource(path);
54
+ }
55
+
56
+ private static ArrayList<String> getConfigFileContents(InputStream input) throws IOException, java.lang.NullPointerException {
57
+ BufferedReader reader = new BufferedReader(new InputStreamReader(input));
58
+ String line;
59
+ ArrayList<String> contents = new ArrayList<String>();
60
+
61
+ while ((line = reader.readLine()) != null) {
62
+ contents.add(line);
63
+ }
64
+ reader.close();
65
+ return(contents);
66
+ }
67
+ }
@@ -0,0 +1,33 @@
1
+ module Monkeybars
2
+ class Resolver
3
+ IN_FILE_SYSTEM = :in_file_system
4
+ IN_JAR_FILE = :in_jar_file
5
+
6
+ # Returns a const value indicating if the currently executing code is being run from the file system or from within a jar file.
7
+ def self.run_location
8
+ if File.expand_path(__FILE__) =~ /\.jar\!/
9
+ IN_JAR_FILE
10
+ else
11
+ IN_FILE_SYSTEM
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ class Object
18
+ def add_to_classpath(path)
19
+ $CLASSPATH << get_expanded_path(path)
20
+ end
21
+
22
+ def add_to_load_path(path)
23
+ $LOAD_PATH << get_expanded_path(path)
24
+ end
25
+
26
+ private
27
+ def get_expanded_path(path)
28
+ resolved_path = File.expand_path(File.dirname(__FILE__) + "/" + path.gsub("\\", "/"))
29
+ resolved_path.gsub!("file:", "") unless resolved_path.index(".jar!")
30
+ resolved_path.gsub!("%20", ' ')
31
+ resolved_path
32
+ end
33
+ end
@@ -0,0 +1,89 @@
1
+ require 'fileutils'
2
+
3
+ desc "ALL, CONTROLLER, VIEW, MODEL are valid options."
4
+ task 'generate'
5
+ rule(/^generate/) do |t|
6
+ ARGV[1..-1].each do |generator_command|
7
+ command, argument = generator_command.split("=")
8
+ case command
9
+ when "ALL"
10
+ generate_tuple(argument)
11
+ when "VIEW"
12
+ generate_view(argument)
13
+ when "CONTROLLER"
14
+ generate_controller(argument)
15
+ when "MODEL"
16
+ generate_model(argument)
17
+ else
18
+ $stdout << "Unknown generate target #{argument}"
19
+ end
20
+ end
21
+ end
22
+
23
+ def generate_tuple(path)
24
+ pwd = FileUtils.pwd
25
+ generate_controller(path)
26
+ FileUtils.cd(pwd)
27
+ generate_model(path)
28
+ FileUtils.cd(pwd)
29
+ generate_view(path)
30
+ end
31
+
32
+ def generate_controller(path)
33
+ name = setup_directory(path)
34
+ file_name = "#{name}_controller.rb"
35
+ name = camelize(name)
36
+ $stdout << "Generating controller #{name}Controller in file #{file_name}\n"
37
+ File.open(file_name, "w") do |controller_file|
38
+ controller_file << <<-ENDL
39
+ class #{name}Controller < ApplicationController
40
+ set_model '#{name}Model'
41
+ set_view '#{name}View'
42
+ set_close_action :exit
43
+ end
44
+ ENDL
45
+ end
46
+ end
47
+
48
+ def generate_model(path)
49
+ name = setup_directory(path)
50
+ file_name = "#{name}_model.rb"
51
+ name = camelize(name)
52
+ $stdout << "Generating model #{name}Model in file #{file_name}\n"
53
+ File.open(file_name, "w") do |model_file|
54
+ model_file << <<-ENDL
55
+ class #{name}Model
56
+
57
+ end
58
+ ENDL
59
+ end
60
+ end
61
+
62
+ def generate_view(path)
63
+ name = setup_directory(path)
64
+ file_name = "#{name}_view.rb"
65
+ name = camelize(name)
66
+ $stdout << "Generating view #{name}View in file #{file_name}\n"
67
+ File.open(file_name, "w") do |view_file|
68
+ view_file << <<-ENDL
69
+ class #{name}View < ApplicationView
70
+ set_java_class ''
71
+ end
72
+ ENDL
73
+ end
74
+ end
75
+
76
+ def setup_directory(path)
77
+ FileUtils.mkdir_p path.gsub("\\", "/")
78
+ FileUtils.cd(path)
79
+ path.split("/").last
80
+ end
81
+
82
+ def camelize(name, first_letter_in_uppercase = true)
83
+ name = name.to_s
84
+ if first_letter_in_uppercase
85
+ name.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
86
+ else
87
+ name[0..0] + camelize(name[1..-1])
88
+ end
89
+ end
@@ -1,11 +1,13 @@
1
- module Wagon
2
- BASE_PATH = File.join(File.dirname(__FILE__), '..')
3
- VERSION = open(File.join(BASE_PATH, 'VERSION')).read()
4
-
5
- def self.connect(username, password)
6
- Connection.new(username, password)
7
- end
8
- end
9
-
10
- require 'wagon/page'
1
+ require 'queue_to_the_future'
2
+
3
+ module Wagon
4
+ BASE_PATH = File.join(File.dirname(__FILE__), '..')
5
+ VERSION = open(File.join(BASE_PATH, 'VERSION')).read()
6
+
7
+ def self.connect(username, password)
8
+ Connection.new(username, password)
9
+ end
10
+ end
11
+
12
+ require 'wagon/page'
11
13
  require 'wagon/connection'
@@ -1,40 +1,40 @@
1
- module Wagon
2
- class Address
3
- CITY_STATE_ZIP = %r/^(\D+), (\D+)?\s*(\d+(-\d+)?)?$/
4
-
5
- attr_reader :city, :state, :zip, :country
6
-
7
- def self.extract_from_string(string)
8
- parts = string.split("\n").collect(&:strip).delete_if(&:empty?)
9
- street = city = state = zip = country = nil
10
-
11
- parts.delete_if do |part|
12
- next unless part =~ CITY_STATE_ZIP
13
- city, state, zip = $1, ($2 || '').strip(), $3; true
14
- end
15
-
16
- self.new(parts.shift, city, state, zip, parts.shift)
17
- end
18
-
19
- def initialize(street, city, state, zip, country)
20
- @street, @city, @state, @zip, @country = street, city, state, zip, country
21
- end
22
-
23
- def street
24
- #601 N. Monterey Drive Apartment K
25
- @street.to_s.gsub(/apartment/i, 'Apt.').gsub(/drive/i, 'Dr.')
26
- end
27
-
28
- def to_s
29
- [street, [[city, state].compact.join(", "), zip, country.to_s.empty? ? nil : "(#{country})"].compact.join(" ")].compact.join("\n")
30
- end
31
-
32
- def ==(other)
33
- street == other.street &&
34
- city == other.city &&
35
- state == other.state &&
36
- zip == other.zip &&
37
- country == other.country
38
- end
39
- end
1
+ module Wagon
2
+ class Address
3
+ CITY_STATE_ZIP = %r/^(\D+), (\D+)?\s*(\d+(-\d+)?)?$/
4
+
5
+ attr_reader :city, :state, :zip, :country
6
+
7
+ def self.extract_from_string(string)
8
+ parts = string.split("\n").collect(&:strip).delete_if(&:empty?)
9
+ street = city = state = zip = country = nil
10
+
11
+ parts.delete_if do |part|
12
+ next unless part =~ CITY_STATE_ZIP
13
+ city, state, zip = $1, ($2 || '').strip(), $3; true
14
+ end
15
+
16
+ self.new(parts.shift, city, state, zip, parts.shift)
17
+ end
18
+
19
+ def initialize(street, city, state, zip, country)
20
+ @street, @city, @state, @zip, @country = street, city, state, zip, country
21
+ end
22
+
23
+ def street
24
+ #601 N. Monterey Drive Apartment K
25
+ @street.to_s.gsub(/apartment/i, 'Apt.').gsub(/drive/i, 'Dr.')
26
+ end
27
+
28
+ def to_s
29
+ [street, [[city, state].compact.join(", "), zip, country.to_s.empty? ? nil : "(#{country})"].compact.join(" ")].compact.join("\n")
30
+ end
31
+
32
+ def ==(other)
33
+ street == other.street &&
34
+ city == other.city &&
35
+ state == other.state &&
36
+ zip == other.zip &&
37
+ country == other.country
38
+ end
39
+ end
40
40
  end