flammarion-utils 0.1.10pre
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +147 -0
- data/Readme.md +188 -0
- data/bin/emoji-keyboard +21 -0
- data/bin/engrave +16 -0
- data/bin/flammarion-repl +40 -0
- data/bin/flammarion-services +31 -0
- data/bin/frake +34 -0
- data/bin/fwrap +37 -0
- data/bin/markdown-browser +16 -0
- metadata +78 -0
data/LICENSE
ADDED
@@ -0,0 +1,147 @@
|
|
1
|
+
# Flammarion
|
2
|
+
|
3
|
+
Copyright (c) 2015 Zachary Capalbo
|
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
|
+
|
24
|
+
# External Packages
|
25
|
+
|
26
|
+
Flammarion is bundled with a number of 3rd party packages:
|
27
|
+
|
28
|
+
## Font Awesome
|
29
|
+
|
30
|
+
This software incorporates
|
31
|
+
[Font Awesome by Dave Gandy - http://fontawesome.io](http://fontawesome.io). The
|
32
|
+
fonts in Font Awesome are licensed under the
|
33
|
+
[SIL OFL 1.1](http://scripts.sil.org/OFL). The css files in Font Awesome are
|
34
|
+
licensed under the [MIT License](http://opensource.org/licenses/mit-license.html)
|
35
|
+
|
36
|
+
C.f. https://fortawesome.github.io/Font-Awesome/license/
|
37
|
+
|
38
|
+
## JQuery
|
39
|
+
|
40
|
+
jQuery Foundation projects are released under the terms of the license specified in the project's repository or if not specified, under the [MIT license](https://tldrlegal.com/license/mit-license)
|
41
|
+
|
42
|
+
## Highlight JS
|
43
|
+
|
44
|
+
Copyright (c) 2006, Ivan Sagalaev
|
45
|
+
All rights reserved.
|
46
|
+
Redistribution and use in source and binary forms, with or without
|
47
|
+
modification, are permitted provided that the following conditions are met:
|
48
|
+
|
49
|
+
* Redistributions of source code must retain the above copyright
|
50
|
+
notice, this list of conditions and the following disclaimer.
|
51
|
+
* Redistributions in binary form must reproduce the above copyright
|
52
|
+
notice, this list of conditions and the following disclaimer in the
|
53
|
+
documentation and/or other materials provided with the distribution.
|
54
|
+
* Neither the name of highlight.js nor the names of its contributors
|
55
|
+
may be used to endorse or promote products derived from this software
|
56
|
+
without specific prior written permission.
|
57
|
+
|
58
|
+
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
|
59
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
60
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
61
|
+
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
|
62
|
+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
63
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
64
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
65
|
+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
66
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
67
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
68
|
+
|
69
|
+
## Leaflet
|
70
|
+
|
71
|
+
Copyright (c) 2010-2015, Vladimir Agafonkin
|
72
|
+
Copyright (c) 2010-2011, CloudMade
|
73
|
+
All rights reserved.
|
74
|
+
|
75
|
+
Redistribution and use in source and binary forms, with or without modification, are
|
76
|
+
permitted provided that the following conditions are met:
|
77
|
+
|
78
|
+
1. Redistributions of source code must retain the above copyright notice, this list of
|
79
|
+
conditions and the following disclaimer.
|
80
|
+
|
81
|
+
2. Redistributions in binary form must reproduce the above copyright notice, this list
|
82
|
+
of conditions and the following disclaimer in the documentation and/or other materials
|
83
|
+
provided with the distribution.
|
84
|
+
|
85
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
86
|
+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
87
|
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
88
|
+
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
89
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
90
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
91
|
+
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
92
|
+
TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
93
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
94
|
+
|
95
|
+
## Rubame
|
96
|
+
|
97
|
+
(The MIT License)
|
98
|
+
|
99
|
+
Copyright © 2013 Mark Saward
|
100
|
+
|
101
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the ‘Software’), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
102
|
+
|
103
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
104
|
+
|
105
|
+
THE SOFTWARE IS PROVIDED ‘AS IS’, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
106
|
+
|
107
|
+
## Emojione
|
108
|
+
|
109
|
+
Emoji provided free by [Emoji One](http://emojione.com)
|
110
|
+
|
111
|
+
#### Emoji One Artwork
|
112
|
+
|
113
|
+
* Applies to all PNG and SVG files as well as any adaptations made.
|
114
|
+
* License: Creative Commons Attribution 4.0 International
|
115
|
+
* Human Readable License: http://creativecommons.org/licenses/by/4.0/
|
116
|
+
* Complete Legal Terms: http://creativecommons.org/licenses/by/4.0/legalcode
|
117
|
+
|
118
|
+
|
119
|
+
#### Emoji One Non-Artwork
|
120
|
+
|
121
|
+
* Applies to the Javascript, JSON, PHP, CSS, HTML files, and everything else not covered under the artwork license above.
|
122
|
+
* License: MIT
|
123
|
+
* Complete Legal Terms: http://opensource.org/licenses/MIT
|
124
|
+
|
125
|
+
## Plotly
|
126
|
+
|
127
|
+
The MIT License (MIT)
|
128
|
+
|
129
|
+
Copyright (c) 2016 Plotly, Inc
|
130
|
+
|
131
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
132
|
+
of this software and associated documentation files (the "Software"), to deal
|
133
|
+
in the Software without restriction, including without limitation the rights
|
134
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
135
|
+
copies of the Software, and to permit persons to whom the Software is
|
136
|
+
furnished to do so, subject to the following conditions:
|
137
|
+
|
138
|
+
The above copyright notice and this permission notice shall be included in
|
139
|
+
all copies or substantial portions of the Software.
|
140
|
+
|
141
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
142
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
143
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
144
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
145
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
146
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
147
|
+
THE SOFTWARE.
|
data/Readme.md
ADDED
@@ -0,0 +1,188 @@
|
|
1
|
+
# Flammarion GUI Toolkit
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/flammarion.svg)](https://badge.fury.io/rb/flammarion)
|
4
|
+
|
5
|
+
* [Source](https://github.com/zach-capalbo/flammarion)
|
6
|
+
* [Documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
|
7
|
+
|
8
|
+
## Overview
|
9
|
+
|
10
|
+
Flammarion is an easy-to-use library for displaying information that you might
|
11
|
+
normally display to the command line in a slightly easier-to-access way.
|
12
|
+
|
13
|
+
It is not intended to be a full fledged application development toolkit. It is
|
14
|
+
intended instead for small scripts where you just want to show some information
|
15
|
+
or buttons without going through too much trouble.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
First, you need to install [electron](http://electron.atom.io/) or [chrome](http://www.google.com/chrome)
|
20
|
+
and make sure it's in your path. (*Note:* On Windows, currently only chrome
|
21
|
+
works, but you don't need to worry about putting it in your path.)
|
22
|
+
|
23
|
+
Then you can install the gem:
|
24
|
+
|
25
|
+
```
|
26
|
+
gem install flammarion
|
27
|
+
```
|
28
|
+
|
29
|
+
or add it to your Gemfile.
|
30
|
+
|
31
|
+
## Tutorial
|
32
|
+
|
33
|
+
The easiest way to use Flammarion, is similar to how you might use STDOUT:
|
34
|
+
|
35
|
+
_(Note: these examples are intended to be run from an interactive session such as IRB or [pry](http://pryrepl.org/). If you wish to use them as part of a script, you should use `f.wait_until_closed` at the end, in order to block termination of the script.)_
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
require 'flammarion'
|
39
|
+
f = Flammarion::Engraving.new
|
40
|
+
f.puts "Hello World!"
|
41
|
+
```
|
42
|
+
|
43
|
+
It can even support standard console color codes (Thanks to [ansi_up](http://github.com/drudru/ansi_up)!) and emoji / icons (Thanks to [emojione](http://emojione.com/) and [font awesome](https://fortawesome.github.io/Font-Awesome/))
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
require 'colorized'
|
47
|
+
f.puts "This line will be red!".red
|
48
|
+
f.puts "This #{"word".colorize(:green)} will not be blue."
|
49
|
+
f.puts "This line will have cows :cow: :cow2:", escape_icons: true
|
50
|
+
```
|
51
|
+
|
52
|
+
However, you can also do more advanced things. Say you want to show a table. Easy!
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
f.table(
|
56
|
+
[%w[Number Squared Sqrt].map{|h| h.light_magenta}] + # Make the header a different color
|
57
|
+
10.times.collect{|x| [x, x * x, Math.sqrt(x)]})
|
58
|
+
```
|
59
|
+
|
60
|
+
Now, instead of a table, you decide you want a plot. No problem.
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
x = 10.times.to_a
|
64
|
+
f.plot([{x:x, y:x}, {x: x, y: x.map{|i| i*i}}, {x: x, y: x.map{|i| Math.sqrt(i)}}])
|
65
|
+
```
|
66
|
+
|
67
|
+
Or maybe you want to know where something is:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
f.map("Boston, MA")
|
71
|
+
```
|
72
|
+
|
73
|
+
Maybe you even want to see both of those things *at the same time*!
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
f.pane("numberstuff").table([%w[Number Squared Sqrt].map{|h| h.light_magenta}] +
|
77
|
+
10.times.collect{|x| [x, x * x, Math.sqrt(x)]})
|
78
|
+
f.pane("mapstuff").map("Big Ben")
|
79
|
+
```
|
80
|
+
|
81
|
+
If you need feedback, there's a simple callback mechanism for buttons and text
|
82
|
+
boxes:
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
f.button("Click Here!!!") {f.puts "You clicked the button!"}
|
86
|
+
f.input("Placeholder > ") {|msg| f.puts "You wrote: #{msg['text'].light_magenta}"}
|
87
|
+
```
|
88
|
+
|
89
|
+
The [api documentation](http://zach-capalbo.github.io/flammarion/doc/Flammarion.html)
|
90
|
+
is available at <http://zach-capalbo.github.io/flammarion/doc/Flammarion.html>.
|
91
|
+
|
92
|
+
## Screenshots / Samples
|
93
|
+
|
94
|
+
### Message Composer with Address Book
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
f = Flammarion::Engraving.new
|
98
|
+
f.orientation = :horizontal
|
99
|
+
recipient = f.subpane("number").input("Phone Number")
|
100
|
+
text = f.input("Body", multiline:true)
|
101
|
+
f.button("Send") { send_message(recipient.to_s, text.to_s); f.status("Message Sent!")}
|
102
|
+
f.pane("contacts").puts("Contacts", replace:true)
|
103
|
+
icons = %w[thumbs-up meh-o bicycle gears star-o star cow cat cactus] + [nil] * 5
|
104
|
+
30.times do |i|
|
105
|
+
name = Faker::Name.name
|
106
|
+
f.pane("contacts").button(name, right_icon:icons.sample, left_icon:icons.sample) do
|
107
|
+
recipient = name
|
108
|
+
f.subpane("number").replace(name)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
```
|
112
|
+
|
113
|
+
![Message Sample](http://zach-capalbo.github.io/flammarion/img/messagesample.png)
|
114
|
+
|
115
|
+
### Rake Task Runner
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
f = Flammarion::Engraving.new(exit_on_disconnect:true)
|
119
|
+
f.title "frake #{Dir.pwd}"
|
120
|
+
|
121
|
+
def run(task)
|
122
|
+
f2 = Flammarion::Engraving.new
|
123
|
+
f2.title task
|
124
|
+
f2.puts "Running #{task.light_magenta}"
|
125
|
+
Open3.popen3(task) do |i,o,e,t|
|
126
|
+
Thread.new {e.each_line{|l| f2.print l.red}}
|
127
|
+
o.each_line {|l| f2.print l}
|
128
|
+
f2.status t.value.success? ? "Done!".light_green : "Failed!".light_red
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
f.markdown "# Rake Tasks: "
|
133
|
+
`rake -T`.each_line do |l|
|
134
|
+
f.break
|
135
|
+
parts = l.split("#")
|
136
|
+
task = parts[0]
|
137
|
+
desc = parts[1]
|
138
|
+
f.puts desc
|
139
|
+
f.button(task) do
|
140
|
+
run(task)
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
f.wait_until_closed
|
145
|
+
```
|
146
|
+
|
147
|
+
![Frake](http://zach-capalbo.github.io/flammarion/img/frake.png)
|
148
|
+
|
149
|
+
### Tables
|
150
|
+
|
151
|
+
```ruby
|
152
|
+
f = Flammarion::Engraving.new
|
153
|
+
f.orientation = :horizontal
|
154
|
+
f.table([["Id", "Name", "Address"].map{|h| h.light_magenta}] + 20.times.map do |i|
|
155
|
+
[i, Faker::Name.name, Faker::Address.street_address]
|
156
|
+
end)
|
157
|
+
f.pane("sidebar").pane("side1").puts Faker::Hipster.paragraph.red
|
158
|
+
f.pane("sidebar").pane("side2").puts Faker::Hipster.paragraph.green
|
159
|
+
|
160
|
+
3.times { f.status(Faker::Hipster.sentence.light_green)}
|
161
|
+
```
|
162
|
+
|
163
|
+
![Table Sample](http://zach-capalbo.github.io/flammarion/img/table.png)
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
f = Flammarion::Engraving.new
|
167
|
+
f.plot(5.times.map{|t| {y:100.times.map{rand * t}}})
|
168
|
+
```
|
169
|
+
|
170
|
+
![Plot Sample](http://zach-capalbo.github.io/flammarion/img/plot.png)
|
171
|
+
|
172
|
+
## Examples
|
173
|
+
|
174
|
+
There are a number of useful examples in the [examples directory.](https://github.com/zach-capalbo/flammarion/tree/master/examples)
|
175
|
+
|
176
|
+
# Bundled Packages
|
177
|
+
|
178
|
+
Flammarion is distributed with a bunch of useful tools to make everyone's life easier.
|
179
|
+
They are:
|
180
|
+
|
181
|
+
* [ansi up](https://github.com/drudru/ansi_up)
|
182
|
+
* [highlight.js](https://highlightjs.org/)
|
183
|
+
* [jquery](https://jquery.com/)
|
184
|
+
* [jquery transit](http://ricostacruz.com/jquery.transit/)
|
185
|
+
* [leaflet](http://leafletjs.com/)
|
186
|
+
* [font awesome](https://fortawesome.github.io/Font-Awesome/)
|
187
|
+
* [emojione](http://emojione.com/)
|
188
|
+
* [Plotly](https://plot.ly/)
|
data/bin/emoji-keyboard
ADDED
@@ -0,0 +1,21 @@
|
|
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
|
+
print unicode_char
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
f.wait_until_closed
|
data/bin/engrave
ADDED
@@ -0,0 +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
|
data/bin/flammarion-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
|
@@ -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
|
data/bin/frake
ADDED
@@ -0,0 +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
|
data/bin/fwrap
ADDED
@@ -0,0 +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
|
@@ -0,0 +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
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flammarion-utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.10pre
|
5
|
+
prerelease: 6
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Zach Capalbo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-08-09 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: flammarion
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - '='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.1.10pre
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - '='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.1.10pre
|
30
|
+
description: Extra tools using the Flammarion toolkit.
|
31
|
+
email: zach.geek@gmail.com
|
32
|
+
executables:
|
33
|
+
- fwrap
|
34
|
+
- flammarion-repl
|
35
|
+
- flammarion-services
|
36
|
+
- frake
|
37
|
+
- markdown-browser
|
38
|
+
- engrave
|
39
|
+
- emoji-keyboard
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- LICENSE
|
44
|
+
- Readme.md
|
45
|
+
- bin/fwrap
|
46
|
+
- bin/flammarion-repl
|
47
|
+
- bin/flammarion-services
|
48
|
+
- bin/frake
|
49
|
+
- bin/markdown-browser
|
50
|
+
- bin/engrave
|
51
|
+
- bin/emoji-keyboard
|
52
|
+
homepage: https://github.com/zach-capalbo/flammarion
|
53
|
+
licenses:
|
54
|
+
- MIT
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>'
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.3.1
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.23
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Tools from the Flammarion GUI Toolkit
|
77
|
+
test_files: []
|
78
|
+
has_rdoc:
|