fresh_vector_salad 0.0.1
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 +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +13 -0
- data/Rakefile +2 -0
- data/bin/fresh_vector_salad +131 -0
- data/fresh_vector_salad.gemspec +26 -0
- data/lib/fresh_vector_salad/version.rb +3 -0
- data/lib/fresh_vector_salad.rb +87 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54d64a59bf8a6e9ab5fa08ee375b6367c63645e2
|
4
|
+
data.tar.gz: d36a489c7dfd1024f6352b8d22b5ce3ba464a915
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 30506dee6d666a24ae5ca0df4eb56f7d5705046a0e45dc0214cdd612a5097526c51775e8cb038f671a90ee493c5cee1997c9830d3fd1942e7fb1cb3fd3168638
|
7
|
+
data.tar.gz: b0194a2d9d309eb2b4d6eca1dc6202fd72b466f55c6b712bc09518ed0c039e83581892bc90b24e0b2f078e7a06f59c955ad8d82dcd012dd87519f6026e61e40d
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Simon George
|
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,13 @@
|
|
1
|
+
# FreshVectorSalad
|
2
|
+
|
3
|
+
Display VectorSalad designs live while coding. Uses Tk for a native window.
|
4
|
+
|
5
|
+
See [vector_salad](https://github.com/sfcgeorge/vector_salad) for more information.
|
6
|
+
|
7
|
+
## Contributing
|
8
|
+
|
9
|
+
1. Fork it ( https://github.com/sfcgeorge/fresh_vector_salad/fork )
|
10
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
11
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
12
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
13
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'fresh_vector_salad'
|
4
|
+
require 'optparse'
|
5
|
+
require 'ostruct'
|
6
|
+
require 'tk'
|
7
|
+
require 'tkextlib/tkimg'
|
8
|
+
require 'open3'
|
9
|
+
require 'expect'
|
10
|
+
require 'pty'
|
11
|
+
#require 'listen'
|
12
|
+
|
13
|
+
module FreshVectorSalad
|
14
|
+
class FreshOptparse
|
15
|
+
#
|
16
|
+
# Return a structure describing the options.
|
17
|
+
#
|
18
|
+
def self.parse(args)
|
19
|
+
# The options specified on the command line will be collected in *options*.
|
20
|
+
# We set default values here.
|
21
|
+
options = OpenStruct.new
|
22
|
+
options.verbose = false
|
23
|
+
options.dpi = 90
|
24
|
+
|
25
|
+
opt_parser = OptionParser.new do |opts|
|
26
|
+
opts.banner = "Usage: vrs [options]"
|
27
|
+
|
28
|
+
opts.separator ""
|
29
|
+
opts.separator "Specific options:"
|
30
|
+
|
31
|
+
opts.on('-p', "--path PATH",
|
32
|
+
"PATH to the files.") do |path|
|
33
|
+
#strip trailing slash
|
34
|
+
path = path =~ /\/\z/ ? path[0..-2] : path
|
35
|
+
options.path = path
|
36
|
+
end
|
37
|
+
|
38
|
+
opts.on('-d', "--dpi [DPI]",
|
39
|
+
"Export DPI (default 90). Use to shrink or expand the preview.") do |dpi|
|
40
|
+
options.dpi = dpi
|
41
|
+
end
|
42
|
+
|
43
|
+
opts.on("--crop CROP",
|
44
|
+
"Set width and height manually, format WIDTHxHEIGHT, e.g: 400x600.") do |crop|
|
45
|
+
options.width, options.height = crop.split('x').map(&:to_i)
|
46
|
+
end
|
47
|
+
|
48
|
+
opts.on('-f', "--filename FILENAME",
|
49
|
+
"FILENAME (without extension) to compile from and render to.") do |file|
|
50
|
+
options.file = file
|
51
|
+
end
|
52
|
+
|
53
|
+
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
|
54
|
+
options.verbose = v
|
55
|
+
end
|
56
|
+
|
57
|
+
opts.separator ""
|
58
|
+
opts.separator "Common options:"
|
59
|
+
|
60
|
+
# No argument, shows at tail. This will print an options summary.
|
61
|
+
# Try it and see!
|
62
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
63
|
+
puts opts
|
64
|
+
exit
|
65
|
+
end
|
66
|
+
|
67
|
+
# Another typical switch to print the version.
|
68
|
+
opts.on_tail("--version", "Show version") do
|
69
|
+
puts FreshVectorSalad::VERSION
|
70
|
+
exit
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
opt_parser.parse!(args)
|
75
|
+
options
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
|
80
|
+
class Callbacks
|
81
|
+
def initialize(options, image, label)
|
82
|
+
@options, @image, @label = options, image, label
|
83
|
+
end
|
84
|
+
|
85
|
+
def success
|
86
|
+
@image.file = "#{@options.path}/#{@options.file}.png"
|
87
|
+
@label.height = @image.height + 10
|
88
|
+
@label.width = @image.width + 10
|
89
|
+
@label.background = 'white'
|
90
|
+
@label.pack
|
91
|
+
end
|
92
|
+
|
93
|
+
def error
|
94
|
+
@label.background = 'red'
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
options = FreshVectorSalad::FreshOptparse.parse(ARGV)
|
100
|
+
options.filepath = "#{options.path}/#{options.file}"
|
101
|
+
|
102
|
+
TkRoot.new do
|
103
|
+
title "Fresh Vector Salad"
|
104
|
+
end
|
105
|
+
|
106
|
+
image = TkPhotoImage.new()
|
107
|
+
|
108
|
+
label = TkLabel.new
|
109
|
+
label.image = image
|
110
|
+
|
111
|
+
callbacks = FreshVectorSalad::Callbacks.new(options, image, label)
|
112
|
+
fvs = FreshVectorSalad::Fresh.new(options, callbacks)
|
113
|
+
|
114
|
+
fvs.auto_compile
|
115
|
+
|
116
|
+
#Listen.to(options.path, only: [/\.rb$/], force_polling: true) do |modified, added, removed|
|
117
|
+
#fvs.auto_compile if modified.any?{ |m| m =~ /\.rb$/ }
|
118
|
+
#end.start
|
119
|
+
Thread.new do
|
120
|
+
last = File.stat("#{options.filepath}.rb").mtime
|
121
|
+
while true
|
122
|
+
now = File.stat("#{options.filepath}.rb").mtime
|
123
|
+
if now > last
|
124
|
+
fvs.auto_compile
|
125
|
+
last = now
|
126
|
+
end
|
127
|
+
sleep 0.2
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Tk.mainloop
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'fresh_vector_salad/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "fresh_vector_salad"
|
8
|
+
spec.version = FreshVectorSalad::VERSION
|
9
|
+
spec.authors = ["Simon George"]
|
10
|
+
spec.email = ["simon@sfcgeorge.co.uk"]
|
11
|
+
spec.summary = %q{Fresh View Vector Salad Images}
|
12
|
+
spec.description = %q{Live reloads images generated by Vector Salad}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
#spec.add_dependency "listen", "~> 2.8"
|
22
|
+
spec.add_dependency "vector_salad", "~> 0.0"
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.7"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
require "fresh_vector_salad/version"
|
2
|
+
require 'vector_salad/export_with_magic'
|
3
|
+
require 'ostruct'
|
4
|
+
|
5
|
+
module FreshVectorSalad
|
6
|
+
class Fresh
|
7
|
+
def initialize(options, callbacks)
|
8
|
+
@o = options
|
9
|
+
@callbacks = callbacks
|
10
|
+
end
|
11
|
+
|
12
|
+
def auto
|
13
|
+
auto_compile
|
14
|
+
auto_render
|
15
|
+
end
|
16
|
+
|
17
|
+
def auto_compile
|
18
|
+
puts 'Compiling...'
|
19
|
+
start = Time.now
|
20
|
+
|
21
|
+
#_, _, stderr = start_vector_salad
|
22
|
+
#if e = stderr.gets
|
23
|
+
#puts e
|
24
|
+
#@callbacks.error
|
25
|
+
#else
|
26
|
+
#puts "Compiled in #{Time.now - start} seconds."
|
27
|
+
#auto_render
|
28
|
+
#end
|
29
|
+
|
30
|
+
begin
|
31
|
+
options = OpenStruct.new
|
32
|
+
options.file = "#{@o.path}/#{@o.file}.rb"
|
33
|
+
options.width = @o.width
|
34
|
+
options.height = @o.height
|
35
|
+
o = VectorSalad::ExportWithMagic.new(options).export
|
36
|
+
File.open("#{@o.path}/#{@o.file}.svg", 'w') do |file|
|
37
|
+
file.sync = true
|
38
|
+
file.write(o)
|
39
|
+
file.fsync
|
40
|
+
end
|
41
|
+
File.write("#{@o.path}/#{@o.file}.svg", o)
|
42
|
+
puts "Compiled in #{Time.now - start} seconds."
|
43
|
+
auto_render
|
44
|
+
rescue Exception => e
|
45
|
+
puts e.inspect
|
46
|
+
e.backtrace.each{ |l| puts l }
|
47
|
+
@callbacks.error
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def start_vector_salad
|
52
|
+
vs = "vector_salad -f \"#{@o.path}/#{@o.file}.rb\" > \"#{@o.path}/#{@o.file}.svg\""
|
53
|
+
return Open3.popen3(vs)
|
54
|
+
end
|
55
|
+
|
56
|
+
def auto_render
|
57
|
+
puts 'Rendering...'
|
58
|
+
start = Time.now
|
59
|
+
if @ink_i.nil?
|
60
|
+
puts 'Starting Inkscape'
|
61
|
+
@ink_o, @ink_i, _ = start_inkscape
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
@ink_o.expect(">") do |result|
|
66
|
+
result.each{ |r| puts r }
|
67
|
+
@ink_i.puts("\"#{@o.path}/#{@o.file}.svg\" --export-background=white --export-dpi=#{@o.dpi} --export-png=\"#{@o.path}/#{@o.file}.png\"")
|
68
|
+
end
|
69
|
+
@ink_o.expect("Bitmap saved") do |result|
|
70
|
+
result.each{ |r| puts r }
|
71
|
+
end
|
72
|
+
@callbacks.success
|
73
|
+
puts "Rendered in #{Time.now - start} seconds."
|
74
|
+
rescue Exception => e
|
75
|
+
puts e.inspect
|
76
|
+
e.backtrace.each{ |l| puts l }
|
77
|
+
@callbacks.error
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def start_inkscape
|
82
|
+
ink = "inkscape -z --shell"
|
83
|
+
#Open3.popen3(ink)
|
84
|
+
PTY.spawn(ink)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fresh_vector_salad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Simon George
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-06-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: vector_salad
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.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.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.7'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.7'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: Live reloads images generated by Vector Salad
|
56
|
+
email:
|
57
|
+
- simon@sfcgeorge.co.uk
|
58
|
+
executables:
|
59
|
+
- fresh_vector_salad
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/fresh_vector_salad
|
69
|
+
- fresh_vector_salad.gemspec
|
70
|
+
- lib/fresh_vector_salad.rb
|
71
|
+
- lib/fresh_vector_salad/version.rb
|
72
|
+
homepage: ''
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.5
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: Fresh View Vector Salad Images
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|