├── .gitignore
├── Gemfile
├── LICENCE
├── README.md
├── bin
└── proton
├── build.rb
├── lib
└── proton.rb
├── login.html
├── opal
├── node
│ ├── buffer.rb
│ ├── net.rb
│ ├── readable_stream.rb
│ └── writable_stream.rb
├── proton.rb
├── proton
│ ├── browser_window.rb
│ ├── client_request.rb
│ ├── incoming_message.rb
│ ├── ipc_main.rb
│ ├── ipc_renderer.rb
│ ├── net.rb
│ ├── remote.rb
│ └── web_contents.rb
├── proton_app.rb
├── proton_global.rb
└── proton_process.rb
└── proton.gemspec
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | Gemfile.lock
4 |
5 | *.gem
6 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | source "https://rubygems.org"
3 |
4 | gem "opal"
5 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | Copyright (c) 2016 - Guillaume Hivert
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.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Proton — Ruby Electron — Desktop app using Ruby and Node!
2 |
3 | Ruby Electron is an experimental work. As an open source project, it should provide a full port of [Electron](https://electronjs.org), the perfect web desktop app framework. Some parts are currently working, but everything needs more work. As time is passing, more and more features will be added, and examples will be provided in the future. [They can be found here](https://github.com/ghivert/proton-sample-apps).
4 |
5 | Right now, Proton can be bundled as a gem, but is not purposefully. It is still at a really early stage, and eveything can change or break previous code at any moment. When stable, Proton will be released on RubyGems.
6 |
7 | ## How does it work ?
8 |
9 | Ruby Electron makes its magic with help of Node.js and [Opal](http://opalrb.com). Opal is a transpiler from Ruby to JavaScript. It has few limitations like non mutable string. Otherwise it provides a full transpiler. More details can be found on the page of the project.
10 | Providing Electron to Ruby users, Proton makes extensive use of Electron, by providing a Ruby-like library.
11 |
12 | ## How to compile ?
13 |
14 | ```
15 | git clone https://github.com/ghivert/proton.git
16 | cd proton
17 | gem build proton.gemspec
18 | gem install ./proton-0.1.0.gem
19 | ```
20 |
21 | ## How can I use it ?
22 |
23 | Once you cloned and locally installed the gem, you can simple use `proton main.rb` on a correct file (see the examples or sources). Everything is automated to give the perfect Proton experience !
24 |
25 | ## Remarks ?
26 | ### PR ? Contributing ?
27 | PR are welcome. :) You can else mail me, or come and contribute if you like the project and want to help ! Any help is welcome, even docs !
28 |
29 | ### Tests
30 | "Hey guy, you're not writing tests!" I know. Proton is mainly a POC as for now, and shouldn't be used into production. If the project goes on, Spectron will probably be used.
31 |
32 | ### Issues
33 | Any issues ? Let me know, I'll fix it as soon as I can !
34 |
35 | ## Licence
36 |
37 | MIT Licence. Enjoy the work.
38 |
39 | ## Why ?
40 |
41 | Because it's both fun and useful. Electron rocks. Ruby rocks.
42 |
43 | Ruby + Electron = <3
44 |
45 | ## Support on Beerpay
46 | Hey dude! Help me out for a couple of :beers:!
47 |
48 | [](https://beerpay.io/ghivert/proton) [](https://beerpay.io/ghivert/proton?focus=wish)
49 |
--------------------------------------------------------------------------------
/bin/proton:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'opal'
3 | require 'getoptlong'
4 |
5 | # Parsing class. Ease code reading.
6 |
7 | class CliArgs
8 | @help = <<-HELP
9 | proton [OPTIONS] main.rb
10 | -h, --help: Show help.
11 | -s, --start: Launch electron right after compiling!
12 | -o, --out: Specify file name of output.
13 | HELP
14 |
15 | def self.parse
16 | start = false
17 | output = nil
18 | opts = GetoptLong.new(
19 | [ '--start', '-s', GetoptLong::NO_ARGUMENT ],
20 | [ '--help', '-h', GetoptLong::NO_ARGUMENT ],
21 | [ '--out', '-o', GetoptLong::REQUIRED_ARGUMENT ]
22 | )
23 |
24 | opts.each do |opt, arg|
25 | case opt
26 | when '--help' then puts @help; exit 0
27 | when '--start' then start = true
28 | when '--out' then output = arg
29 | end
30 | end
31 |
32 | if ARGV.length != 1
33 | puts "No file provided. (Call proton --help to see the full list of commands.)"
34 | exit 0
35 | end
36 |
37 | input = ARGV.shift
38 | output = input.gsub(/.rb/, '.js') if output.nil?
39 |
40 | {
41 | input: input,
42 | output: output,
43 | start: start
44 | }
45 | end
46 | end
47 |
48 |
49 | Opal.use_gem 'proton'
50 | Opal.append_path '.'
51 |
52 | options = CliArgs.parse
53 |
54 | requirements = [
55 | 'var electron = require(\'electron\');',
56 | 'var {BrowserWindow, webContents, net} = electron;',
57 | 'var nodeNet = require(\'net\');'
58 | ].join "\n"
59 |
60 | IO.binwrite options[:output], requirements + Opal::Builder.build(options[:input]).to_s
61 | `electron #{options[:output]}` if options[:start]
62 |
--------------------------------------------------------------------------------
/build.rb:
--------------------------------------------------------------------------------
1 | require 'opal'
2 |
3 | Opal.append_path 'lib'
4 | Opal.append_path 'test_app'
5 | File.binwrite "main.js", "var electron = require('electron');\nvar {BrowserWindow, webContents, net} = electron;\n" + Opal::Builder.build('main').to_s
6 |
--------------------------------------------------------------------------------
/lib/proton.rb:
--------------------------------------------------------------------------------
1 | require 'opal'
2 |
3 | Opal.append_path File.expand_path('../../opal', __FILE__).untaint
4 |
--------------------------------------------------------------------------------
/login.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |