live 0.1.2 → 0.2.0
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.
- checksums.yaml +7 -0
- data/lib/live.rb +26 -89
- data/lib/live/element.rb +57 -0
- data/lib/live/page.rb +95 -0
- data/lib/live/resolver.rb +66 -0
- data/lib/live/version.rb +3 -1
- data/lib/live/view.rb +51 -0
- metadata +115 -108
- data/.gitignore +0 -5
- data/Gemfile +0 -4
- data/README.rdoc +0 -37
- data/Rakefile +0 -2
- data/bin/live +0 -6
- data/lib/ext/object.rb +0 -21
- data/live.gemspec +0 -25
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f33999c1164c25bd9fccfac8d7be846b6ad536ae04da0302b450662a7db1624f
|
4
|
+
data.tar.gz: 0bbd2f3b7b06819b9ae5cb8b057277a1885fe7d44598238a46d21704eb62173c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a5bcd37c979d0155cd70b822f7959ae7d97661c7652f2e945cc9b9ff6ff4a099600894f8348b0b135abeb90dd1156e724ed2b063b68c2c908c5823240b41af3c
|
7
|
+
data.tar.gz: 68aae390d5d46ca5e81d4f333a40d3db1e9fbf8394d41600576dace4b0a2bd2df5c94ab8795cbdd156bab01e07ecc0b372d84853c5e99c965481b4fb1f9a0ce6
|
data/lib/live.rb
CHANGED
@@ -1,90 +1,27 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative "live/version"
|
24
|
+
|
25
|
+
require_relative 'live/page'
|
26
|
+
require_relative 'live/view'
|
3
27
|
|
4
|
-
$LOAD_PATH.unshift File.dirname(__FILE__)
|
5
|
-
require 'ext/object'
|
6
|
-
|
7
|
-
module Live
|
8
|
-
class Notice < String; end
|
9
|
-
|
10
|
-
class Context
|
11
|
-
def initialize session
|
12
|
-
@session = session
|
13
|
-
@binding = binding
|
14
|
-
end
|
15
|
-
|
16
|
-
def eval string
|
17
|
-
begin
|
18
|
-
super string, @binding
|
19
|
-
rescue Exception => exception
|
20
|
-
SystemExit === exception ? quit! : exception
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Binds a proc to a keystroke
|
25
|
-
def bind_key key, &block
|
26
|
-
@session.key_bindings[key.to_s.unpack('c').first] = block
|
27
|
-
Notice.new "Key '#{key}' is bound to an action" if block
|
28
|
-
end
|
29
|
-
|
30
|
-
def quit!
|
31
|
-
@session.quit!
|
32
|
-
end
|
33
|
-
|
34
|
-
def reset!
|
35
|
-
@session.key_bindings.clear
|
36
|
-
@session.new_context
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
class Session
|
41
|
-
include HighLine::SystemExtensions
|
42
|
-
attr_reader :path, :key_bindings
|
43
|
-
|
44
|
-
# Starts a live session using a named pipe to receive code from a remote source and evaluates it within a context, a bit like an IRB session but evaluates code sent from a text editor
|
45
|
-
def initialize path = "#{Dir.tmpdir}/live-rb"
|
46
|
-
raise Exception.new("Another session sems to be running: #{path}") if File.exist? path
|
47
|
-
puts Notice.new("Live Session: #{path}")
|
48
|
-
|
49
|
-
%x{mkfifo #{path}}
|
50
|
-
@pipe, @path, @key_bindings = File.open(path, 'r+'), path, {}
|
51
|
-
|
52
|
-
begin
|
53
|
-
new_context and key_listen and run!
|
54
|
-
ensure
|
55
|
-
File.delete(path) if File.exists? path
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
def quit!
|
60
|
-
File.delete(@path) && exit
|
61
|
-
end
|
62
|
-
|
63
|
-
def puts obj
|
64
|
-
super obj.colored_inspect
|
65
|
-
# Hackish solution for cursor position
|
66
|
-
super "\e[200D"
|
67
|
-
super "\e[2A"
|
68
|
-
end
|
69
|
-
|
70
|
-
def new_context
|
71
|
-
@context = Context.new(self)
|
72
|
-
end
|
73
|
-
|
74
|
-
private
|
75
|
-
# Starts a loop that checks the named pipe and evaluate its contents, will be called on initialize
|
76
|
-
def run!
|
77
|
-
loop { puts @context.eval(@pipe.gets) }
|
78
|
-
end
|
79
|
-
|
80
|
-
# Listen for keystrokes and calls bound procs
|
81
|
-
def key_listen
|
82
|
-
Thread.new do
|
83
|
-
loop do
|
84
|
-
block = @key_bindings[get_character]
|
85
|
-
puts block.call if block
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end
|
data/lib/live/element.rb
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'json'
|
24
|
+
|
25
|
+
module Live
|
26
|
+
class Element
|
27
|
+
def initialize(id, **data)
|
28
|
+
@id = id
|
29
|
+
@data = data
|
30
|
+
@data[:class] ||= self.class.name
|
31
|
+
|
32
|
+
@page = nil
|
33
|
+
end
|
34
|
+
|
35
|
+
attr :id
|
36
|
+
|
37
|
+
def forward(details = nil)
|
38
|
+
if details
|
39
|
+
"live.forward(#{JSON.dump(@id)}, event, #{JSON.dump(details)})"
|
40
|
+
else
|
41
|
+
"live.forward(#{JSON.dump(@id)}, event)"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def bind(page)
|
46
|
+
@page = page
|
47
|
+
end
|
48
|
+
|
49
|
+
def handle(event, details)
|
50
|
+
end
|
51
|
+
|
52
|
+
def rpc(method, arguments)
|
53
|
+
# This update might not be sent right away. Therefore, mutable arguments may be serialized to JSON at a later time (or never). This could be a race condition:
|
54
|
+
@page.updates.enqueue([method, arguments])
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
data/lib/live/page.rb
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'element'
|
24
|
+
require_relative 'resolver'
|
25
|
+
|
26
|
+
require 'async'
|
27
|
+
require 'async/queue'
|
28
|
+
|
29
|
+
module Live
|
30
|
+
class Page
|
31
|
+
def initialize(resolver)
|
32
|
+
@resolver = resolver
|
33
|
+
|
34
|
+
@elements = {}
|
35
|
+
@updates = Async::Queue.new
|
36
|
+
end
|
37
|
+
|
38
|
+
attr :updates
|
39
|
+
|
40
|
+
def bind(element)
|
41
|
+
@elements[element.id] = element
|
42
|
+
|
43
|
+
element.bind(self)
|
44
|
+
end
|
45
|
+
|
46
|
+
def resolve(id, data)
|
47
|
+
@resolver.call(id, data)
|
48
|
+
end
|
49
|
+
|
50
|
+
def handle(id, event, details)
|
51
|
+
if element = @elements[id]
|
52
|
+
return element.handle(event, details)
|
53
|
+
else
|
54
|
+
Console.logger.warn(self, "Could not handle event:", event, details)
|
55
|
+
end
|
56
|
+
|
57
|
+
return nil
|
58
|
+
end
|
59
|
+
|
60
|
+
def run(connection)
|
61
|
+
reader_task = start_reader(connection)
|
62
|
+
|
63
|
+
while update = @updates.dequeue
|
64
|
+
Console.logger.debug(self, "Sending update:", update)
|
65
|
+
|
66
|
+
connection.write(update)
|
67
|
+
connection.flush if @updates.empty?
|
68
|
+
end
|
69
|
+
ensure
|
70
|
+
reader_task&.stop
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def start_reader(connection)
|
76
|
+
Async do
|
77
|
+
while message = connection.read
|
78
|
+
Console.logger.debug(self, "Reading message:", message)
|
79
|
+
|
80
|
+
if id = message[:bind] and data = message[:data]
|
81
|
+
if element = self.resolve(id, data)
|
82
|
+
self.bind(element)
|
83
|
+
else
|
84
|
+
Console.logger.warn(self, "Could not resolve element:", message)
|
85
|
+
end
|
86
|
+
elsif id = message[:id]
|
87
|
+
self.handle(id, message[:event], message[:details])
|
88
|
+
else
|
89
|
+
Console.logger.warn(self, "Unhandled message:", message)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'element'
|
24
|
+
|
25
|
+
module Live
|
26
|
+
# Resolves a client-side tag into a server-side instance.
|
27
|
+
class Resolver
|
28
|
+
# Creates an instance of the resolver, allowing the specified classes to be resolved.
|
29
|
+
def self.allow(*arguments)
|
30
|
+
self.new.allow(*arguments).freeze
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize
|
34
|
+
@allowed = {}
|
35
|
+
end
|
36
|
+
|
37
|
+
attr :allowed
|
38
|
+
|
39
|
+
def freeze
|
40
|
+
return self unless frozen?
|
41
|
+
|
42
|
+
@allowed.freeze
|
43
|
+
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
# Allow the specified classes to be resolved.
|
48
|
+
def allow(*arguments)
|
49
|
+
arguments.each do |klass|
|
50
|
+
@allowed[klass.name] = klass
|
51
|
+
end
|
52
|
+
|
53
|
+
return self
|
54
|
+
end
|
55
|
+
|
56
|
+
# Resolve a tag.
|
57
|
+
# @parameter id [String] The unique identifier for the tag.
|
58
|
+
# @parameter data [Hash] The data associated with the tag. Should include the `:class` key.
|
59
|
+
# @returns [Element] The element instance if it was allowed.
|
60
|
+
def call(id, data)
|
61
|
+
if klass = @allowed[data[:class]]
|
62
|
+
return klass.new(id, **data)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/live/version.rb
CHANGED
data/lib/live/view.rb
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
# of this software and associated documentation files (the "Software"), to deal
|
7
|
+
# in the Software without restriction, including without limitation the rights
|
8
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
# copies of the Software, and to permit persons to whom the Software is
|
10
|
+
# furnished to do so, subject to the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be included in
|
13
|
+
# all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
# THE SOFTWARE.
|
22
|
+
|
23
|
+
require_relative 'element'
|
24
|
+
require 'trenni/builder'
|
25
|
+
|
26
|
+
module Live
|
27
|
+
class View < Element
|
28
|
+
def replace!
|
29
|
+
rpc(:replace, [@id, self.to_html])
|
30
|
+
end
|
31
|
+
|
32
|
+
def append!(node)
|
33
|
+
rpc(:append, [@id, node.to_html])
|
34
|
+
end
|
35
|
+
|
36
|
+
def prepend!(node)
|
37
|
+
rpc(:prepend, [@id, node.to_html])
|
38
|
+
end
|
39
|
+
|
40
|
+
def render(builder)
|
41
|
+
end
|
42
|
+
|
43
|
+
def to_html
|
44
|
+
Trenni::Builder.fragment do |builder|
|
45
|
+
builder.tag :div, id: @id, class: 'live', data: @data do
|
46
|
+
render(builder)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
metadata
CHANGED
@@ -1,125 +1,132 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: live
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
version: 0.1.2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
13
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Samuel Williams
|
8
|
+
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
date: 2021-04-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: trenni
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
22
21
|
prerelease: false
|
23
|
-
|
24
|
-
|
25
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
26
24
|
- - ">="
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: async-websocket
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
31
34
|
type: :runtime
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
-
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: async-rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: covered
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.6'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.6'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
executables: []
|
40
100
|
extensions: []
|
41
|
-
|
42
101
|
extra_rdoc_files: []
|
43
|
-
|
44
|
-
files:
|
45
|
-
- .gitignore
|
46
|
-
- Gemfile
|
47
|
-
- README.rdoc
|
48
|
-
- Rakefile
|
49
|
-
- bin/live
|
50
|
-
- lib/ext/object.rb
|
102
|
+
files:
|
51
103
|
- lib/live.rb
|
104
|
+
- lib/live/element.rb
|
105
|
+
- lib/live/page.rb
|
106
|
+
- lib/live/resolver.rb
|
52
107
|
- lib/live/version.rb
|
53
|
-
- live.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
post_install_message:
|
59
|
-
== Live
|
60
|
-
|
61
|
-
Live is like irb only it is meant to be used from a text editor, it essentially polls a *nix pipe and evaluates its contents.
|
62
|
-
It was devised for audiovisual livecoding (ruby-processing and scruby), a block can be bound to a key and can be called later by a keystroke.
|
63
|
-
|
64
|
-
== Install
|
65
|
-
|
66
|
-
$ [sudo] gem install live
|
67
|
-
|
68
|
-
|
69
|
-
== Usage
|
70
|
-
|
71
|
-
$ live
|
72
|
-
|
73
|
-
open a new terminal
|
74
|
-
|
75
|
-
$ echo ' "hello" ' > /tmp/live-rb
|
76
|
-
|
77
|
-
You will see the code evaluated in the first terminal
|
78
|
-
|
79
|
-
$ echo 'bind_key(:a){ "key a was pressed" }' > /tmp/live-rb
|
80
|
-
|
81
|
-
When you press the key 'a' with focus on the first terminal it will call the block
|
82
|
-
|
83
|
-
|
84
|
-
== Vim
|
85
|
-
|
86
|
-
To use from vim paste this in your .vimrc file
|
87
|
-
|
88
|
-
function EvalLiveRuby() range
|
89
|
-
let text = [join(getline(a:firstline, a:lastline), ';')]
|
90
|
-
return writefile(text, '/tmp/live-rb')
|
91
|
-
endfunction
|
92
|
-
|
93
|
-
map <Leader>x :call EvalLiveRuby()<enter>
|
94
|
-
|
95
|
-
Then by pressing leader and x you will execute the range in the live session
|
96
|
-
|
108
|
+
- lib/live/view.rb
|
109
|
+
homepage: https://github.com/socketry/live
|
110
|
+
licenses:
|
111
|
+
- MIT
|
112
|
+
metadata: {}
|
113
|
+
post_install_message:
|
97
114
|
rdoc_options: []
|
98
|
-
|
99
|
-
require_paths:
|
115
|
+
require_paths:
|
100
116
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
103
|
-
requirements:
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
104
119
|
- - ">="
|
105
|
-
- !ruby/object:Gem::Version
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
-
none: false
|
111
|
-
requirements:
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: 2.5.0
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
112
124
|
- - ">="
|
113
|
-
- !ruby/object:Gem::Version
|
114
|
-
|
115
|
-
- 0
|
116
|
-
version: "0"
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
117
127
|
requirements: []
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
specification_version: 3
|
123
|
-
summary: Live is like irb only it is meant to be used from a text editor
|
128
|
+
rubygems_version: 3.2.3
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Live HTML tags updated via a WebSocket.
|
124
132
|
test_files: []
|
125
|
-
|
data/Gemfile
DELETED
data/README.rdoc
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
== Live
|
2
|
-
|
3
|
-
Live is like irb only it is meant to be used from a text editor, it essentially polls a *nix pipe and evaluates its contents.
|
4
|
-
It was devised for audiovisual livecoding (ruby-processing and scruby), a block can be bound to a key and can be called later by a keystroke.
|
5
|
-
|
6
|
-
== Install
|
7
|
-
|
8
|
-
$ [sudo] gem install live
|
9
|
-
|
10
|
-
|
11
|
-
== Usage
|
12
|
-
|
13
|
-
$ live
|
14
|
-
|
15
|
-
open a new terminal
|
16
|
-
|
17
|
-
$ echo ' "hello" ' > /tmp/live-rb
|
18
|
-
|
19
|
-
You will see the code evaluated in the first terminal
|
20
|
-
|
21
|
-
$ echo 'bind_key(:a){ "key a was pressed" }' > /tmp/live-rb
|
22
|
-
|
23
|
-
When you press the key 'a' with focus on the first terminal it will call the block
|
24
|
-
|
25
|
-
|
26
|
-
== Vim
|
27
|
-
|
28
|
-
To use from vim paste this in your .vimrc file
|
29
|
-
|
30
|
-
function EvalLiveRuby() range
|
31
|
-
let text = [join(getline(a:firstline, a:lastline), ';')]
|
32
|
-
return writefile(text, '/tmp/live-rb')
|
33
|
-
endfunction
|
34
|
-
|
35
|
-
map <Leader>x :call EvalLiveRuby()<enter>
|
36
|
-
|
37
|
-
Then by pressing leader and x you will execute the range in the live session
|
data/Rakefile
DELETED
data/bin/live
DELETED
data/lib/ext/object.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# Outputs an ANSI colored string with the object representation
|
3
|
-
def colored_inspect
|
4
|
-
case self
|
5
|
-
when Exception
|
6
|
-
"\e[41;33m#{self.inspect}\e[0m"
|
7
|
-
when Numeric, Symbol, TrueClass, FalseClass, NilClass
|
8
|
-
"\e[35m#{self.inspect}\e[0m"
|
9
|
-
when Live::Notice
|
10
|
-
"\e[42;30m#{self}\e[0m"
|
11
|
-
when String
|
12
|
-
"\e[32m#{self.inspect}\e[0m"
|
13
|
-
when Array
|
14
|
-
"[#{ self.collect{ |i| i.colored_inspect}.join(', ') }]"
|
15
|
-
when Hash
|
16
|
-
"{#{ self.collect{ |i| i.collect{|e| e.colored_inspect}.join(' => ') }.join(', ') }}"
|
17
|
-
else
|
18
|
-
"\e[36m#{self}\e[0m"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/live.gemspec
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path("../lib", __FILE__)
|
3
|
-
require "live/version"
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = "live"
|
7
|
-
s.version = Live::VERSION
|
8
|
-
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = ["Macario Ortega"]
|
10
|
-
s.email = ["macarui@gmail.com"]
|
11
|
-
s.homepage = "http://github.com/maca/live"
|
12
|
-
s.summary = %q{Live is like irb only it is meant to be used from a text editor}
|
13
|
-
s.description = %q{Live is like irb only it is meant to be used from a text editor, it essentially polls a *nix pipe and evaluates its contents.
|
14
|
-
It was devised for audiovisual livecoding (ruby-processing and scruby), a block can be bound to a key and can be called later by a keystroke.}
|
15
|
-
|
16
|
-
s.post_install_message = File.read("#{File.dirname(__FILE__)}/README.rdoc")
|
17
|
-
|
18
|
-
s.add_dependency 'highline'
|
19
|
-
|
20
|
-
s.rubyforge_project = "live"
|
21
|
-
s.files = `git ls-files`.split("\n")
|
22
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
23
|
-
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
24
|
-
s.require_paths = ["lib"]
|
25
|
-
end
|