nyaplot_on_web 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/.gitignore +9 -0
- data/Gemfile +4 -0
- data/README.md +48 -0
- data/Rakefile +2 -0
- data/bin/nyaplot_on_web +10 -0
- data/lib/nyaplot/export_to_web.rb +54 -0
- data/lib/nyaplot_on_web/version.rb +3 -0
- data/lib/nyaplot_on_web.rb +5 -0
- data/nyaplot_on_web.gemspec +27 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a99cc83600a49d3b467bfb2dd076e06eefc9be1f
|
4
|
+
data.tar.gz: b39d0a6a8cfb2424c409060d9d64230c84ae060e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 64d61342ecf00133e631d7a99663f2c30e6a2bf715951d30fb600cff1248cdc045fee6fc7abda905d9b53b1e462d2135bc3c4916c8421c943151eb2fc38b552c
|
7
|
+
data.tar.gz: d3ae0dc3ca7e9766ee3352e129bfeeb2537e80380c9325c7423e780cc579aba578ebd89ed996b478051008a905761988dd23ee584e15804925bc44ab953edb3e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# Nyaplot on Web
|
2
|
+
|
3
|
+
Use Nyaplot plotter simply on web browser, without IRuby.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'nyaplot_on_web'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install nyaplot_on_web
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Execute a command `nyaplot_on_web`.
|
24
|
+
|
25
|
+
$ nyaplot_on_web
|
26
|
+
|
27
|
+
`nyaplot_on_web` calls `pry` interactive environments.
|
28
|
+
|
29
|
+
```
|
30
|
+
$ nyaplot_on_web
|
31
|
+
[1] pry(main)> plot = Nyaplot::Plot.new
|
32
|
+
=> #<Nyaplot::Plot:0x007fe972a656e0 @properties={:diagrams=>[], :options=>{}}>
|
33
|
+
[2] pry(main)> bar = plot.add(:bar, ['Persian', 'Maine Coon', 'American Shorthair'], [15,45,30])
|
34
|
+
=> #<Nyaplot::Diagram:0x007fe9749c8c80
|
35
|
+
@properties={:type=>:bar, :options=>{:x=>"data0", :y=>"data1"}, :data=>"d4e88362-e0f4-485c-aece-6eb44abd5404"},
|
36
|
+
@xrange=["Persian", "Maine Coon", "American Shorthair"],
|
37
|
+
@yrange=[0, 45]>
|
38
|
+
[3] pry(main)> plot.show
|
39
|
+
start server on port 28288.
|
40
|
+
=> #<Process::Waiter:0x007fe974a59b90 sleep>
|
41
|
+
[4] pry(main)>
|
42
|
+
shutdown server
|
43
|
+
```
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/takahashim/nyaplot_on_web.
|
48
|
+
|
data/Rakefile
ADDED
data/bin/nyaplot_on_web
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'webrick'
|
2
|
+
require 'tmpdir'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'launchy'
|
5
|
+
require 'nyaplot'
|
6
|
+
|
7
|
+
|
8
|
+
module Nyaplot
|
9
|
+
module ExportToWeb
|
10
|
+
@@server = nil
|
11
|
+
@@web_root = nil
|
12
|
+
|
13
|
+
def show_on_web(port=28288, filename=nil)
|
14
|
+
filename ||= "plot.html"
|
15
|
+
@@web_root ||= Dir.mktmpdir
|
16
|
+
export_html(File.join(@@web_root, filename))
|
17
|
+
|
18
|
+
if !@@server
|
19
|
+
@@server = WEBrick::HTTPServer.new(DocumentRoot: @@web_root,
|
20
|
+
Port: port,
|
21
|
+
ServerType: Thread,
|
22
|
+
Logger: WEBrick::Log.new(File.open(File::NULL, 'w')),
|
23
|
+
AccessLog: [])
|
24
|
+
|
25
|
+
%w(INT TERM).each do |sig|
|
26
|
+
trap(sig) do
|
27
|
+
shutdown_webserver
|
28
|
+
end
|
29
|
+
end
|
30
|
+
@@server.start
|
31
|
+
$stderr.puts "start server on port #{port}."
|
32
|
+
end
|
33
|
+
|
34
|
+
Launchy.open "http://localhost:#{port}/#{filename}"
|
35
|
+
end
|
36
|
+
|
37
|
+
alias_method :show, :show_on_web
|
38
|
+
|
39
|
+
def shutdown_webserver
|
40
|
+
if @@server
|
41
|
+
@@server.shutdown
|
42
|
+
@@server = nil
|
43
|
+
$stderr.puts "shutdown server"
|
44
|
+
end
|
45
|
+
if @@web_root
|
46
|
+
FileUtils.remove_entry_secure @@web_root
|
47
|
+
@@web_root = nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
module_function :shutdown_webserver
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
Nyaplot::Plot.send(:prepend, Nyaplot::ExportToWeb)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'nyaplot_on_web/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "nyaplot_on_web"
|
8
|
+
spec.version = NyaplotOnWeb::VERSION
|
9
|
+
spec.authors = ["takahashim"]
|
10
|
+
spec.email = ["maki@rubycolor.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{Nyaplot exporter to web browser}
|
13
|
+
spec.description = %q{Nyaplot exporter to web browser}
|
14
|
+
spec.homepage = "https://github.com/takahashim/nyaplot_on_web"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency "nyaplot"
|
22
|
+
spec.add_dependency "launchy"
|
23
|
+
spec.add_dependency "pry"
|
24
|
+
|
25
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
26
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
27
|
+
end
|
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nyaplot_on_web
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- takahashim
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nyaplot
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: launchy
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.11'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.11'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
description: Nyaplot exporter to web browser
|
84
|
+
email:
|
85
|
+
- maki@rubycolor.org
|
86
|
+
executables:
|
87
|
+
- nyaplot_on_web
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- Gemfile
|
93
|
+
- README.md
|
94
|
+
- Rakefile
|
95
|
+
- bin/nyaplot_on_web
|
96
|
+
- lib/nyaplot/export_to_web.rb
|
97
|
+
- lib/nyaplot_on_web.rb
|
98
|
+
- lib/nyaplot_on_web/version.rb
|
99
|
+
- nyaplot_on_web.gemspec
|
100
|
+
homepage: https://github.com/takahashim/nyaplot_on_web
|
101
|
+
licenses: []
|
102
|
+
metadata: {}
|
103
|
+
post_install_message:
|
104
|
+
rdoc_options: []
|
105
|
+
require_paths:
|
106
|
+
- lib
|
107
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
requirements: []
|
118
|
+
rubyforge_project:
|
119
|
+
rubygems_version: 2.5.1
|
120
|
+
signing_key:
|
121
|
+
specification_version: 4
|
122
|
+
summary: Nyaplot exporter to web browser
|
123
|
+
test_files: []
|
124
|
+
has_rdoc:
|