opal-bootbox 0.1.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/LICENSE.txt +22 -0
- data/README.md +119 -0
- data/gemfile +2 -0
- data/lib/Rakefile +48 -0
- data/lib/opal-bootbox.rb +1 -0
- data/lib/opal/bootbox.rb +38 -0
- data/lib/opal/bootbox/version.rb +5 -0
- data/opal-bootbox.gemspec +20 -0
- metadata +73 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e94c8a226c35e6fc5399538d5ca5eb973462a1d9
|
4
|
+
data.tar.gz: 2589cc1d0833023a5444f3814a84f1d3f2018a28
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: af6abe7bd3a80cff78427098059b049f4397bd891433f1d77ed307e16966214f32a8bfb8093e3073305e4ea35be2286d3efc330374e29ebd3c7fbf57639217fc
|
7
|
+
data.tar.gz: e7b07b2e6eb60c913f982885ea7441aa35b5c1867190c8b51bd5e4b6f6934c08ae2376838521662a7256200b1c56bf98d97a0d23483f2e729e28e77d3259df82
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Colin Gunn
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,119 @@
|
|
1
|
+
## Opal Ruby wrapper of Bootbox Javascript library
|
2
|
+
|
3
|
+
The goal of this project is to wrap the Bootbox Javascript library with Opal, providing a simple Ruby interface to Bootbox functionality.
|
4
|
+
|
5
|
+
Bootbox.js is a small JavaScript library which implements dialog (alert, prompt, confirm) boxes using Bootstrap modals.
|
6
|
+
|
7
|
+
To find out more about Bootbox, go to http://bootboxjs.com.
|
8
|
+
|
9
|
+
To find out more about Opal, go to http://opalrb.org
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Install opal-bootbox from RubyGems:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ gem install opal-bootbox
|
17
|
+
```
|
18
|
+
|
19
|
+
Or include it in your Gemfile for Bundler:
|
20
|
+
|
21
|
+
```
|
22
|
+
ruby
|
23
|
+
gem 'opal-bootbox'
|
24
|
+
```
|
25
|
+
|
26
|
+
## Cloning this repository
|
27
|
+
|
28
|
+
```
|
29
|
+
$ git clone https://github.com/balmoral/opal-bootbox
|
30
|
+
```
|
31
|
+
|
32
|
+
## Getting Started
|
33
|
+
|
34
|
+
### Usage
|
35
|
+
|
36
|
+
`opal-bootbox` can be added to your opal application sources using a standard require:
|
37
|
+
|
38
|
+
```
|
39
|
+
ruby
|
40
|
+
# app/application.rb
|
41
|
+
require 'opal'
|
42
|
+
require 'opal-bootbox'
|
43
|
+
```
|
44
|
+
|
45
|
+
> You need to bring your own `bootbox.js` or `bootbox.min.js` and bootstrap files.
|
46
|
+
>> http://bootboxjs.com/download/
|
47
|
+
>> http://getbootstrap.com/getting-started/#download
|
48
|
+
> and put the files in `app/` or whichever directory you are compiling assets from.
|
49
|
+
|
50
|
+
### Usage
|
51
|
+
|
52
|
+
```
|
53
|
+
$bootbox.alert('Hello world!') do
|
54
|
+
puts 'hello world acknowledged'
|
55
|
+
end
|
56
|
+
|
57
|
+
$bootbox.alert(title: 'Alert dialog', message: 'Hello world!') do
|
58
|
+
puts 'hello world acknowledged'
|
59
|
+
end
|
60
|
+
|
61
|
+
$bootbox.confirm('Are you sure?') do |result|
|
62
|
+
puts "user is #{result ? 'sure' : 'unsure'}"
|
63
|
+
end
|
64
|
+
|
65
|
+
$bootbox.confirm(title: 'Confirmation dialog', message: Are you sure?') do |result|
|
66
|
+
puts "user is #{result ? 'sure' : 'unsure'}"
|
67
|
+
end
|
68
|
+
|
69
|
+
$bootbox.prompt('What is your name?') do |result|
|
70
|
+
if result
|
71
|
+
puts "user's name is '#{result}'"
|
72
|
+
else
|
73
|
+
puts "prompt dismissed"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
$bootbox.prompt(title: 'Prompt dialog', message: 'What is your name?', value: 'default name') do |result|
|
78
|
+
if result
|
79
|
+
puts "user's name is '#{result}'"
|
80
|
+
else
|
81
|
+
puts "prompt dismissed"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
```
|
86
|
+
|
87
|
+
`$bootbox` is a global variable. `Opal::Bootbox` may be substituted.
|
88
|
+
|
89
|
+
Strings (text) provided as arguments to bootbox methods may be HTML format.
|
90
|
+
|
91
|
+
## To do
|
92
|
+
|
93
|
+
* Implement Bootbox custom dialog options.
|
94
|
+
* Documentation
|
95
|
+
* Testing
|
96
|
+
|
97
|
+
## Getting involved
|
98
|
+
|
99
|
+
To contribute to this project, follow the steps below.
|
100
|
+
|
101
|
+
1. Fork the repo ( https://github.com/balmoral/opal-bootbox/fork )
|
102
|
+
2. Create your feature branch (`git checkout -b new-branch`)
|
103
|
+
3. Commit your changes (`git commit -am 'description of commit'`)
|
104
|
+
4. Push to the branch (`git push origin new-branch`)
|
105
|
+
5. Create a Pull Request
|
106
|
+
|
107
|
+
Contributions welcome.
|
108
|
+
|
109
|
+
## Licenses
|
110
|
+
|
111
|
+
### Bootbox
|
112
|
+
Open source (MIT) licence.
|
113
|
+
See https://github.com/makeusabrew/bootbox/blob/master/LICENSE.md for details.
|
114
|
+
|
115
|
+
###opal-bootbox
|
116
|
+
MIT Licence.
|
117
|
+
See LICENSE.txt
|
118
|
+
|
119
|
+
|
data/gemfile
ADDED
data/lib/Rakefile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler.require
|
3
|
+
Bundler::GemHelper.install_tasks
|
4
|
+
|
5
|
+
require 'opal/rspec/rake_task'
|
6
|
+
Opal::RSpec::RakeTask.new(:default) do |s|
|
7
|
+
s.index_path = 'spec/html/index.html.erb'
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Build build/opal-bootbox.js"
|
11
|
+
task :dist do
|
12
|
+
require 'fileutils'
|
13
|
+
FileUtils.mkdir_p 'build'
|
14
|
+
|
15
|
+
src = Opal::Builder.build('opal-bootbox')
|
16
|
+
#min = uglify src
|
17
|
+
#gzp = gzip min
|
18
|
+
|
19
|
+
File.open('build/opal-bootbox.js', 'w+') do |out|
|
20
|
+
out << src
|
21
|
+
end
|
22
|
+
|
23
|
+
#puts "development: #{src.size}, minified: #{min.size}, gzipped: #{gzp.size}"
|
24
|
+
end
|
25
|
+
|
26
|
+
# Used for uglifying source to minify
|
27
|
+
def uglify(str)
|
28
|
+
IO.popen('uglifyjs', 'r+') do |i|
|
29
|
+
i.puts str
|
30
|
+
i.close_write
|
31
|
+
return i.read
|
32
|
+
end
|
33
|
+
rescue Errno::ENOENT
|
34
|
+
$stderr.puts '"uglifyjs" command not found (install with: "npm install -g uglify-js")'
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
# Gzip code to check file size
|
39
|
+
def gzip(str)
|
40
|
+
IO.popen('gzip -f', 'r+') do |i|
|
41
|
+
i.puts str
|
42
|
+
i.close_write
|
43
|
+
return i.read
|
44
|
+
end
|
45
|
+
rescue Errno::ENOENT
|
46
|
+
$stderr.puts '"gzip" command not found, it is required to produce the .gz version'
|
47
|
+
nil
|
48
|
+
end
|
data/lib/opal-bootbox.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'opal/bootbox'
|
data/lib/opal/bootbox.rb
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
module Opal
|
2
|
+
module Bootbox
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def bootbox_call(method, *args, &block)
|
6
|
+
Native.call(`bootbox`, method, *args, &block)
|
7
|
+
end
|
8
|
+
|
9
|
+
# Creates an alert window.
|
10
|
+
# The given block is optional.
|
11
|
+
# No result is passed to the given block.
|
12
|
+
def alert(*args, &block)
|
13
|
+
bootbox_call(__method__, *args, &block)
|
14
|
+
end
|
15
|
+
|
16
|
+
# Creates a confirm window.
|
17
|
+
# The result passed to given block is true or false.
|
18
|
+
def confirm(*args, &block)
|
19
|
+
bootbox_call(__method__, *args, &block)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Creates a prompt window.
|
23
|
+
# The result passed to given block is a String or nil.
|
24
|
+
def prompt(*args, &block)
|
25
|
+
bootbox_call(__method__, *args, &block)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
$bootbox = Opal::Bootbox
|
31
|
+
|
32
|
+
if RUBY_ENGINE == 'opal'
|
33
|
+
else
|
34
|
+
require 'opal'
|
35
|
+
require 'opal/bootbox/version'
|
36
|
+
Opal.append_path File.expand_path('../..', __FILE__).untaint
|
37
|
+
end
|
38
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/opal/bootbox/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'opal-bootbox'
|
6
|
+
spec.version = Opal::Bootbox::VERSION
|
7
|
+
spec.authors = [ 'Colin Gunn' ]
|
8
|
+
spec.email = [ 'colgunn@icloud.com' ]
|
9
|
+
spec.homepage = 'http://github.com/balmoral/opal-bootbox'
|
10
|
+
spec.summary = 'Opal Ruby wrapper for Bootbox Javascript library.'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
|
13
|
+
spec.files = `git ls-files -z`.split("\x0")
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ['lib']
|
17
|
+
|
18
|
+
spec.required_ruby_version = '>= 1.9.3'
|
19
|
+
spec.add_runtime_dependency 'opal', '>= 0.8.0', '< 0.9.0'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opal-bootbox
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Colin Gunn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.0
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.9.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.8.0
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 0.9.0
|
33
|
+
description:
|
34
|
+
email:
|
35
|
+
- colgunn@icloud.com
|
36
|
+
executables: []
|
37
|
+
extensions: []
|
38
|
+
extra_rdoc_files: []
|
39
|
+
files:
|
40
|
+
- LICENSE.txt
|
41
|
+
- README.md
|
42
|
+
- gemfile
|
43
|
+
- lib/Rakefile
|
44
|
+
- lib/opal-bootbox.rb
|
45
|
+
- lib/opal/bootbox.rb
|
46
|
+
- lib/opal/bootbox/version.rb
|
47
|
+
- opal-bootbox.gemspec
|
48
|
+
homepage: http://github.com/balmoral/opal-bootbox
|
49
|
+
licenses:
|
50
|
+
- MIT
|
51
|
+
metadata: {}
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: 1.9.3
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project:
|
68
|
+
rubygems_version: 2.4.6
|
69
|
+
signing_key:
|
70
|
+
specification_version: 4
|
71
|
+
summary: Opal Ruby wrapper for Bootbox Javascript library.
|
72
|
+
test_files: []
|
73
|
+
has_rdoc:
|