rubyserif 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Makefile +14 -0
- data/README.md +14 -0
- data/doc/JavaScript/Function.html +242 -0
- data/doc/JavaScript/Object.html +282 -0
- data/doc/JavaScript.html +147 -0
- data/doc/Makefile.html +107 -0
- data/doc/created.rid +4 -0
- data/doc/images/brick.png +0 -0
- data/doc/images/brick_link.png +0 -0
- data/doc/images/bug.png +0 -0
- data/doc/images/bullet_black.png +0 -0
- data/doc/images/bullet_toggle_minus.png +0 -0
- data/doc/images/bullet_toggle_plus.png +0 -0
- data/doc/images/date.png +0 -0
- data/doc/images/find.png +0 -0
- data/doc/images/loadingAnimation.gif +0 -0
- data/doc/images/macFFBgHack.png +0 -0
- data/doc/images/package.png +0 -0
- data/doc/images/page_green.png +0 -0
- data/doc/images/page_white_text.png +0 -0
- data/doc/images/page_white_width.png +0 -0
- data/doc/images/plugin.png +0 -0
- data/doc/images/ruby.png +0 -0
- data/doc/images/tag_green.png +0 -0
- data/doc/images/wrench.png +0 -0
- data/doc/images/wrench_orange.png +0 -0
- data/doc/images/zoom.png +0 -0
- data/doc/index.html +70 -0
- data/doc/js/darkfish.js +116 -0
- data/doc/js/jquery.js +32 -0
- data/doc/js/quicksearch.js +114 -0
- data/doc/js/thickbox-compressed.js +10 -0
- data/doc/lib/js_rb.html +52 -0
- data/doc/rdoc.css +763 -0
- data/doc/test/test_rb.html +52 -0
- data/lib/js.rb +50 -0
- data/test/test.rb +30 -0
- metadata +84 -0
@@ -0,0 +1,52 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
8
|
+
|
9
|
+
<title>File: test.rb [RDoc Documentation]</title>
|
10
|
+
|
11
|
+
<link type="text/css" media="screen" href="../rdoc.css" rel="stylesheet" />
|
12
|
+
|
13
|
+
<script src="../js/jquery.js" type="text/javascript"
|
14
|
+
charset="utf-8"></script>
|
15
|
+
<script src="../js/thickbox-compressed.js" type="text/javascript"
|
16
|
+
charset="utf-8"></script>
|
17
|
+
<script src="../js/quicksearch.js" type="text/javascript"
|
18
|
+
charset="utf-8"></script>
|
19
|
+
<script src="../js/darkfish.js" type="text/javascript"
|
20
|
+
charset="utf-8"></script>
|
21
|
+
</head>
|
22
|
+
|
23
|
+
<body class="file file-popup">
|
24
|
+
<div id="metadata">
|
25
|
+
<dl>
|
26
|
+
<dt class="modified-date">Last Modified</dt>
|
27
|
+
<dd class="modified-date">2012-03-14 17:45:16 -0400</dd>
|
28
|
+
|
29
|
+
|
30
|
+
<dt class="requires">Requires</dt>
|
31
|
+
<dd class="requires">
|
32
|
+
<ul>
|
33
|
+
|
34
|
+
</ul>
|
35
|
+
</dd>
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
</dl>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div id="documentation">
|
43
|
+
|
44
|
+
<div class="description">
|
45
|
+
<h2>Description</h2>
|
46
|
+
|
47
|
+
</div>
|
48
|
+
|
49
|
+
</div>
|
50
|
+
</body>
|
51
|
+
</html>
|
52
|
+
|
data/lib/js.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
module JavaScript
|
2
|
+
def JavaScript.Version
|
3
|
+
return '0.1'
|
4
|
+
end
|
5
|
+
class Object
|
6
|
+
def initialize(hash={}, constants=[]) #Put keys into constants that you want to be read only
|
7
|
+
@hash,@constants=hash,constants
|
8
|
+
end
|
9
|
+
def method_missing(name, *args, &block)
|
10
|
+
if name.to_s =~ /=$/
|
11
|
+
raise "Cannot modify object constant - #{name.to_s.sub(/=/,'')}" if @constants.include? name.to_s.sub(/=/,'').to_sym
|
12
|
+
@hash[name.to_s.sub(/=/,'').to_sym] = ((args==[]) ? ((block.nil?) ? nil : block) : args[0])
|
13
|
+
elsif name =~ /^\/(.+?)$/
|
14
|
+
/($1.to_sym) #/
|
15
|
+
else
|
16
|
+
return @hash[name]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
def /(args=:elements) #/
|
20
|
+
case args
|
21
|
+
when :elements
|
22
|
+
return @hash.keys
|
23
|
+
when :constants
|
24
|
+
return @constants.keys
|
25
|
+
else
|
26
|
+
return nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
class Function
|
32
|
+
def initialize(&code)
|
33
|
+
@code = code
|
34
|
+
end
|
35
|
+
|
36
|
+
def [](*args)
|
37
|
+
i='a'; string=''
|
38
|
+
while(arg = args.shift)
|
39
|
+
@temp = {}
|
40
|
+
eval "@temp[:#{i}] = arg"
|
41
|
+
string << ", @temp[:#{i}]"
|
42
|
+
i.next!
|
43
|
+
end
|
44
|
+
string.sub!(/\,/,'')
|
45
|
+
eval "@code.call #{string}"
|
46
|
+
@temp = nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
data/test/test.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require_relative '../javascript.gem'
|
2
|
+
puts "Creating object JavaScript::Object.new({ :foo => 'bar', :hello => 'world' }, [ :hello ] "
|
3
|
+
obj = JavaScript::Object.new({ :foo => 'bar', :hello => 'world' }, [ :hello ])
|
4
|
+
puts "Setting obj.foo to 'car'"
|
5
|
+
obj.foo = 'car'
|
6
|
+
(obj.foo == 'car') ? puts 'Success' : puts "Failed to set obj.foo to 'car'"
|
7
|
+
puts "Creating new element cat"
|
8
|
+
obj.cat = true
|
9
|
+
(obj.cat) ? puts "Success" : puts "Cat element not created"
|
10
|
+
puts "Attempting to write constant 'hello'"
|
11
|
+
begin
|
12
|
+
obj.hello = 'fail'
|
13
|
+
puts 'Constant not write protected'
|
14
|
+
rescue
|
15
|
+
puts 'Success'
|
16
|
+
end
|
17
|
+
|
18
|
+
puts "Attempting to read elements"
|
19
|
+
(obj/:elements) ? puts "Success" : puts "Failed"
|
20
|
+
|
21
|
+
puts "Testing JavaScript::Function"
|
22
|
+
function = JavaScript::Function.new { true }
|
23
|
+
if function.class == Proc
|
24
|
+
puts 'Success'
|
25
|
+
end
|
26
|
+
puts "Testing successful use of JavaScript::Function#[]"
|
27
|
+
if (function[].class == TrueClass)
|
28
|
+
puts 'Success'
|
29
|
+
end
|
30
|
+
|
metadata
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubyserif
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Matt Carey[swarley]
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-14 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A JavaScript-ish interface for ruby including a JSON object class like
|
15
|
+
OpenStruct. And a function class that resembles making anonymous functions, named
|
16
|
+
ones to come? Maybe?
|
17
|
+
email: matthew.b.carey@gmail.com
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- doc/lib/js_rb.html
|
23
|
+
- doc/Makefile.html
|
24
|
+
- doc/rdoc.css
|
25
|
+
- doc/images/page_white_width.png
|
26
|
+
- doc/images/page_white_text.png
|
27
|
+
- doc/images/tag_green.png
|
28
|
+
- doc/images/find.png
|
29
|
+
- doc/images/zoom.png
|
30
|
+
- doc/images/page_green.png
|
31
|
+
- doc/images/bullet_black.png
|
32
|
+
- doc/images/bullet_toggle_minus.png
|
33
|
+
- doc/images/ruby.png
|
34
|
+
- doc/images/wrench_orange.png
|
35
|
+
- doc/images/date.png
|
36
|
+
- doc/images/brick_link.png
|
37
|
+
- doc/images/loadingAnimation.gif
|
38
|
+
- doc/images/bullet_toggle_plus.png
|
39
|
+
- doc/images/plugin.png
|
40
|
+
- doc/images/wrench.png
|
41
|
+
- doc/images/brick.png
|
42
|
+
- doc/images/macFFBgHack.png
|
43
|
+
- doc/images/package.png
|
44
|
+
- doc/images/bug.png
|
45
|
+
- doc/JavaScript/Function.html
|
46
|
+
- doc/JavaScript/Object.html
|
47
|
+
- doc/JavaScript.html
|
48
|
+
- doc/js/jquery.js
|
49
|
+
- doc/js/thickbox-compressed.js
|
50
|
+
- doc/js/darkfish.js
|
51
|
+
- doc/js/quicksearch.js
|
52
|
+
- doc/test/test_rb.html
|
53
|
+
- doc/created.rid
|
54
|
+
- doc/index.html
|
55
|
+
- lib/js.rb
|
56
|
+
- Makefile
|
57
|
+
- test/test.rb
|
58
|
+
- README.md
|
59
|
+
homepage: https://github.com/swarley/rubyserif
|
60
|
+
licenses: []
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 1.8.11
|
80
|
+
signing_key:
|
81
|
+
specification_version: 3
|
82
|
+
summary: Javascripty things to use. No dependencies, one file, yeah. As simple as
|
83
|
+
it gets.
|
84
|
+
test_files: []
|