invision_support 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +7 -0
- data/invision_support.gemspec +24 -0
- data/lib/invision_support.rb +7 -0
- data/lib/invision_support/filename.rb +26 -0
- data/lib/invision_support/node_name.rb +73 -0
- data/lib/invision_support/path.rb +69 -0
- data/lib/invision_support/version.rb +3 -0
- data/test/lib/invision_support/filename_test.rb +53 -0
- data/test/lib/invision_support/node_name_test.rb +154 -0
- data/test/lib/invision_support/path_test.rb +94 -0
- data/test/test_helper.rb +5 -0
- metadata +105 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e963ce017549ca6962d7486d0657d1b80fbebab7
|
4
|
+
data.tar.gz: 503c935d87c6accfd6f82feee83ff13714ce1eb6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e6ec565b4ec5befa17daa3f5f362953317d80a2a5e1894402ca6a0af84674960fd51f8289113285c53401103cfd97b9f3f99d7a5be9c93b910d5c3d147ee9a00
|
7
|
+
data.tar.gz: 53cd1d305274f42a1250cd08197e0d7fd58ef518d25eb5365057717f6b07958ccde96e9cc9ebc5740e300377bfbafbd9a7e8e9e6efbd07624e2c2a7744643b49
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Sophy Eung
|
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,29 @@
|
|
1
|
+
# InvisionSupport
|
2
|
+
|
3
|
+
Utility library that is used by [sketch.rb](https://github.com/InVisionApp/sketch.rb) and [psd.rb](https://github.com/InVisionApp/psd.rb).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'invision_support'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install invision_support
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'invision_support/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "invision_support"
|
8
|
+
spec.version = InvisionSupport::VERSION
|
9
|
+
spec.authors = ["Sophy Eung"]
|
10
|
+
spec.email = ["ungsophy@gmail.com"]
|
11
|
+
spec.description = "A utility library"
|
12
|
+
spec.summary = "A utility library"
|
13
|
+
spec.homepage = "https://github.com/ungsophy/invision_support"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency 'minitest', '~> 5.2.0'
|
24
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module InvisionSupport
|
2
|
+
module Filename
|
3
|
+
def preview_filename(file_path, output_filename = nil)
|
4
|
+
filename = !output_filename.nil? && !output_filename.empty? ? output_filename : file_path
|
5
|
+
filename = File.basename(filename, File.extname(filename))
|
6
|
+
|
7
|
+
filename_in_png(filename)
|
8
|
+
end
|
9
|
+
|
10
|
+
def filename_in_png(str1, str2 = '', has_at2x = false)
|
11
|
+
str2 = '' if str2.nil?
|
12
|
+
str2 = str2.strip.gsub(/^\& /, '').gsub(/\W/, '-')
|
13
|
+
|
14
|
+
at2x = has_at2x ? '@2x' : ''
|
15
|
+
|
16
|
+
arr = str1.strip.split(' ')
|
17
|
+
arr << str2 unless str2.empty?
|
18
|
+
|
19
|
+
index = arr.size > 1 ? 1 : 0
|
20
|
+
filename = arr.slice(index, arr.size).join('-')
|
21
|
+
filename = File.basename(filename, '.png') if filename =~ /\.png$/
|
22
|
+
|
23
|
+
"#{filename}#{at2x}.png"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module InvisionSupport
|
2
|
+
module NodeName
|
3
|
+
|
4
|
+
include Filename
|
5
|
+
|
6
|
+
GLOBAL = '*'
|
7
|
+
SCREEN = '+'
|
8
|
+
VARIANT = '&'
|
9
|
+
EXCLUDE = '-'
|
10
|
+
|
11
|
+
ASSET_EXTS = %W(.png .jpg .jpeg .gif)
|
12
|
+
|
13
|
+
# Check if a node is an asset node
|
14
|
+
#
|
15
|
+
# Returns boolean
|
16
|
+
def icon?(node_or_str)
|
17
|
+
filename = get_filename(node_or_str)
|
18
|
+
File.extname(filename).downcase == '.ico'
|
19
|
+
end
|
20
|
+
|
21
|
+
# Check if a node is an asset node
|
22
|
+
#
|
23
|
+
# Returns boolean
|
24
|
+
def asset?(node_or_str)
|
25
|
+
filename = get_filename(node_or_str)
|
26
|
+
extname = File.extname(filename).downcase
|
27
|
+
|
28
|
+
ASSET_EXTS.include?(extname)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check if a node is a screen node
|
32
|
+
#
|
33
|
+
# Returns boolean
|
34
|
+
def screen?(node)
|
35
|
+
symbol(node.name).include?(SCREEN) && node.text.nil?
|
36
|
+
rescue NameError
|
37
|
+
symbol(node).include?(SCREEN)
|
38
|
+
end
|
39
|
+
|
40
|
+
# Check if a node is a global node
|
41
|
+
#
|
42
|
+
# Returns boolean
|
43
|
+
def global?(node)
|
44
|
+
symbol(node.name).include?(GLOBAL)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Check if a node is a variant node
|
48
|
+
#
|
49
|
+
# Returns boolean
|
50
|
+
def variant?(node)
|
51
|
+
symbol(node.name).include?(VARIANT)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Check if a node is an exclude node
|
55
|
+
#
|
56
|
+
# Returns boolean
|
57
|
+
def exclude?(node)
|
58
|
+
symbol(node.name).include?(EXCLUDE)
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
def get_filename(node_or_str)
|
64
|
+
node_or_str.name.strip
|
65
|
+
rescue NameError
|
66
|
+
node_or_str
|
67
|
+
end
|
68
|
+
|
69
|
+
def symbol(name)
|
70
|
+
name.strip.split(' ').first
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module InvisionSupport
|
2
|
+
module Path
|
3
|
+
|
4
|
+
include NodeName
|
5
|
+
|
6
|
+
# Example:
|
7
|
+
# root_path: /var/www/output/mail-app
|
8
|
+
# fonts_path: /var/www/output/mail-app/assets/fonts
|
9
|
+
# images_path: /var/www/output/mail-app/assets/images
|
10
|
+
# screens_path: /var/www/output/mail-app/screens
|
11
|
+
# icons_path: /var/www/output/mail-app/icons
|
12
|
+
attr_accessor :root_path, :images_path, :fonts_path, :screens_path, :icons_path,
|
13
|
+
:output_filename
|
14
|
+
|
15
|
+
# Preview image path e.g. /var/www/output/mail-app/screens/mail-app.png
|
16
|
+
#
|
17
|
+
# Returns string
|
18
|
+
def preview_path(file_path, output_filename = nil)
|
19
|
+
filename = preview_filename(file_path, output_filename)
|
20
|
+
File.join(screens_path, filename)
|
21
|
+
end
|
22
|
+
|
23
|
+
# preview image path in zip e.g. screens/mail-app.png
|
24
|
+
#
|
25
|
+
# Returns string
|
26
|
+
def preview_path_in_zip(file_path, output_filename = nil)
|
27
|
+
filename = preview_filename(file_path, output_filename)
|
28
|
+
File.join(screens_path_in_zip, filename)
|
29
|
+
end
|
30
|
+
|
31
|
+
%w(font image screen icon).each do |type|
|
32
|
+
class_eval(<<END_OF_CODE)
|
33
|
+
def #{type}s_path_in_zip
|
34
|
+
raise ArgumentError, 'root_path is empty' unless root_path
|
35
|
+
raise ArgumentError, '#{type}s_path is empty' unless #{type}s_path
|
36
|
+
|
37
|
+
@#{type}s_path_in_zip ||= #{type}s_path.gsub(/^\#\{root_path\}\\//, '')
|
38
|
+
end
|
39
|
+
|
40
|
+
def #{type}_path_in_zip(name1, name2, has_at2x = false)
|
41
|
+
path = file_path_in_zip('#{type}', name1, name2, has_at2x)
|
42
|
+
extnames = path.split('.').last(2)
|
43
|
+
|
44
|
+
if extnames.last == 'png' && asset?("foo.\#\{extnames.first\}")
|
45
|
+
return path.gsub(/\.png$/, '')
|
46
|
+
end
|
47
|
+
|
48
|
+
path
|
49
|
+
end
|
50
|
+
|
51
|
+
def #{type}_path(name1, name2, has_at2x = false)
|
52
|
+
file_path('#{type}', name1, name2, has_at2x)
|
53
|
+
end
|
54
|
+
END_OF_CODE
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def file_path(type, name1, name2, has_at2x = false)
|
60
|
+
filename = filename_in_png(name1, name2, has_at2x)
|
61
|
+
File.join(__send__("#{type}s_path"), filename)
|
62
|
+
end
|
63
|
+
|
64
|
+
def file_path_in_zip(type, name1, name2, has_at2x = false)
|
65
|
+
filename = filename_in_png(name1, name2, has_at2x)
|
66
|
+
File.join(__send__("#{type}s_path_in_zip"), filename)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class Foo
|
4
|
+
include InvisionSupport::Filename
|
5
|
+
end
|
6
|
+
|
7
|
+
describe InvisionSupport::Filename do
|
8
|
+
let(:foo) { Foo.new }
|
9
|
+
|
10
|
+
describe '#preview_filename' do
|
11
|
+
describe 'when output_filename is present' do
|
12
|
+
it 'uses output filename' do
|
13
|
+
foo.preview_filename('123-94757-jkfh89.sketch', 'mail-app.sketch').must_equal 'mail-app.png'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe 'when output_filename is not present' do
|
18
|
+
it 'uses file path' do
|
19
|
+
foo.preview_filename('aaa.sketch', '').must_equal 'aaa.png'
|
20
|
+
foo.preview_filename('aaa.sketch').must_equal 'aaa.png'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#filename_in_png' do
|
26
|
+
describe 'only one name' do
|
27
|
+
it 'returns filename with .png as extension' do
|
28
|
+
foo.filename_in_png('+ inbox').must_equal 'inbox.png'
|
29
|
+
foo.filename_in_png('* inbox').must_equal 'inbox.png'
|
30
|
+
foo.filename_in_png(' + inbox').must_equal 'inbox.png'
|
31
|
+
foo.filename_in_png('+ inbox.png').must_equal 'inbox.png'
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe 'one name with has_at2x' do
|
36
|
+
it 'returns filename with @2x.png' do
|
37
|
+
foo.filename_in_png('+ inbox', '', true).must_equal 'inbox@2x.png'
|
38
|
+
foo.filename_in_png('* inbox', '', true).must_equal 'inbox@2x.png'
|
39
|
+
foo.filename_in_png(' + inbox', '', true).must_equal 'inbox@2x.png'
|
40
|
+
foo.filename_in_png('+ inbox.png', '', true).must_equal 'inbox@2x.png'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe 'two names' do
|
45
|
+
it 'returns the combination of two names' do
|
46
|
+
foo.filename_in_png('+ inbox', '& primary', false).must_equal 'inbox-primary.png'
|
47
|
+
foo.filename_in_png('+ inbox', ' & primary', false).must_equal 'inbox-primary.png'
|
48
|
+
foo.filename_in_png(' + inbox', ' & primary', false).must_equal 'inbox-primary.png'
|
49
|
+
foo.filename_in_png(' + inbox', '& primary', false).must_equal 'inbox-primary.png'
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,154 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
FakeNode = Struct.new(:name, :text)
|
4
|
+
|
5
|
+
class FakeHelper
|
6
|
+
include InvisionSupport::NodeName
|
7
|
+
end
|
8
|
+
|
9
|
+
describe InvisionSupport::NodeName do
|
10
|
+
let(:helper) { FakeHelper.new }
|
11
|
+
|
12
|
+
describe '#filename_in_png' do
|
13
|
+
describe 'only one name' do
|
14
|
+
it 'returns filename with .png as extension' do
|
15
|
+
helper.filename_in_png('+ inbox').must_equal 'inbox.png'
|
16
|
+
helper.filename_in_png('* inbox').must_equal 'inbox.png'
|
17
|
+
helper.filename_in_png(' + inbox').must_equal 'inbox.png'
|
18
|
+
helper.filename_in_png('+ inbox.png').must_equal 'inbox.png'
|
19
|
+
helper.filename_in_png('+ inbox.jpg').must_equal 'inbox.jpg.png'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe 'one name with has_at2x' do
|
24
|
+
it 'returns filename with @2x.png' do
|
25
|
+
helper.filename_in_png('+ inbox', '', true).must_equal 'inbox@2x.png'
|
26
|
+
helper.filename_in_png('* inbox', '', true).must_equal 'inbox@2x.png'
|
27
|
+
helper.filename_in_png(' + inbox', '', true).must_equal 'inbox@2x.png'
|
28
|
+
helper.filename_in_png('+ inbox.png', '', true).must_equal 'inbox@2x.png'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'two names' do
|
33
|
+
it 'returns the combination of two names' do
|
34
|
+
helper.filename_in_png('+ inbox', '& primary', false).must_equal 'inbox-primary.png'
|
35
|
+
helper.filename_in_png('+ inbox', ' & primary', false).must_equal 'inbox-primary.png'
|
36
|
+
helper.filename_in_png(' + inbox', ' & primary', false).must_equal 'inbox-primary.png'
|
37
|
+
helper.filename_in_png(' + inbox', '& primary', false).must_equal 'inbox-primary.png'
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#icon?' do
|
43
|
+
it 'returns true when name has .ico extension' do
|
44
|
+
helper.icon?(FakeNode.new('button.ico')).must_equal true
|
45
|
+
helper.icon?('button.ico').must_equal true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'returns false when name does not has .ico extension' do
|
49
|
+
helper.icon?(FakeNode.new('button')).must_equal false
|
50
|
+
helper.icon?(FakeNode.new('button.ico.jpg')).must_equal false
|
51
|
+
|
52
|
+
helper.icon?('button').must_equal false
|
53
|
+
helper.icon?('button.ico.jpg').must_equal false
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#asset?' do
|
58
|
+
it 'returns true when name has .png, .jpg, .jpeg or .git extension' do
|
59
|
+
helper.asset?(FakeNode.new('button.png')).must_equal true
|
60
|
+
helper.asset?(FakeNode.new('button.jpg')).must_equal true
|
61
|
+
helper.asset?(FakeNode.new('button.jpeg')).must_equal true
|
62
|
+
helper.asset?(FakeNode.new('button.gif')).must_equal true
|
63
|
+
|
64
|
+
helper.asset?('button.png').must_equal true
|
65
|
+
helper.asset?('button.jpg').must_equal true
|
66
|
+
helper.asset?('button.jpeg').must_equal true
|
67
|
+
helper.asset?('button.gif').must_equal true
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'returns false when name does not has .png extension' do
|
71
|
+
helper.asset?(FakeNode.new('button')).must_equal false
|
72
|
+
helper.asset?(FakeNode.new('button.png.ico')).must_equal false
|
73
|
+
helper.asset?(FakeNode.new('button.bmp')).must_equal false
|
74
|
+
|
75
|
+
helper.asset?('button').must_equal false
|
76
|
+
helper.asset?('button.png.ico').must_equal false
|
77
|
+
helper.asset?('button.bmp').must_equal false
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#screen?' do
|
82
|
+
it 'returns true when name has + prefix and node is not text node' do
|
83
|
+
node1 = FakeNode.new('+ inbox')
|
84
|
+
node2 = FakeNode.new(' + inbox')
|
85
|
+
node3 = FakeNode.new(' + inbox')
|
86
|
+
|
87
|
+
helper.screen?(node1).must_equal true
|
88
|
+
helper.screen?(node2).must_equal true
|
89
|
+
helper.screen?(node3).must_equal true
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'returns false when name has no + prefix' do
|
93
|
+
node1 = FakeNode.new('inbox')
|
94
|
+
node2 = FakeNode.new('inbox', {})
|
95
|
+
|
96
|
+
helper.screen?(node1).must_equal false
|
97
|
+
helper.screen?(node2).must_equal false
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns false when name has + prefix, but node is text node' do
|
101
|
+
node = FakeNode.new('+ inbox', {})
|
102
|
+
|
103
|
+
helper.screen?(node).must_equal false
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#global?' do
|
108
|
+
it 'returns true when name has * prefix' do
|
109
|
+
node1 = FakeNode.new('* inbox')
|
110
|
+
node2 = FakeNode.new(' * inbox')
|
111
|
+
node3 = FakeNode.new(' * inbox')
|
112
|
+
|
113
|
+
helper.global?(node1).must_equal true
|
114
|
+
helper.global?(node2).must_equal true
|
115
|
+
helper.global?(node3).must_equal true
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'returns false when name has no * prefix' do
|
119
|
+
node = FakeNode.new('inbox')
|
120
|
+
|
121
|
+
helper.screen?(node).must_equal false
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe '#variant?' do
|
126
|
+
it 'returns true when name has & prefix' do
|
127
|
+
node1 = FakeNode.new('& inbox')
|
128
|
+
node2 = FakeNode.new(' & inbox')
|
129
|
+
node3 = FakeNode.new(' & inbox')
|
130
|
+
|
131
|
+
helper.variant?(node1).must_equal true
|
132
|
+
helper.variant?(node2).must_equal true
|
133
|
+
helper.variant?(node3).must_equal true
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'returns false when name has no * prefix' do
|
137
|
+
node = FakeNode.new('inbox')
|
138
|
+
|
139
|
+
helper.variant?(node).must_equal false
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#exclude?' do
|
144
|
+
it 'returns true when name has & prefix' do
|
145
|
+
node1 = FakeNode.new('- inbox')
|
146
|
+
node2 = FakeNode.new(' - inbox')
|
147
|
+
node3 = FakeNode.new(' - inbox')
|
148
|
+
|
149
|
+
helper.exclude?(node1).must_equal true
|
150
|
+
helper.exclude?(node2).must_equal true
|
151
|
+
helper.exclude?(node3).must_equal true
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require './test/test_helper'
|
2
|
+
|
3
|
+
class Foo
|
4
|
+
include InvisionSupport::Path
|
5
|
+
end
|
6
|
+
|
7
|
+
describe InvisionSupport::Path do
|
8
|
+
def create_foo
|
9
|
+
foo = Foo.new
|
10
|
+
foo.root_path = '/foo'
|
11
|
+
foo.screens_path = '/foo/screens'
|
12
|
+
foo.images_path = '/foo/assets/images'
|
13
|
+
foo.fonts_path = '/foo/assets/fonts'
|
14
|
+
foo.icons_path = '/foo/assets/icons'
|
15
|
+
|
16
|
+
foo
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:foo) { create_foo }
|
20
|
+
|
21
|
+
describe '#screens_path_in_zip' do
|
22
|
+
it 'returns screens path in zip file' do
|
23
|
+
foo.screens_path_in_zip.must_equal 'screens'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#screen_path' do
|
28
|
+
it 'returns screen path' do
|
29
|
+
foo.screen_path('+ inbox', '').must_equal '/foo/screens/inbox.png'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#screen_path_in_zip' do
|
34
|
+
it 'returns screen path in zip' do
|
35
|
+
foo.screen_path_in_zip('+ inbox', '').must_equal 'screens/inbox.png'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#preview_path' do
|
40
|
+
it 'returns preview path' do
|
41
|
+
foo.preview_path('/foo/var/sample.sketch').must_equal '/foo/screens/sample.png'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#preview_path_in_zip' do
|
46
|
+
it 'returns preview path in zip' do
|
47
|
+
foo.preview_path_in_zip('/foo/var/sample.sketch', 'new-sample.sketch').must_equal 'screens/new-sample.png'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#images_path_in_zip' do
|
52
|
+
it 'returns images path in zip file' do
|
53
|
+
foo.images_path_in_zip.must_equal 'assets/images'
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '#image_path' do
|
58
|
+
it 'returns image path' do
|
59
|
+
foo.image_path('button.png', '').must_equal '/foo/assets/images/button.png'
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
describe '#image_path_in_zip' do
|
64
|
+
it 'returns image path in zip' do
|
65
|
+
foo.image_path_in_zip('+ inbox', '').must_equal 'assets/images/inbox.png'
|
66
|
+
foo.image_path_in_zip('inbox.gif.png', '').must_equal 'assets/images/inbox.gif'
|
67
|
+
foo.image_path_in_zip('inbox.jpg.png', '').must_equal 'assets/images/inbox.jpg'
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#fonts_path_in_zip' do
|
72
|
+
it 'returns fonts path in zip file' do
|
73
|
+
foo.fonts_path_in_zip.must_equal 'assets/fonts'
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#icons_path_in_zip' do
|
78
|
+
it 'returns icons path in zip file' do
|
79
|
+
foo.icons_path_in_zip.must_equal 'assets/icons'
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe '#icon_path' do
|
84
|
+
it 'returns icon path' do
|
85
|
+
foo.icon_path('btn.png', '').must_equal '/foo/assets/icons/btn.png'
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#icon_path_in_zip' do
|
90
|
+
it 'returns icon path in zip' do
|
91
|
+
foo.icon_path_in_zip('btn.png', '').must_equal 'assets/icons/btn.png'
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: invision_support
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sophy Eung
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
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: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 5.2.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 5.2.0
|
55
|
+
description: A utility library
|
56
|
+
email:
|
57
|
+
- ungsophy@gmail.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- invision_support.gemspec
|
68
|
+
- lib/invision_support.rb
|
69
|
+
- lib/invision_support/filename.rb
|
70
|
+
- lib/invision_support/node_name.rb
|
71
|
+
- lib/invision_support/path.rb
|
72
|
+
- lib/invision_support/version.rb
|
73
|
+
- test/lib/invision_support/filename_test.rb
|
74
|
+
- test/lib/invision_support/node_name_test.rb
|
75
|
+
- test/lib/invision_support/path_test.rb
|
76
|
+
- test/test_helper.rb
|
77
|
+
homepage: https://github.com/ungsophy/invision_support
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.2.2
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: A utility library
|
101
|
+
test_files:
|
102
|
+
- test/lib/invision_support/filename_test.rb
|
103
|
+
- test/lib/invision_support/node_name_test.rb
|
104
|
+
- test/lib/invision_support/path_test.rb
|
105
|
+
- test/test_helper.rb
|