goat 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ class AutoBind
4
+ def initialize(inp, out)
5
+ @inp = inp
6
+ @out = out
7
+ end
8
+
9
+ def self.process(str)
10
+ out = StringIO.new
11
+ new(StringIO.new(str), out).process
12
+ out.string
13
+ end
14
+
15
+ def process
16
+ brace_count = 0
17
+ while char = @inp.getc
18
+ case char
19
+ when ?^
20
+ char2 = @inp.getc
21
+ if char2 == ?{ || char2 == ?(
22
+ expand(char2)
23
+ else
24
+ brace_count += 1
25
+ @out.putc char
26
+ @out.putc char2 if char2
27
+ end
28
+ when ?{
29
+ brace_count += 1
30
+ @out.putc char
31
+ when ?}
32
+ brace_count -= 1
33
+ @out.putc char
34
+ if brace_count < 0
35
+ return
36
+ end
37
+ when ?", ?'
38
+ @out.putc char
39
+ string(char)
40
+ else
41
+ @out.putc char
42
+ end
43
+ end
44
+ end
45
+
46
+ def expand(c)
47
+ @out.write("(closure(this, function(")
48
+
49
+ if c == ?(
50
+ while (c2 = @inp.getc) != ?)
51
+ @out.putc c2
52
+ end
53
+ while @inp.getc != ?{
54
+ nil
55
+ end
56
+ end
57
+
58
+ @out.write("){")
59
+ process
60
+ @out.write("))")
61
+ end
62
+
63
+ def string(delim)
64
+ while char = @inp.getc
65
+ case char
66
+ when ?\\
67
+ char2 = @inp.getc
68
+ @out.putc char
69
+ @out.putc char2 if char2
70
+ when delim
71
+ @out.putc char
72
+ return
73
+ else
74
+ @out.putc char
75
+ end
76
+ end
77
+ end
78
+ end
79
+
80
+ if __FILE__ == $0
81
+ inp = $stdin
82
+ out = $stdout
83
+ if inf_name = ARGV.shift
84
+ inp = File.open(inf_name, "r")
85
+ end
86
+ if outf_name = ARGV.shift
87
+ out = File.open(outf_name, "w+")
88
+ end
89
+ AutoBind.new(inp, out).process
90
+ end
@@ -0,0 +1,29 @@
1
+ var Component = Class.extend({
2
+ init: function(cls, id) {
3
+ this.id = id;
4
+ this.cls = cls;
5
+ },
6
+
7
+ onLoad: function() {
8
+ this.node = $("#" + this.id);
9
+ },
10
+
11
+ rpc: function(name, args, callback, er) {
12
+ args['_id'] = this.id;
13
+ args['_rpc'] = name;
14
+ args['_component'] = this.cls;
15
+ $.ajax({
16
+ type: 'POST',
17
+ url: '/rpc',
18
+ data: args,
19
+ success: callback,
20
+ error: er,
21
+ dataType: 'json',
22
+ async: true
23
+ });
24
+ },
25
+
26
+ $: function(sel) {
27
+ return $("#" + this.id + " " + sel);
28
+ }
29
+ });
@@ -0,0 +1,24 @@
1
+ require 'yaml'
2
+
3
+ module Goat
4
+ class Static
5
+ class << self
6
+ def press_enabled?
7
+ not @press.nil?
8
+ end
9
+
10
+ def press=(h)
11
+ @press = YAML.load_file(h[:file])
12
+ @rsrc = h[:resource]
13
+ end
14
+
15
+ def pressed?(c)
16
+ @press[:classes].include?(c.to_s)
17
+ end
18
+
19
+ def press_resource
20
+ @rsrc
21
+ end
22
+ end
23
+ end
24
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goat
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Patrick Collison
@@ -29,6 +29,7 @@ extra_rdoc_files: []
29
29
 
30
30
  files:
31
31
  - bin/yodel
32
+ - lib/goat/autobind.rb
32
33
  - lib/goat/extn.rb
33
34
  - lib/goat/goat.js
34
35
  - lib/goat.rb
@@ -38,7 +39,9 @@ files:
38
39
  - lib/goat/notifications.rb
39
40
  - lib/goat/sinatra.rb
40
41
  - lib/goat/yodel.rb
42
+ - lib/goat/static.rb
41
43
  - lib/views/plain_layout.erb
44
+ - lib/goat/js/component.js
42
45
  has_rdoc: true
43
46
  homepage: http://goatweb.org
44
47
  licenses: []