melomel 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
+ ### Melomel 0.3.0
2
+ * Added `Melomel.invoke_function()` for package level functions invocation. (Nikita Dudnik)
3
+
1
4
  ### Melomel 0.2.0
2
5
  * Moved `Melomel::UI` methods into `Melomel`.
3
6
  * Changed Flex build from `ant compile` to `ant build`.
4
7
  * Made `build` the default ant target.
5
- *
8
+
9
+ ### Melomel 0.1.0
10
+ * Initial alpha version.
data/README.md CHANGED
@@ -41,6 +41,8 @@ After it's connected, there are several actions you can perform:
41
41
  1. Get Property
42
42
  1. Set Property
43
43
  1. Invoke Method
44
+ 1. Invoke Function
45
+
44
46
 
45
47
  ## API
46
48
 
@@ -107,6 +109,14 @@ because it had more than one argument. The `clear` method, however, required
107
109
  that a bang character be appended to the name or that the `invoke_method` be
108
110
  used.
109
111
 
112
+ ### Invoke Function
113
+
114
+ Invoking package level functions is also handled transparently.
115
+
116
+ className = Melomel.invoke_function('flash.utils.getQualifiedClassName', "Some string.")
117
+
118
+ The className will contain "String".
119
+
110
120
 
111
121
  ## HACKING
112
122
 
@@ -49,6 +49,23 @@ module Melomel
49
49
  send(xml.root.to_xml(:indent => 0))
50
50
  parse_message_value(Nokogiri::XML(receive()).root)
51
51
  end
52
+
53
+ # Invokes a package level function in the Flash virtual machine
54
+ def invoke_function(function, *args)
55
+ xml = Nokogiri::XML("<invoke-function name=\"#{function}\"><args/></invoke>")
56
+
57
+ # Loop over and add arguments to call
58
+ args_node = xml.at_xpath('invoke-function/args')
59
+ args.each do |arg|
60
+ arg_node = Nokogiri::XML::Node.new('arg', xml)
61
+ format_message_value(arg_node, arg)
62
+ args_node.add_child(arg_node)
63
+ end
64
+
65
+ # Send and receive
66
+ send(xml.root.to_xml(:indent => 0))
67
+ parse_message_value(Nokogiri::XML(receive()).root)
68
+ end
52
69
 
53
70
  # Creates an object proxy from a hash
54
71
  def create_hash(hash)
@@ -1,3 +1,3 @@
1
1
  module Melomel
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/melomel.rb CHANGED
@@ -34,5 +34,10 @@ module Melomel
34
34
  def create_object(class_name)
35
35
  @bridge.create_object(class_name)
36
36
  end
37
+
38
+ # Invokes package level function
39
+ def invoke_function(function, *args)
40
+ @bridge.invoke_function(function, *args)
41
+ end
37
42
  end
38
43
  end
@@ -38,4 +38,9 @@ class IntegrationTestCase < RunnerTestCase
38
38
  point.y = 40
39
39
  assert_equal 50, point.length
40
40
  end
41
+
42
+ def test_should_invoke_function
43
+ result = Melomel.invoke_function('flash.utils.getQualifiedClassName', 'Some string.')
44
+ assert_equal 'String', result
45
+ end
41
46
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: melomel
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 2
8
+ - 3
9
9
  - 0
10
- version: 0.2.0
10
+ version: 0.3.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Ben Johnson
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-03 00:00:00 -06:00
18
+ date: 2010-09-20 00:00:00 -06:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -30,10 +30,10 @@ dependencies:
30
30
  - 4
31
31
  - 3
32
32
  version: 1.4.3
33
- name: nokogiri
34
33
  requirement: *id001
35
- prerelease: false
36
34
  type: :runtime
35
+ name: nokogiri
36
+ prerelease: false
37
37
  - !ruby/object:Gem::Dependency
38
38
  version_requirements: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -46,10 +46,10 @@ dependencies:
46
46
  - 7
47
47
  - 0
48
48
  version: 1.7.0
49
- name: minitest
50
49
  requirement: *id002
51
- prerelease: false
52
50
  type: :development
51
+ name: minitest
52
+ prerelease: false
53
53
  - !ruby/object:Gem::Dependency
54
54
  version_requirements: &id003 !ruby/object:Gem::Requirement
55
55
  none: false
@@ -62,10 +62,10 @@ dependencies:
62
62
  - 9
63
63
  - 8
64
64
  version: 0.9.8
65
- name: mocha
66
65
  requirement: *id003
67
- prerelease: false
68
66
  type: :development
67
+ name: mocha
68
+ prerelease: false
69
69
  description:
70
70
  email:
71
71
  - benbjohnson@yahoo.com