webview_ruby 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 80bb60c95ce40f4a3a997c1d7a06da58ad56416d3c132efe49c5204b4b0eb4bf
4
+ data.tar.gz: 3998804646c9aa5cdec05a4787ed127ab640445ba8f5df2e01641a9360db8c32
5
+ SHA512:
6
+ metadata.gz: 345a74af70e29b384456590b46e6fa76d5312137fc922d55185743857aa4fb2bb8abc4f625cf60670c0b0c880dfe1503ac829d23c411352f2c91d0730d8a1efc
7
+ data.tar.gz: bb0c0d3c96aa21f8c3366be008bbde70c1085d26594f80548f0248cbf25b784b924a7b1fc6cadf3b9fef38b2d50d1eb3222fb16fe74034189a1ac4cc95cc0c0c
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-02-09
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at TODO: Write your email address. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in webview_ruby.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ webview_ruby (0.1.0)
5
+ ffi
6
+ ffi-compiler
7
+ rake
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ ffi (1.15.5)
14
+ ffi-compiler (1.0.1)
15
+ ffi (>= 1.0.0)
16
+ rake
17
+ minitest (5.15.0)
18
+ parallel (1.21.0)
19
+ parser (3.1.0.0)
20
+ ast (~> 2.4.1)
21
+ rainbow (3.1.1)
22
+ rake (13.0.6)
23
+ regexp_parser (2.2.0)
24
+ rexml (3.2.5)
25
+ rubocop (1.25.1)
26
+ parallel (~> 1.10)
27
+ parser (>= 3.1.0.0)
28
+ rainbow (>= 2.2.2, < 4.0)
29
+ regexp_parser (>= 1.8, < 3.0)
30
+ rexml
31
+ rubocop-ast (>= 1.15.1, < 2.0)
32
+ ruby-progressbar (~> 1.7)
33
+ unicode-display_width (>= 1.4.0, < 3.0)
34
+ rubocop-ast (1.15.1)
35
+ parser (>= 3.0.1.1)
36
+ ruby-progressbar (1.11.0)
37
+ unicode-display_width (2.1.0)
38
+
39
+ PLATFORMS
40
+ arm64-darwin-20
41
+ arm64-darwin-21
42
+
43
+ DEPENDENCIES
44
+ minitest (~> 5.0)
45
+ rake (~> 13.0)
46
+ rubocop (~> 1.21)
47
+ webview_ruby!
48
+
49
+ BUNDLED WITH
50
+ 2.3.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 TODO: Write your name
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.
data/README.md ADDED
@@ -0,0 +1,108 @@
1
+ # WebviewRuby
2
+
3
+ WebViewRuby is a library that provide bindings for [webview/webview](https://github.com/webview/webview) a tiny tiny cross-platform webview library to build modern cross-platform GUIs. Webview uses Cocoa/WebKit on macOS, gtk-webkit2 on Linux and Edge on Windows 10.
4
+
5
+ IMPORTANT: Compilation may not work on windows and linux right now. Follow the progress [here](https://github.com/Maaarcocr/webview_ruby/issues/1)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'webview_ruby'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install webview_ruby
22
+
23
+ ## Usage
24
+
25
+ ### Hello World
26
+
27
+ Create a new Webview instance
28
+
29
+ ```ruby
30
+ webview = WebviewRuby::Webview.new
31
+ ```
32
+
33
+ Set the size and the title of the window
34
+
35
+ ```ruby
36
+ webview.set_title("Example")
37
+ webview.set_size(480, 360)
38
+ ```
39
+
40
+ Navigate to a specific webpage
41
+
42
+ ```ruby
43
+ webview.navigate("https://en.m.wikipedia.org/wiki/Main_Page")
44
+ ```
45
+
46
+ Then run the main loop till its terminated (remember to always destroy the webview after it stops running)
47
+
48
+ ```ruby
49
+ webview.run
50
+ webview.destroy
51
+ ```
52
+
53
+ ### Run ruby code from JS
54
+
55
+ You can bind a ruby function to a JavaScript one before the webview is in running state. To do so use the `bind` method like:
56
+
57
+ ```ruby
58
+ webview.bind("exampleFunc") do
59
+ print("got called by js")
60
+ end
61
+ ```
62
+
63
+ Now you can use `exampleFunc` as any other JS function, you can call it from the javascript that has been loaded in the webview or
64
+ from the html. If you want to make a function take some parameters, just add parameters to the `do` block like so:
65
+
66
+ ```ruby
67
+ webview.bind("exampleFunc") do |arg1, arg2|
68
+ print("got called by js with #{arg1} and #{arg2}")
69
+ end
70
+ ```
71
+
72
+ You can only use positional arguments, keyword ones wouldn't work.
73
+
74
+ ### Run JS code from ruby
75
+
76
+ You can invoke JS code to be run asynchrounously (the result of the execution won't be returned to you) by running
77
+
78
+ ```ruby
79
+ webview.eval("console.log('Called from ruby')")
80
+ ```
81
+
82
+ ### Terminate the main loop
83
+
84
+ ```
85
+ webview.terminate
86
+ ```
87
+
88
+ ### Run JS code at initialisation
89
+
90
+ If you want to inject JavaScript code at the initialization of the new page, such that every time the webview will open a the new page - this initialization code will be executed, then you can use
91
+
92
+ ```ruby
93
+ webview.init("console.log('running at initialisation')")
94
+ ```
95
+
96
+ It is guaranteed that code is executed before window.onload.
97
+
98
+ ## Contributing
99
+
100
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Maaarcocr/webview_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/webview_ruby/blob/master/CODE_OF_CONDUCT.md).
101
+
102
+ ## License
103
+
104
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
105
+
106
+ ## Code of Conduct
107
+
108
+ Everyone interacting in the WebviewRuby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/webview_ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require 'ffi-compiler/compile_task'
6
+
7
+ task :compile do
8
+ FFI::Compiler::CompileTask.new('webview-ext') do |c|
9
+ c.cxxflags << "-std=c++11"
10
+ c.ldflags << "-framework WebKit"
11
+ end
12
+ end
13
+
14
+
15
+ Rake::TestTask.new(:test) do |t|
16
+ t.libs << "test"
17
+ t.libs << "lib"
18
+ t.test_files = FileList["test/**/test_*.rb"]
19
+ end
20
+
21
+ task :test => :compile
22
+
23
+ require "rubocop/rake_task"
24
+
25
+ RuboCop::RakeTask.new
26
+
27
+ task default: %i[test rubocop]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "webview_ruby"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/ext/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'ffi-compiler/compile_task'
2
+
3
+ FFI::Compiler::CompileTask.new('webview-ext') do |c|
4
+ c.cxxflags << "-std=c++11"
5
+ c.ldflags << "-framework WebKit"
6
+ end
@@ -0,0 +1 @@
1
+ #include "webview.h"