flammarion-utils 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +165 -147
- data/Readme.md +197 -196
- data/bin/emoji-keyboard +22 -22
- data/bin/engrave +16 -16
- data/bin/flammarion-repl +40 -40
- data/bin/flammarion-services +31 -31
- data/bin/frake +34 -34
- data/bin/fwrap +37 -37
- data/bin/markdown-browser +16 -16
- data/bin/repl +40 -0
- data/bin/services +31 -0
- data/bin/slim-engrave +12 -12
- data/bin/xml-explorer +66 -66
- metadata +25 -28
data/bin/emoji-keyboard
CHANGED
@@ -1,22 +1,22 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Emoji Keyboard Example
|
4
|
-
#
|
5
|
-
# A simple example that will output the selected emoji to STDOUT and a also to
|
6
|
-
# a seperate pane.
|
7
|
-
|
8
|
-
require 'flammarion'
|
9
|
-
|
10
|
-
f = Flammarion::Engraving.new
|
11
|
-
f.style "font-size", "200%"
|
12
|
-
f.pane("output", weight: 0.1).send("> ")
|
13
|
-
f.emoji.keys.each do |emoji|
|
14
|
-
f.button(emoji, escape_icons: true, inline: true) do
|
15
|
-
unicode_char = f.emoji[emoji]['unicode'].last.split("-").map(&:hex).pack("U")
|
16
|
-
f.pane("output").send unicode_char
|
17
|
-
f.status(f.emoji[emoji]['unicode'].last)
|
18
|
-
print unicode_char
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Emoji Keyboard Example
|
4
|
+
#
|
5
|
+
# A simple example that will output the selected emoji to STDOUT and a also to
|
6
|
+
# a seperate pane.
|
7
|
+
|
8
|
+
require 'flammarion'
|
9
|
+
|
10
|
+
f = Flammarion::Engraving.new
|
11
|
+
f.style "font-size", "200%"
|
12
|
+
f.pane("output", weight: 0.1).send("> ")
|
13
|
+
f.emoji.keys.each do |emoji|
|
14
|
+
f.button(emoji, escape_icons: true, inline: true) do
|
15
|
+
unicode_char = f.emoji[emoji]['unicode'].last.split("-").map(&:hex).pack("U")
|
16
|
+
f.pane("output").send unicode_char
|
17
|
+
f.status(f.emoji[emoji]['unicode'].last)
|
18
|
+
print unicode_char
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
f.wait_until_closed
|
data/bin/engrave
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Engrave Example
|
4
|
-
#
|
5
|
-
# A simple example that will print ARGF to a flammarion engraving
|
6
|
-
|
7
|
-
require 'flammarion'
|
8
|
-
|
9
|
-
f = Flammarion::Engraving.new(title:ARGF.filename, exit_on_disconnect:true)
|
10
|
-
f.status("Flammarion version: #{Flammarion::VERSION.green}", :right)
|
11
|
-
|
12
|
-
ARGF.each_line do |l|
|
13
|
-
f.print l
|
14
|
-
end
|
15
|
-
|
16
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Engrave Example
|
4
|
+
#
|
5
|
+
# A simple example that will print ARGF to a flammarion engraving
|
6
|
+
|
7
|
+
require 'flammarion'
|
8
|
+
|
9
|
+
f = Flammarion::Engraving.new(title:ARGF.filename, exit_on_disconnect:true)
|
10
|
+
f.status("Flammarion version: #{Flammarion::VERSION.green}", :right)
|
11
|
+
|
12
|
+
ARGF.each_line do |l|
|
13
|
+
f.print l
|
14
|
+
end
|
15
|
+
|
16
|
+
f.wait_until_closed
|
data/bin/flammarion-repl
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# Repl Example
|
4
|
-
#
|
5
|
-
# A simple interactive example for running a repl in flammarion
|
6
|
-
require 'flammarion'
|
7
|
-
|
8
|
-
class FlammarionRepl
|
9
|
-
def initialize
|
10
|
-
@f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
11
|
-
@f.subpane("output")
|
12
|
-
@f.input("> ", autoclear:true, history:true) {|msg| repl(msg['text']) }
|
13
|
-
end
|
14
|
-
|
15
|
-
def repl(str)
|
16
|
-
@f.subpane("output").puts "> #{str}"
|
17
|
-
result =
|
18
|
-
begin
|
19
|
-
eval(str).to_s.green
|
20
|
-
rescue Exception => e
|
21
|
-
"#{e}".red
|
22
|
-
end
|
23
|
-
@f.subpane("output").puts result
|
24
|
-
end
|
25
|
-
|
26
|
-
def puts(str)
|
27
|
-
@f.subpane("output").puts "#{str}"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
module Kernel
|
32
|
-
def puts(str)
|
33
|
-
$repl.puts(str)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
if __FILE__ == $0 then
|
38
|
-
$repl = FlammarionRepl.new
|
39
|
-
$repl.wait_until_closed
|
40
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Repl Example
|
4
|
+
#
|
5
|
+
# A simple interactive example for running a repl in flammarion
|
6
|
+
require 'flammarion'
|
7
|
+
|
8
|
+
class FlammarionRepl
|
9
|
+
def initialize
|
10
|
+
@f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
11
|
+
@f.subpane("output")
|
12
|
+
@f.input("> ", autoclear:true, history:true) {|msg| repl(msg['text']) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def repl(str)
|
16
|
+
@f.subpane("output").puts "> #{str}"
|
17
|
+
result =
|
18
|
+
begin
|
19
|
+
eval(str).to_s.green
|
20
|
+
rescue Exception => e
|
21
|
+
"#{e}".red
|
22
|
+
end
|
23
|
+
@f.subpane("output").puts result
|
24
|
+
end
|
25
|
+
|
26
|
+
def puts(str)
|
27
|
+
@f.subpane("output").puts "#{str}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Kernel
|
32
|
+
def puts(str)
|
33
|
+
$repl.puts(str)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if __FILE__ == $0 then
|
38
|
+
$repl = FlammarionRepl.new
|
39
|
+
$repl.wait_until_closed
|
40
|
+
end
|
data/bin/flammarion-services
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Service Example
|
4
|
-
#
|
5
|
-
# A simple example that lists the services on the system with buttons to start
|
6
|
-
# and stop them. Uses the `service` command to interace with services.
|
7
|
-
require 'flammarion'
|
8
|
-
require 'colorize'
|
9
|
-
require 'ostruct'
|
10
|
-
|
11
|
-
# First a list of all the services running on the system
|
12
|
-
services = `service --status-all`.split("\n").map{|l| m = l.match(/ \[ (.) \]\s*(\w+)/); o = OpenStruct.new; o.status = m[1]; o.name = m[2]; o }
|
13
|
-
|
14
|
-
# Now create a new engraving to display all this
|
15
|
-
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
16
|
-
|
17
|
-
# Now show everything in a table:
|
18
|
-
f.table(
|
19
|
-
|
20
|
-
# Headers for readability. Flammarion can handle standard ANSI colors just fine.
|
21
|
-
[["Status", "Service"].map{|h|h.light_magenta}] +
|
22
|
-
services.collect do |service|
|
23
|
-
|
24
|
-
# Create buttons which we can embed in the text. When they are clicked, the
|
25
|
-
# blocks will be called.
|
26
|
-
start_button = f.embedded_button("Start") { f.status "Starting #{service.name}"; system("service start #{service.name}"); f.status "Started #{service.name}".green}
|
27
|
-
stop_button = f.embedded_button("Stop") { f.status "Stopping #{service.name}"; system("service stop #{service.name}"); f.status "Stopped #{service.name}".green}
|
28
|
-
[service.status, service.name, start_button, stop_button]
|
29
|
-
end, escape_html:false)
|
30
|
-
|
31
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Service Example
|
4
|
+
#
|
5
|
+
# A simple example that lists the services on the system with buttons to start
|
6
|
+
# and stop them. Uses the `service` command to interace with services.
|
7
|
+
require 'flammarion'
|
8
|
+
require 'colorize'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
# First a list of all the services running on the system
|
12
|
+
services = `service --status-all`.split("\n").map{|l| m = l.match(/ \[ (.) \]\s*(\w+)/); o = OpenStruct.new; o.status = m[1]; o.name = m[2]; o }
|
13
|
+
|
14
|
+
# Now create a new engraving to display all this
|
15
|
+
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
16
|
+
|
17
|
+
# Now show everything in a table:
|
18
|
+
f.table(
|
19
|
+
|
20
|
+
# Headers for readability. Flammarion can handle standard ANSI colors just fine.
|
21
|
+
[["Status", "Service"].map{|h|h.light_magenta}] +
|
22
|
+
services.collect do |service|
|
23
|
+
|
24
|
+
# Create buttons which we can embed in the text. When they are clicked, the
|
25
|
+
# blocks will be called.
|
26
|
+
start_button = f.embedded_button("Start") { f.status "Starting #{service.name}"; system("service start #{service.name}"); f.status "Started #{service.name}".green}
|
27
|
+
stop_button = f.embedded_button("Stop") { f.status "Stopping #{service.name}"; system("service stop #{service.name}"); f.status "Stopped #{service.name}".green}
|
28
|
+
[service.status, service.name, start_button, stop_button]
|
29
|
+
end, escape_html:false)
|
30
|
+
|
31
|
+
f.wait_until_closed
|
data/bin/frake
CHANGED
@@ -1,34 +1,34 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# frake.rb: Wraps a little gui around rake tasks
|
4
|
-
|
5
|
-
require 'flammarion'
|
6
|
-
require 'open3'
|
7
|
-
|
8
|
-
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
9
|
-
f.title "frake #{Dir.pwd}"
|
10
|
-
|
11
|
-
def run(task)
|
12
|
-
f2 = Flammarion::Engraving.new
|
13
|
-
f2.title task
|
14
|
-
f2.puts "Running #{task.light_magenta}"
|
15
|
-
Open3.popen3(task) do |i,o,e,t|
|
16
|
-
Thread.new {e.each_line{|l| f2.print l.red}}
|
17
|
-
o.each_line {|l| f2.print l}
|
18
|
-
f2.status t.value.success? ? "Done!".light_green : "Failed!".light_red
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
f.markdown "# Rake Tasks: "
|
23
|
-
`rake -T`.each_line do |l|
|
24
|
-
f.break
|
25
|
-
parts = l.split("#")
|
26
|
-
task = parts[0]
|
27
|
-
desc = parts[1]
|
28
|
-
f.puts desc
|
29
|
-
f.button(task) do
|
30
|
-
run(task)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# frake.rb: Wraps a little gui around rake tasks
|
4
|
+
|
5
|
+
require 'flammarion'
|
6
|
+
require 'open3'
|
7
|
+
|
8
|
+
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
9
|
+
f.title "frake #{Dir.pwd}"
|
10
|
+
|
11
|
+
def run(task)
|
12
|
+
f2 = Flammarion::Engraving.new
|
13
|
+
f2.title task
|
14
|
+
f2.puts "Running #{task.light_magenta}"
|
15
|
+
Open3.popen3(task) do |i,o,e,t|
|
16
|
+
Thread.new {e.each_line{|l| f2.print l.red}}
|
17
|
+
o.each_line {|l| f2.print l}
|
18
|
+
f2.status t.value.success? ? "Done!".light_green : "Failed!".light_red
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
f.markdown "# Rake Tasks: "
|
23
|
+
`rake -T`.each_line do |l|
|
24
|
+
f.break
|
25
|
+
parts = l.split("#")
|
26
|
+
task = parts[0]
|
27
|
+
desc = parts[1]
|
28
|
+
f.puts desc
|
29
|
+
f.button(task) do
|
30
|
+
run(task)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
f.wait_until_closed
|
data/bin/fwrap
CHANGED
@@ -1,37 +1,37 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# A simple example that will wrap any command into a flammarion window.
|
4
|
-
require 'open3'
|
5
|
-
require 'flammarion'
|
6
|
-
|
7
|
-
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
8
|
-
i, o, e, t = Open3.popen3(*ARGV.to_a)
|
9
|
-
|
10
|
-
f.subpane("out").print("")
|
11
|
-
|
12
|
-
f.subpane("in").input("> ", autoclear:true, history:true) do |msg|
|
13
|
-
i.puts msg['text']
|
14
|
-
end
|
15
|
-
|
16
|
-
f.subpane("in").button("Close (Ctrl+D)") do
|
17
|
-
f.subpane("in").clear
|
18
|
-
i.close
|
19
|
-
t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
|
20
|
-
end
|
21
|
-
|
22
|
-
Thread.new do
|
23
|
-
while l = e.readpartial(4096)
|
24
|
-
f.subpane("out").print l.red
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
begin
|
29
|
-
while l = o.readpartial(4096)
|
30
|
-
f.subpane("out").print l
|
31
|
-
end
|
32
|
-
rescue EOFError
|
33
|
-
f.subpane("in").clear
|
34
|
-
t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
|
35
|
-
end
|
36
|
-
|
37
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# A simple example that will wrap any command into a flammarion window.
|
4
|
+
require 'open3'
|
5
|
+
require 'flammarion'
|
6
|
+
|
7
|
+
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
8
|
+
i, o, e, t = Open3.popen3(*ARGV.to_a)
|
9
|
+
|
10
|
+
f.subpane("out").print("")
|
11
|
+
|
12
|
+
f.subpane("in").input("> ", autoclear:true, history:true) do |msg|
|
13
|
+
i.puts msg['text']
|
14
|
+
end
|
15
|
+
|
16
|
+
f.subpane("in").button("Close (Ctrl+D)") do
|
17
|
+
f.subpane("in").clear
|
18
|
+
i.close
|
19
|
+
t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
|
20
|
+
end
|
21
|
+
|
22
|
+
Thread.new do
|
23
|
+
while l = e.readpartial(4096)
|
24
|
+
f.subpane("out").print l.red
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
begin
|
29
|
+
while l = o.readpartial(4096)
|
30
|
+
f.subpane("out").print l
|
31
|
+
end
|
32
|
+
rescue EOFError
|
33
|
+
f.subpane("in").clear
|
34
|
+
t.value.success? ? f.status("Exit Success".light_green) : f.status("Exit code: #{t.value}".light_red)
|
35
|
+
end
|
36
|
+
|
37
|
+
f.wait_until_closed
|
data/bin/markdown-browser
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
require 'flammarion'
|
3
|
-
|
4
|
-
pwd = Dir.pwd
|
5
|
-
f = Flammarion::Engraving.new(title:pwd)
|
6
|
-
f.orientation = :horizontal
|
7
|
-
f.markdown("Choose a file ->")
|
8
|
-
f.pane("files", weight:0.3)
|
9
|
-
|
10
|
-
(Dir["**/*.md"] + Dir["**/*.markdown"]).each do |file|
|
11
|
-
f.pane("files", weight:0.3).button(file) do
|
12
|
-
f.markdown(File.read(file), replace:true)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
f.wait_until_closed
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'flammarion'
|
3
|
+
|
4
|
+
pwd = Dir.pwd
|
5
|
+
f = Flammarion::Engraving.new(title:pwd)
|
6
|
+
f.orientation = :horizontal
|
7
|
+
f.markdown("Choose a file ->")
|
8
|
+
f.pane("files", weight:0.3)
|
9
|
+
|
10
|
+
(Dir["**/*.md"] + Dir["**/*.markdown"]).each do |file|
|
11
|
+
f.pane("files", weight:0.3).button(file) do
|
12
|
+
f.markdown(File.read(file), replace:true)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
f.wait_until_closed
|
data/bin/repl
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Repl Example
|
4
|
+
#
|
5
|
+
# A simple interactive example for running a repl in flammarion
|
6
|
+
require 'flammarion'
|
7
|
+
|
8
|
+
class FlammarionRepl
|
9
|
+
def initialize
|
10
|
+
@f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
11
|
+
@f.subpane("output")
|
12
|
+
@f.input("> ", autoclear:true, history:true) {|msg| repl(msg['text']) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def repl(str)
|
16
|
+
@f.subpane("output").puts "> #{str}"
|
17
|
+
result =
|
18
|
+
begin
|
19
|
+
eval(str).to_s.green
|
20
|
+
rescue Exception => e
|
21
|
+
"#{e}".red
|
22
|
+
end
|
23
|
+
@f.subpane("output").puts result
|
24
|
+
end
|
25
|
+
|
26
|
+
def puts(str)
|
27
|
+
@f.subpane("output").puts "#{str}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
module Kernel
|
32
|
+
def puts(str)
|
33
|
+
$repl.puts(str)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
if __FILE__ == $0 then
|
38
|
+
$repl = FlammarionRepl.new
|
39
|
+
$repl.wait_until_closed
|
40
|
+
end
|
data/bin/services
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Service Example
|
4
|
+
#
|
5
|
+
# A simple example that lists the services on the system with buttons to start
|
6
|
+
# and stop them. Uses the `service` command to interace with services.
|
7
|
+
require 'flammarion'
|
8
|
+
require 'colorize'
|
9
|
+
require 'ostruct'
|
10
|
+
|
11
|
+
# First a list of all the services running on the system
|
12
|
+
services = `service --status-all`.split("\n").map{|l| m = l.match(/ \[ (.) \]\s*(\w+)/); o = OpenStruct.new; o.status = m[1]; o.name = m[2]; o }
|
13
|
+
|
14
|
+
# Now create a new engraving to display all this
|
15
|
+
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
16
|
+
|
17
|
+
# Now show everything in a table:
|
18
|
+
f.table(
|
19
|
+
|
20
|
+
# Headers for readability. Flammarion can handle standard ANSI colors just fine.
|
21
|
+
[["Status", "Service"].map{|h|h.light_magenta}] +
|
22
|
+
services.collect do |service|
|
23
|
+
|
24
|
+
# Create buttons which we can embed in the text. When they are clicked, the
|
25
|
+
# blocks will be called.
|
26
|
+
start_button = f.embedded_button("Start") { f.status "Starting #{service.name}"; system("service start #{service.name}"); f.status "Started #{service.name}".green}
|
27
|
+
stop_button = f.embedded_button("Stop") { f.status "Stopping #{service.name}"; system("service stop #{service.name}"); f.status "Stopped #{service.name}".green}
|
28
|
+
[service.status, service.name, start_button, stop_button]
|
29
|
+
end, escape_html:false)
|
30
|
+
|
31
|
+
f.wait_until_closed
|