livecode 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +27 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/bin/livecode_server +34 -0
- data/lib/livecode.rb +0 -0
- data/lib/livecode_server/client.rb +21 -0
- data/lib/livecode_server/daemon.rb +31 -0
- data/lib/livecode_server/scope.rb +14 -0
- data/lib/livecode_server.rb +40 -0
- data/livecode.gemspec +61 -0
- data/test/helper.rb +11 -0
- data/test/test_livecode_server.rb +30 -0
- metadata +80 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008-2009 Inge Jørgensen
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
= Livecode
|
2
|
+
|
3
|
+
Livecoding toolkit for Ruby. Primarily intended for Textmate on OSX, but the server should work on any *nix variant.
|
4
|
+
|
5
|
+
More to come.
|
6
|
+
|
7
|
+
== Installation
|
8
|
+
|
9
|
+
First, install the gem:
|
10
|
+
|
11
|
+
gem install livecode
|
12
|
+
|
13
|
+
== Usage
|
14
|
+
|
15
|
+
Once you're set up, fire up the server:
|
16
|
+
|
17
|
+
livecode_server run
|
18
|
+
|
19
|
+
== Connecting to the Livecode server
|
20
|
+
|
21
|
+
require 'livecode_server'
|
22
|
+
client = LivecodeServer::Client.new
|
23
|
+
|
24
|
+
You can now send code to the server:
|
25
|
+
|
26
|
+
client.run 'message = "Hello world!"'
|
27
|
+
client.run 'puts message'
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "livecode"
|
8
|
+
gem.summary = %Q{OSX livecoding toolkit}
|
9
|
+
gem.description = %Q{A toolkit for livecoding using Ruby and TextMate on OSX}
|
10
|
+
gem.email = "inge@elektronaut.no"
|
11
|
+
gem.homepage = "http://github.com/elektronaut/livecode"
|
12
|
+
gem.authors = ["Inge Jørgensen"]
|
13
|
+
gem.add_dependency "daemons"
|
14
|
+
#gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "livecode #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/bin/livecode_server
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
|
4
|
+
|
5
|
+
require 'rubygems'
|
6
|
+
require 'daemons'
|
7
|
+
require 'livecode_server'
|
8
|
+
|
9
|
+
LivecodeServer.make_dir!
|
10
|
+
|
11
|
+
daemon_options = {
|
12
|
+
:dir_mode => :normal,
|
13
|
+
:dir => LivecodeServer::CONFIG_DIR
|
14
|
+
}
|
15
|
+
|
16
|
+
group = Daemons.run_proc(File.basename($0), daemon_options) do
|
17
|
+
server = LivecodeServer::Daemon.new
|
18
|
+
unless LivecodeServer.running?
|
19
|
+
DRb.start_service nil, server
|
20
|
+
LivecodeServer.register_uri DRb.uri
|
21
|
+
puts "Started Livecode server on #{DRb.uri}"
|
22
|
+
puts "Press ^C to exit"
|
23
|
+
trap_proc = proc{
|
24
|
+
puts "Exiting..."
|
25
|
+
LivecodeServer.register_shutdown
|
26
|
+
exit
|
27
|
+
}
|
28
|
+
%w{SIGINT TERM}.each{|s| trap s, trap_proc}
|
29
|
+
DRb.thread.join
|
30
|
+
else
|
31
|
+
puts "Livecode server appears to be running on #{LivecodeServer.uri}. Please check your processes."
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
data/lib/livecode.rb
ADDED
File without changes
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module LivecodeServer
|
2
|
+
class ConnectionError < StandardError; end
|
3
|
+
|
4
|
+
class Client
|
5
|
+
def server
|
6
|
+
unless @server
|
7
|
+
if LivecodeServer.running?
|
8
|
+
DRb.start_service
|
9
|
+
@server = DRbObject.new nil, LivecodeServer.uri
|
10
|
+
else
|
11
|
+
raise ConnectionError, "Server not running", caller
|
12
|
+
end
|
13
|
+
end
|
14
|
+
@server
|
15
|
+
end
|
16
|
+
|
17
|
+
def run(code)
|
18
|
+
server.run code
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module LivecodeServer
|
2
|
+
class Daemon
|
3
|
+
attr_reader :scope
|
4
|
+
|
5
|
+
def initialize(scope=nil)
|
6
|
+
@scope = Scope.new(self)
|
7
|
+
@output = ""
|
8
|
+
end
|
9
|
+
|
10
|
+
def output(string, prefix=nil)
|
11
|
+
@output += string + "\n"
|
12
|
+
puts (prefix) ? "#{prefix} #{string}" : string
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def run(code)
|
17
|
+
code = code.strip
|
18
|
+
@output = ""
|
19
|
+
puts
|
20
|
+
begin
|
21
|
+
puts "--- #{Time.now}:"
|
22
|
+
puts ">> #{code}"
|
23
|
+
result = eval(code, @scope.get_binding)
|
24
|
+
puts "=> #{result}"
|
25
|
+
rescue Exception => e
|
26
|
+
output "#{e.class}: #{e}", "!!"
|
27
|
+
end
|
28
|
+
return @output
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'drb'
|
2
|
+
require 'etc'
|
3
|
+
|
4
|
+
[:daemon, :scope, :client].each do |f|
|
5
|
+
require File.join(File.dirname(__FILE__), "livecode_server/#{f}")
|
6
|
+
end
|
7
|
+
|
8
|
+
module LivecodeServer
|
9
|
+
CONFIG_DIR = File.join(Etc.getpwuid.dir, '.config/livecode')
|
10
|
+
URI_FILE = File.join(CONFIG_DIR, 'livecode_server.uri')
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
def uri
|
15
|
+
if File.exists?(URI_FILE)
|
16
|
+
File.read(URI_FILE)
|
17
|
+
else
|
18
|
+
false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def make_dir!
|
23
|
+
FileUtils.mkdir_p(CONFIG_DIR)
|
24
|
+
end
|
25
|
+
|
26
|
+
def running?
|
27
|
+
uri ? true : false
|
28
|
+
end
|
29
|
+
|
30
|
+
def register_uri(uri)
|
31
|
+
File.open(URI_FILE, 'w'){|fh| fh.write uri}
|
32
|
+
end
|
33
|
+
|
34
|
+
def register_shutdown
|
35
|
+
File.unlink(URI_FILE)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
data/livecode.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{livecode}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Inge J\303\270rgensen"]
|
12
|
+
s.date = %q{2009-10-21}
|
13
|
+
s.default_executable = %q{livecode_server}
|
14
|
+
s.description = %q{A toolkit for livecoding using Ruby and TextMate on OSX}
|
15
|
+
s.email = %q{inge@elektronaut.no}
|
16
|
+
s.executables = ["livecode_server"]
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".gitignore",
|
24
|
+
"LICENSE",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"bin/livecode_server",
|
29
|
+
"lib/livecode.rb",
|
30
|
+
"lib/livecode_server.rb",
|
31
|
+
"lib/livecode_server/client.rb",
|
32
|
+
"lib/livecode_server/daemon.rb",
|
33
|
+
"lib/livecode_server/scope.rb",
|
34
|
+
"livecode.gemspec",
|
35
|
+
"test/helper.rb",
|
36
|
+
"test/test_livecode_server.rb"
|
37
|
+
]
|
38
|
+
s.homepage = %q{http://github.com/elektronaut/livecode}
|
39
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
40
|
+
s.require_paths = ["lib"]
|
41
|
+
s.rubygems_version = %q{1.3.5}
|
42
|
+
s.summary = %q{OSX livecoding toolkit}
|
43
|
+
s.test_files = [
|
44
|
+
"test/helper.rb",
|
45
|
+
"test/test_livecode_server.rb"
|
46
|
+
]
|
47
|
+
|
48
|
+
if s.respond_to? :specification_version then
|
49
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
|
+
s.specification_version = 3
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_runtime_dependency(%q<daemons>, [">= 0"])
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<daemons>, [">= 0"])
|
56
|
+
end
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<daemons>, [">= 0"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/test/helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'shoulda'
|
4
|
+
|
5
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
+
require 'livecode'
|
8
|
+
require 'livecode_server'
|
9
|
+
|
10
|
+
class Test::Unit::TestCase
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestLivecodeServer < Test::Unit::TestCase
|
4
|
+
context "A client" do
|
5
|
+
setup do
|
6
|
+
@client = LivecodeServer::Client.new
|
7
|
+
end
|
8
|
+
should "connect" do
|
9
|
+
assert @client.run("true")
|
10
|
+
end
|
11
|
+
should "evaluate puts commands to strings" do
|
12
|
+
assert_equal "Hello world!\n", @client.run('puts "Hello world!"')
|
13
|
+
end
|
14
|
+
should "not crash on undefined methods" do
|
15
|
+
assert @client.run('this_is_an_undefined_method')
|
16
|
+
end
|
17
|
+
should "not crash on open parenthesis" do
|
18
|
+
assert_raise LocalJumpError, @client.run('(1')
|
19
|
+
end
|
20
|
+
should "not crash on open bracket" do
|
21
|
+
assert_raise LocalJumpError, @client.run('[1')
|
22
|
+
end
|
23
|
+
should "not crash on open method" do
|
24
|
+
assert_raise LocalJumpError, @client.run('def hi; puts "yo"')
|
25
|
+
end
|
26
|
+
should "not crash on open class" do
|
27
|
+
assert_raise LocalJumpError, @client.run('class MyClass')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: livecode
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Inge J\xC3\xB8rgensen"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-21 00:00:00 +02:00
|
13
|
+
default_executable: livecode_server
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: daemons
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description: A toolkit for livecoding using Ruby and TextMate on OSX
|
26
|
+
email: inge@elektronaut.no
|
27
|
+
executables:
|
28
|
+
- livecode_server
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- LICENSE
|
33
|
+
- README.rdoc
|
34
|
+
files:
|
35
|
+
- .document
|
36
|
+
- .gitignore
|
37
|
+
- LICENSE
|
38
|
+
- README.rdoc
|
39
|
+
- Rakefile
|
40
|
+
- VERSION
|
41
|
+
- bin/livecode_server
|
42
|
+
- lib/livecode.rb
|
43
|
+
- lib/livecode_server.rb
|
44
|
+
- lib/livecode_server/client.rb
|
45
|
+
- lib/livecode_server/daemon.rb
|
46
|
+
- lib/livecode_server/scope.rb
|
47
|
+
- livecode.gemspec
|
48
|
+
- test/helper.rb
|
49
|
+
- test/test_livecode_server.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage: http://github.com/elektronaut/livecode
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options:
|
56
|
+
- --charset=UTF-8
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: "0"
|
70
|
+
version:
|
71
|
+
requirements: []
|
72
|
+
|
73
|
+
rubyforge_project:
|
74
|
+
rubygems_version: 1.3.5
|
75
|
+
signing_key:
|
76
|
+
specification_version: 3
|
77
|
+
summary: OSX livecoding toolkit
|
78
|
+
test_files:
|
79
|
+
- test/helper.rb
|
80
|
+
- test/test_livecode_server.rb
|