jrubyfx 0.9.1-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (44) hide show
  1. data/LICENSE +202 -0
  2. data/README.md +97 -0
  3. data/bin/jrubyfx-jarify +90 -0
  4. data/bin/rubyfx-generator +81 -0
  5. data/lib/jrubyfx.rb +27 -0
  6. data/lib/jrubyfx/core_ext/border_pane.rb +29 -0
  7. data/lib/jrubyfx/core_ext/circle.rb +26 -0
  8. data/lib/jrubyfx/core_ext/column_constraints.rb +41 -0
  9. data/lib/jrubyfx/core_ext/duration.rb +28 -0
  10. data/lib/jrubyfx/core_ext/effects.rb +30 -0
  11. data/lib/jrubyfx/core_ext/file_chooser.rb +60 -0
  12. data/lib/jrubyfx/core_ext/labeled.rb +24 -0
  13. data/lib/jrubyfx/core_ext/media_player.rb +23 -0
  14. data/lib/jrubyfx/core_ext/node.rb +24 -0
  15. data/lib/jrubyfx/core_ext/observable_value.rb +36 -0
  16. data/lib/jrubyfx/core_ext/pagination.rb +26 -0
  17. data/lib/jrubyfx/core_ext/parallel_transition.rb +28 -0
  18. data/lib/jrubyfx/core_ext/parent.rb +28 -0
  19. data/lib/jrubyfx/core_ext/path.rb +41 -0
  20. data/lib/jrubyfx/core_ext/progress_indicator.rb +38 -0
  21. data/lib/jrubyfx/core_ext/radial_gradient.rb +37 -0
  22. data/lib/jrubyfx/core_ext/region.rb +39 -0
  23. data/lib/jrubyfx/core_ext/rotate.rb +37 -0
  24. data/lib/jrubyfx/core_ext/scene.rb +29 -0
  25. data/lib/jrubyfx/core_ext/shape.rb +27 -0
  26. data/lib/jrubyfx/core_ext/stage.rb +77 -0
  27. data/lib/jrubyfx/core_ext/stop.rb +29 -0
  28. data/lib/jrubyfx/core_ext/table_view.rb +35 -0
  29. data/lib/jrubyfx/core_ext/timeline.rb +47 -0
  30. data/lib/jrubyfx/core_ext/transition.rb +25 -0
  31. data/lib/jrubyfx/core_ext/xy_chart.rb +53 -0
  32. data/lib/jrubyfx/dsl.rb +217 -0
  33. data/lib/jrubyfx/fxml_application.rb +44 -0
  34. data/lib/jrubyfx/fxml_controller.rb +270 -0
  35. data/lib/jrubyfx/fxml_module.rb +98 -0
  36. data/lib/jrubyfx/java_fx_impl.rb +139 -0
  37. data/lib/jrubyfx/jfx_imports.rb +107 -0
  38. data/lib/jrubyfx/utils.rb +56 -0
  39. data/lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb +24 -0
  40. data/lib/jrubyfx/utils/common_converters.rb +140 -0
  41. data/lib/jrubyfx/utils/common_utils.rb +72 -0
  42. data/lib/jrubyfx/version.rb +4 -0
  43. data/lib/jrubyfx_tasks.rb +110 -0
  44. metadata +116 -0
@@ -0,0 +1,72 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+ require 'jrubyfx/utils/common_converters'
18
+
19
+ module JRubyFX
20
+ # Several utilities that have no better place to go
21
+ module Utils
22
+ # Utilities to manage argument properties for build/with
23
+ module CommonUtils
24
+ ##
25
+ # If last argument of the arg list is a hash-like entity (:each_pair)
26
+ # then this strip off last argument and return it as second return
27
+ # value.
28
+ # === Examples:
29
+ # split_args_from_properties(1, 2, a: 1) #=> [[1,2], {a: 1}]
30
+ # split_args_from_properties(1, 2) #=> [[1,2], {}]
31
+ #
32
+ def split_args_from_properties(*args)
33
+ if !args.empty? and args.last.respond_to? :each_pair
34
+ properties = args.pop
35
+ else
36
+ properties = {}
37
+ end
38
+
39
+ return args, properties
40
+ end
41
+
42
+ ##
43
+ # Sets the hashmap given on the passed in object as a set of properties,
44
+ # using converter if necessary.
45
+ #
46
+ def populate_properties(obj, properties)
47
+ properties.each_pair do |name, value|
48
+ obj.send(name.to_s + '=', *attempt_conversion(obj, name, value))
49
+ end
50
+ obj
51
+ end
52
+
53
+ ##
54
+ # Attempts to convert given value to JavaFX equvalent, if any, by calling
55
+ # obj.name_CommonConverters::ARG_CONVERTER_SUFFING, which is created by
56
+ # calling CommonConverters.converter_for in your class.
57
+ # See CommonConverters for current conversions
58
+ #
59
+ def attempt_conversion(obj, name, *values)
60
+ converter_method = name.to_s +
61
+ JRubyFX::Utils::CommonConverters::ARG_CONVERTER_SUFFIX
62
+
63
+ # Each type can create their own converter method to coerce things
64
+ # like symbols into real values JavaFX likes.
65
+ if obj.respond_to? converter_method
66
+ values = obj.__send__ converter_method, *values
67
+ end
68
+ values
69
+ end
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,4 @@
1
+ module JRubyFX
2
+ # Current gem version. Used in rake task.
3
+ VERSION='0.9.1'
4
+ end
@@ -0,0 +1,110 @@
1
+ =begin
2
+ JRubyFX - Write JavaFX and FXML in Ruby
3
+ Copyright (C) 2013 The JRubyFX Team
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
16
+ =end
17
+
18
+ # DO NOT INCLUDE ANY JRUBYFX CODE DIRECTLY!!! THIS IS A RAKEFILE EXTENSION!!!
19
+ require 'open-uri'
20
+ require 'rake'
21
+ require 'tmpdir'
22
+
23
+ module JRubyFX
24
+ # This module contains utilities to jarify an app, and can be used in a rakefile or a running app.
25
+ module Tasks
26
+ extend Rake::DSL
27
+ # Base URL of JRuby-complete.jar download location
28
+ BASE_URL='http://repository.codehaus.org/org/jruby/jruby-complete'
29
+
30
+ ##
31
+ # Downloads the jruby-complete jar file for `jruby_version` and save in
32
+ # ~/.jruby-jar/jruby-complete.jar unless it already exits. If the jar is
33
+ # corrupt or an older version, set force to true to delete and re-download
34
+ def download_jruby(jruby_version, force=false)
35
+ dist = "#{ENV['HOME']}/.jruby-jar"
36
+ unless force || (File.exists?("#{dist}/jruby-complete.jar") && File.size("#{dist}/jruby-complete.jar") > 0)
37
+ mkdir_p dist
38
+ base_dir = Dir.pwd
39
+ cd dist
40
+ puts "JRuby complete jar not found. Downloading... (May take awhile)"
41
+ download(jruby_version)
42
+ cd base_dir
43
+ end
44
+ end
45
+
46
+ ##
47
+ # Creates a full jar from the given source pattern (must be a pattern to match
48
+ # files), with the given main script as the script to launch when the jarfile
49
+ # is run. The output jar is saved in the `target` dir, which also doubles as a
50
+ # temporary work dir. `jar` is the executable that makes jars. If `target` is
51
+ # nill then a random temporary directory is created, and output_jar is the
52
+ # full path to the jar file to save
53
+ def jarify_jrubyfx(src="src/*" ,main_script=nil, target="target", output_jar="jrubyfx-app.jar", opts = {})
54
+ if target_was_nil = target == nil
55
+ target = Dir.mktmpdir("jrubyfx")
56
+ final_jar = output_jar
57
+ output_jar = File.basename output_jar
58
+ end
59
+ # set defaults
60
+ opts = {file_filter: ->(f){true},jar: "jar"}.merge(opts)
61
+
62
+ mkdir_p target
63
+
64
+ #copy jruby jar file in, along with script and our rb files
65
+ cp "#{ENV['HOME']}/.jruby-jar/jruby-complete.jar", "#{target}/#{output_jar}"
66
+
67
+ #copy source in
68
+ FileList[src].each do |iv_srv|
69
+ cp iv_srv, "#{target}/#{File.basename(iv_srv)}" if (main_script == nil || main_script != iv_srv) && opts[:file_filter].call(iv_srv)
70
+ end
71
+ cp main_script, "#{target}/jar-bootstrap.rb" unless main_script == nil
72
+
73
+ unless File.exists? "#{target}/jar-bootstrap.rb"
74
+ puts "@"*79
75
+ puts "@#{"!!!WARNING!!!".center(79-2)}@"
76
+ puts "@#{"jar-bootstrap.rb NOT FOUND!".center(79-2)}@"
77
+ puts "@#{"Did you set main_src= or have jar-bootstrap in src= ?".center(79-2)}@"
78
+ puts "@"*79
79
+ end
80
+
81
+ #copy our libs in
82
+ FileList["#{File.dirname(__FILE__)}/*"].each do |librb|
83
+ cp_r librb, target
84
+ end
85
+
86
+ # edit the jar
87
+ base_dir = Dir.pwd
88
+ cd target
89
+ sh "#{opts[:jar]} ufe '#{output_jar}' org.jruby.JarBootstrapMain *"
90
+ chmod 0775, output_jar
91
+ cd base_dir
92
+
93
+ if target_was_nil
94
+ mv "#{target}/#{output_jar}", final_jar
95
+ rm_rf target
96
+ end
97
+ end
98
+
99
+ private
100
+ def download(version_string) #:nodoc:
101
+ File.open("jruby-complete.jar","wb") do |f|
102
+ f.write(open("#{BASE_URL}/#{version_string}/jruby-complete-#{version_string}.jar").read)
103
+ end
104
+ end
105
+
106
+ module_function :jarify_jrubyfx
107
+ module_function :download_jruby
108
+ module_function :download
109
+ end
110
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jrubyfx
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.9.1
6
+ platform: java
7
+ authors:
8
+ - Patrick Plenefisch
9
+ - Thomas E Enebo
10
+ - Hiroshi Nakamura
11
+ - Hiro Asari
12
+ autorequire:
13
+ bindir: bin
14
+ cert_chain: []
15
+ date: 2013-01-24 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
18
+ name: rake
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: !binary |-
24
+ MA==
25
+ none: false
26
+ requirement: !ruby/object:Gem::Requirement
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ version: !binary |-
31
+ MA==
32
+ none: false
33
+ prerelease: false
34
+ type: :development
35
+ description: Enables JavaFX with FXML controllers and application in pure ruby
36
+ email:
37
+ - simonpatp@gmail.com
38
+ - tom.enebo@gmail.com
39
+ - nahi@ruby-lang.org
40
+ - asari.ruby@gmail.com
41
+ executables:
42
+ - rubyfx-generator
43
+ - jrubyfx-jarify
44
+ extensions: []
45
+ extra_rdoc_files: []
46
+ files:
47
+ - lib/jrubyfx.rb
48
+ - lib/jrubyfx_tasks.rb
49
+ - lib/jrubyfx/dsl.rb
50
+ - lib/jrubyfx/fxml_application.rb
51
+ - lib/jrubyfx/fxml_controller.rb
52
+ - lib/jrubyfx/fxml_module.rb
53
+ - lib/jrubyfx/java_fx_impl.rb
54
+ - lib/jrubyfx/jfx_imports.rb
55
+ - lib/jrubyfx/utils.rb
56
+ - lib/jrubyfx/version.rb
57
+ - lib/jrubyfx/core_ext/border_pane.rb
58
+ - lib/jrubyfx/core_ext/circle.rb
59
+ - lib/jrubyfx/core_ext/column_constraints.rb
60
+ - lib/jrubyfx/core_ext/duration.rb
61
+ - lib/jrubyfx/core_ext/effects.rb
62
+ - lib/jrubyfx/core_ext/file_chooser.rb
63
+ - lib/jrubyfx/core_ext/labeled.rb
64
+ - lib/jrubyfx/core_ext/media_player.rb
65
+ - lib/jrubyfx/core_ext/node.rb
66
+ - lib/jrubyfx/core_ext/observable_value.rb
67
+ - lib/jrubyfx/core_ext/pagination.rb
68
+ - lib/jrubyfx/core_ext/parallel_transition.rb
69
+ - lib/jrubyfx/core_ext/parent.rb
70
+ - lib/jrubyfx/core_ext/path.rb
71
+ - lib/jrubyfx/core_ext/progress_indicator.rb
72
+ - lib/jrubyfx/core_ext/radial_gradient.rb
73
+ - lib/jrubyfx/core_ext/region.rb
74
+ - lib/jrubyfx/core_ext/rotate.rb
75
+ - lib/jrubyfx/core_ext/scene.rb
76
+ - lib/jrubyfx/core_ext/shape.rb
77
+ - lib/jrubyfx/core_ext/stage.rb
78
+ - lib/jrubyfx/core_ext/stop.rb
79
+ - lib/jrubyfx/core_ext/table_view.rb
80
+ - lib/jrubyfx/core_ext/timeline.rb
81
+ - lib/jrubyfx/core_ext/transition.rb
82
+ - lib/jrubyfx/core_ext/xy_chart.rb
83
+ - lib/jrubyfx/utils/__ignore_java_stupid_rdoc.rb
84
+ - lib/jrubyfx/utils/common_converters.rb
85
+ - lib/jrubyfx/utils/common_utils.rb
86
+ - LICENSE
87
+ - README.md
88
+ - bin/rubyfx-generator
89
+ - bin/jrubyfx-jarify
90
+ homepage: https://github.com/byteit101/JRubyFX
91
+ licenses: []
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: !binary |-
101
+ MA==
102
+ none: false
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: !binary |-
108
+ MA==
109
+ none: false
110
+ requirements: []
111
+ rubyforge_project: jrubyfx
112
+ rubygems_version: 1.8.24
113
+ signing_key:
114
+ specification_version: 3
115
+ summary: JavaFX for JRuby with FXML
116
+ test_files: []