torba 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ @mixin border-image($borders...) {
2
+ $webkit-borders: ();
3
+ $spec-borders: ();
4
+
5
+ @each $border in $borders {
6
+ $webkit-border: ();
7
+ $spec-border: ();
8
+ $border-type: type-of($border);
9
+
10
+ @if $border-type == string or list {
11
+ $border-str: if($border-type == list, nth($border, 1), $border);
12
+
13
+ $url-str: str-slice($border-str, 1, 3);
14
+ $gradient-type: str-slice($border-str, 1, 6);
15
+
16
+ @if $url-str == "url" {
17
+ $webkit-border: $border;
18
+ $spec-border: $border;
19
+ }
20
+
21
+ @else if $gradient-type == "linear" {
22
+ $gradients: _linear-gradient-parser("#{$border}");
23
+ $webkit-border: map-get($gradients, webkit-image);
24
+ $spec-border: map-get($gradients, spec-image);
25
+ }
26
+
27
+ @else if $gradient-type == "radial" {
28
+ $gradients: _radial-gradient-parser("#{$border}");
29
+ $webkit-border: map-get($gradients, webkit-image);
30
+ $spec-border: map-get($gradients, spec-image);
31
+ }
32
+
33
+ @else {
34
+ $webkit-border: $border;
35
+ $spec-border: $border;
36
+ }
37
+ }
38
+
39
+ @else {
40
+ $webkit-border: $border;
41
+ $spec-border: $border;
42
+ }
43
+
44
+ $webkit-borders: append($webkit-borders, $webkit-border, comma);
45
+ $spec-borders: append($spec-borders, $spec-border, comma);
46
+ }
47
+
48
+ -webkit-border-image: $webkit-borders;
49
+ border-image: $spec-borders;
50
+ border-style: solid;
51
+ }
52
+
53
+ //Examples:
54
+ // @include border-image(url("image.png"));
55
+ // @include border-image(url("image.png") 20 stretch);
56
+ // @include border-image(linear-gradient(45deg, orange, yellow));
57
+ // @include border-image(linear-gradient(45deg, orange, yellow) stretch);
58
+ // @include border-image(linear-gradient(45deg, orange, yellow) 20 30 40 50 stretch round);
59
+ // @include border-image(radial-gradient(top, cover, orange, yellow, orange));
@@ -0,0 +1,43 @@
1
+ // Used for creating the source string for fonts using @font-face
2
+ // Reference: http://goo.gl/Ru1bKP
3
+
4
+ @function font-url-prefixer($asset-pipeline) {
5
+ @if $asset-pipeline == true {
6
+ @return font-url;
7
+ } @else {
8
+ @return url;
9
+ }
10
+ }
11
+
12
+ @function font-source-declaration(
13
+ $font-family,
14
+ $file-path,
15
+ $asset-pipeline,
16
+ $file-formats,
17
+ $font-url) {
18
+
19
+ $src: ();
20
+
21
+ $formats-map: (
22
+ eot: "#{$file-path}.eot?#iefix" format("embedded-opentype"),
23
+ woff2: "#{$file-path}.woff2" format("woff2"),
24
+ woff: "#{$file-path}.woff" format("woff"),
25
+ ttf: "#{$file-path}.ttf" format("truetype"),
26
+ svg: "#{$file-path}.svg##{$font-family}" format("svg")
27
+ );
28
+
29
+ @each $key, $values in $formats-map {
30
+ @if contains($file-formats, $key) {
31
+ $file-path: nth($values, 1);
32
+ $font-format: nth($values, 2);
33
+
34
+ @if $asset-pipeline == true {
35
+ $src: append($src, font-url($file-path) $font-format, comma);
36
+ } @else {
37
+ $src: append($src, url($file-path) $font-format, comma);
38
+ }
39
+ }
40
+ }
41
+
42
+ @return $src;
43
+ }
@@ -0,0 +1,25 @@
1
+ @mixin retina-image($filename, $background-size, $extension: png, $retina-filename: null, $retina-suffix: _2x, $asset-pipeline: $asset-pipeline) {
2
+ @if $asset-pipeline {
3
+ background-image: image-url("#{$filename}.#{$extension}");
4
+ } @else {
5
+ background-image: url("#{$filename}.#{$extension}");
6
+ }
7
+
8
+ @include hidpi {
9
+ @if $asset-pipeline {
10
+ @if $retina-filename {
11
+ background-image: image-url("#{$retina-filename}.#{$extension}");
12
+ } @else {
13
+ background-image: image-url("#{$filename}#{$retina-suffix}.#{$extension}");
14
+ }
15
+ } @else {
16
+ @if $retina-filename {
17
+ background-image: url("#{$retina-filename}.#{$extension}");
18
+ } @else {
19
+ background-image: url("#{$filename}#{$retina-suffix}.#{$extension}");
20
+ }
21
+ }
22
+
23
+ background-size: $background-size;
24
+ }
25
+ }
@@ -0,0 +1,8 @@
1
+ gh_release "trumbowyg",
2
+ source: "torba-rb/Trumbowyg",
3
+ tag: "1.1.6",
4
+ import: %w[
5
+ dist/trumbowyg.js
6
+ dist/ui/trumbowyg.css
7
+ dist/ui/images/
8
+ ]
@@ -0,0 +1,7 @@
1
+ targz "trumbowyg",
2
+ url: "https://github.com/torba-rb/Trumbowyg/archive/1.1.6.tar.gz",
3
+ import: %w[
4
+ dist/trumbowyg.js
5
+ dist/ui/trumbowyg.css
6
+ dist/ui/images/
7
+ ]
@@ -0,0 +1,7 @@
1
+ zip "trumbowyg",
2
+ url: "https://github.com/torba-rb/Trumbowyg/archive/1.1.6.zip",
3
+ import: %w[
4
+ dist/trumbowyg.js
5
+ dist/ui/trumbowyg.css
6
+ dist/ui/images/
7
+ ]
@@ -0,0 +1 @@
1
+ npm "lo_dash", package: "lodash", version: "0.1.0", import: ["lodash.js"]
@@ -0,0 +1,7 @@
1
+ gh_release "trumbowyg",
2
+ source: "torba-rb/Trumbowyg",
3
+ tag: "1.1.6",
4
+ import: %w[
5
+ dist/ui/trumbowyg.css
6
+ dist/ui/images/icons.png
7
+ ]
@@ -0,0 +1,5 @@
1
+ npm package: 'bourbon', version: '4.2.6', import: %w[
2
+ app/assets/stylesheets/addons/_retina-image.scss
3
+ app/assets/stylesheets/helpers/_font-source-declaration.scss
4
+ app/assets/stylesheets/css3/_border-image.scss
5
+ ]
data/test/package_test.rb CHANGED
@@ -38,5 +38,15 @@ module Torba
38
38
 
39
39
  assert_exists File.join(package.load_path, "package", "hello.css")
40
40
  end
41
+
42
+ def test_package_css_with_urls_pointing_to_nonexisting_assets
43
+ fixture "hello.css", "/*body {\nbackground-image: url(image.png)\n}*/"
44
+ source = Torba::Test::RemoteSource.new(source_dir)
45
+ package = Package.new("package", source, import: ["hello.css"])
46
+
47
+ package.build
48
+
49
+ assert_exists File.join(package.load_path, "package", "hello.css")
50
+ end
41
51
  end
42
52
  end
data/test/test_helper.rb CHANGED
@@ -6,23 +6,34 @@ require "minitest/autorun"
6
6
  require "mocha/mini_test"
7
7
  require "tmpdir"
8
8
  require "fileutils"
9
+ require "open3"
9
10
 
10
11
  module Torba
11
12
  module Test
12
13
  module TempHome
14
+ attr_reader :torba_tmp_dir
15
+
16
+ def self.persistent_tmp_dir
17
+ @persistent_tmp_dir ||= File.realpath(Dir.mktmpdir("torba"))
18
+ end
19
+
13
20
  def before_setup
14
- Torba.home_path = @_torba_tmp_dir = File.realpath(Dir.mktmpdir("torba"))
21
+ Torba.home_path = @torba_tmp_dir = File.realpath(Dir.mktmpdir("torba"))
15
22
  super
16
23
  end
17
24
 
18
25
  def after_teardown
19
- FileUtils.rm_rf(@_torba_tmp_dir)
26
+ FileUtils.rm_rf(torba_tmp_dir)
20
27
  Torba.home_path = nil
21
28
  super
22
29
  end
30
+
31
+ Minitest.after_run do
32
+ FileUtils.rm_rf(persistent_tmp_dir)
33
+ end
23
34
  end
24
35
 
25
- module AssertExists
36
+ module FileSystem
26
37
  def assert_exists(file_path)
27
38
  assert File.exists?(file_path)
28
39
  end
@@ -30,13 +41,64 @@ module Torba
30
41
  def refute_exists(file_path)
31
42
  refute File.exists?(file_path)
32
43
  end
33
- end
34
44
 
35
- module Touch
36
45
  def touch(path)
37
46
  FileUtils.mkdir_p(File.dirname(path))
38
47
  FileUtils.touch(path)
39
48
  end
49
+
50
+ def path_to_packaged(name, home = torba_tmp_dir)
51
+ path = Dir.glob("#{home}/*").grep(Regexp.new(name)).first
52
+ assert path, "Couldn't find packaged #{name.inspect} in #{home.inspect}"
53
+ path
54
+ end
55
+
56
+ def read_without_newline(path)
57
+ content = File.read(path)
58
+ content.strip
59
+ rescue ArgumentError # ignore binary files
60
+ content
61
+ end
62
+
63
+ def compare_dirs(expected, actual)
64
+ expected_paths = Dir.glob("#{expected}/**/*").map{ |path| path.sub(expected, "")}
65
+
66
+ expected_paths.each do |path|
67
+ actual_file = File.join(actual, path)
68
+ assert_exists actual_file
69
+
70
+ unless File.directory?(actual_file)
71
+ expected_file = File.join(expected, path)
72
+ assert_equal read_without_newline(expected_file), read_without_newline(actual_file), "#{expected_file.inspect} should be equal to #{actual_file.inspect}"
73
+ end
74
+ end
75
+
76
+ actual_paths = Dir.glob("#{actual}/**/*").map{ |path| path.sub(actual, "")}
77
+
78
+ paths_diff = actual_paths - expected_paths
79
+ assert_empty paths_diff, "#{expected.inspect} contains extra paths #{paths_diff.inspect}"
80
+ end
81
+ end
82
+
83
+ module Exec
84
+ def torba(torba_cmd, options = {})
85
+ env = {"TORBA_HOME_PATH" => torba_tmp_dir, "TORBA_CACHE_PATH" => TempHome.persistent_tmp_dir}
86
+
87
+ if (torbafile = options[:torbafile])
88
+ env.merge!("TORBA_FILE" => "test/fixtures/torbafiles/#{torbafile}")
89
+ end
90
+
91
+ if (home_path = options[:home_path])
92
+ env.merge!("TORBA_HOME_PATH" => home_path)
93
+ end
94
+
95
+ if (cache_path = options[:cache_path])
96
+ env.merge!("TORBA_CACHE_PATH" => cache_path)
97
+ end
98
+
99
+ cmd = "ruby bin/torba #{torba_cmd}"
100
+ Open3.capture3(env, cmd)
101
+ end
40
102
  end
41
103
 
42
104
  class RemoteSource
@@ -57,6 +119,5 @@ end
57
119
 
58
120
  class Minitest::Test
59
121
  include Torba::Test::TempHome
60
- include Torba::Test::AssertExists
61
- include Torba::Test::Touch
122
+ include Torba::Test::FileSystem
62
123
  end
@@ -0,0 +1,13 @@
1
+ require "test_helper"
2
+
3
+ class TorbaTest < Minitest::Test
4
+ def test_home_path
5
+ Torba.home_path = "/new/home/path"
6
+ assert_equal "/new/home/path", Torba.home_path
7
+ end
8
+
9
+ def test_cache_path
10
+ Torba.cache_path = "/new/cache/path"
11
+ assert_equal "/new/cache/path", Torba.cache_path
12
+ end
13
+ end
data/torba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "torba"
3
- spec.version = "0.5.1"
3
+ spec.version = "0.6.0"
4
4
  spec.authors = ["Andrii Malyshko"]
5
5
  spec.email = ["mail@nashbridges.me"]
6
6
  spec.description = "Bundler for Sprockets"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: torba
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrii Malyshko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-09 00:00:00.000000000 Z
11
+ date: 2016-03-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -116,6 +116,20 @@ files:
116
116
  - lib/torba/verify.rb
117
117
  - test/acceptance_test.rb
118
118
  - test/css_url_to_erb_asset_path_test.rb
119
+ - test/fixtures/home_path/01/trumbowyg/icons-2x.png
120
+ - test/fixtures/home_path/01/trumbowyg/icons.png
121
+ - test/fixtures/home_path/01/trumbowyg/trumbowyg.css.erb
122
+ - test/fixtures/home_path/01/trumbowyg/trumbowyg.js
123
+ - test/fixtures/home_path/02/lo_dash/lodash.js
124
+ - test/fixtures/home_path/04/bourbon/_border-image.scss
125
+ - test/fixtures/home_path/04/bourbon/_font-source-declaration.scss
126
+ - test/fixtures/home_path/04/bourbon/_retina-image.scss
127
+ - test/fixtures/torbafiles/01_gh_release.rb
128
+ - test/fixtures/torbafiles/01_targz.rb
129
+ - test/fixtures/torbafiles/01_zip.rb
130
+ - test/fixtures/torbafiles/02_npm.rb
131
+ - test/fixtures/torbafiles/03_image_asset_not_specified.rb
132
+ - test/fixtures/torbafiles/04_not_existed_assets.rb
119
133
  - test/import_list_test.rb
120
134
  - test/manifest_test.rb
121
135
  - test/package/import_list_test.rb
@@ -129,6 +143,7 @@ files:
129
143
  - test/remote_sources/targz_test.rb
130
144
  - test/remote_sources/zip_test.rb
131
145
  - test/test_helper.rb
146
+ - test/torba_test.rb
132
147
  - torba.gemspec
133
148
  homepage: https://github.com/torba-rb/torba
134
149
  licenses:
@@ -157,6 +172,20 @@ summary: Bundler for Sprockets
157
172
  test_files:
158
173
  - test/acceptance_test.rb
159
174
  - test/css_url_to_erb_asset_path_test.rb
175
+ - test/fixtures/home_path/01/trumbowyg/icons-2x.png
176
+ - test/fixtures/home_path/01/trumbowyg/icons.png
177
+ - test/fixtures/home_path/01/trumbowyg/trumbowyg.css.erb
178
+ - test/fixtures/home_path/01/trumbowyg/trumbowyg.js
179
+ - test/fixtures/home_path/02/lo_dash/lodash.js
180
+ - test/fixtures/home_path/04/bourbon/_border-image.scss
181
+ - test/fixtures/home_path/04/bourbon/_font-source-declaration.scss
182
+ - test/fixtures/home_path/04/bourbon/_retina-image.scss
183
+ - test/fixtures/torbafiles/01_gh_release.rb
184
+ - test/fixtures/torbafiles/01_targz.rb
185
+ - test/fixtures/torbafiles/01_zip.rb
186
+ - test/fixtures/torbafiles/02_npm.rb
187
+ - test/fixtures/torbafiles/03_image_asset_not_specified.rb
188
+ - test/fixtures/torbafiles/04_not_existed_assets.rb
160
189
  - test/import_list_test.rb
161
190
  - test/manifest_test.rb
162
191
  - test/package/import_list_test.rb
@@ -170,4 +199,5 @@ test_files:
170
199
  - test/remote_sources/targz_test.rb
171
200
  - test/remote_sources/zip_test.rb
172
201
  - test/test_helper.rb
202
+ - test/torba_test.rb
173
203
  has_rdoc: