sassc-image-size 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/README.md +44 -0
- data/Rakefile +3 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/sassc/image/size.rb +23 -0
- data/sassc-image-size.gemspec +22 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 76d9ad208255608b1497c3afa0764231f9407865
|
4
|
+
data.tar.gz: 97dcb73e62f8b72813152df67912fb216814f2c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 78d706cc43b6cb377d972e422735da599f0dbf284521a28f3d8bcc0501607031ba7363c6595f0315bf5432c0977a07c0d4b344e26ec058f775d4c68c6b373de2
|
7
|
+
data.tar.gz: 9ffdae3ace5a505024a4b5d19d9a609e6084f0ca2da099e33fc72ed9c9e857c40becbdf219bd502e8fd44599aa2daf7dd498b170509a1c06f912eb01557f118f
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Sassc::Image::Size
|
2
|
+
|
3
|
+
alternative version of [rails-sass-images.gem](https://github.com/ai/rails-sass-images). but, for [sassc-rails.gem](https://github.com/sass/sassc-rails).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'sassc-image-size'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sassc-image-size
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
```scss
|
24
|
+
.foo-image {
|
25
|
+
$foo-image-size: image-size('foo.png');
|
26
|
+
width: map-get($foo-image-size, width);
|
27
|
+
height: map-get($foo-image-size, height);
|
28
|
+
}
|
29
|
+
|
30
|
+
.bar-image {
|
31
|
+
width: image-width('bar.png');
|
32
|
+
height: image-height('bar.png');
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
## Development
|
37
|
+
|
38
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
39
|
+
|
40
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
41
|
+
|
42
|
+
## Contributing
|
43
|
+
|
44
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/sassc-image-size.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "sassc/image/size"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'sassc/script/functions'
|
2
|
+
require 'dimensions'
|
3
|
+
require 'sass/script/value/map'
|
4
|
+
|
5
|
+
module SassC
|
6
|
+
module Script
|
7
|
+
module Functions
|
8
|
+
def image_size(path)
|
9
|
+
dimensions = Dimensions.dimensions(sprockets_context.depend_on_asset(path.value).filename)
|
10
|
+
Sass::Script::Value::Map.new(Sass::Script::Value::String.new('width') => Sass::Script::Value::Number.new(dimensions[0], ['px']),
|
11
|
+
Sass::Script::Value::String.new('height') => Sass::Script::Value::Number.new(dimensions[1], ['px']))
|
12
|
+
end
|
13
|
+
|
14
|
+
def image_width(path)
|
15
|
+
Sass::Script::Value::Number.new(Dimensions.width(sprockets_context.depend_on_asset(path.value).filename), ['px'])
|
16
|
+
end
|
17
|
+
|
18
|
+
def image_height(path)
|
19
|
+
Sass::Script::Value::Number.new(Dimensions.height(sprockets_context.depend_on_asset(path.value).filename), ['px'])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "sassc-image-size"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["miyucy"]
|
9
|
+
spec.email = ["fistfvck@gmail.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{image-(size|width|height) function for sassc}
|
12
|
+
spec.description = %q{image-(size|width|height) function for sassc}
|
13
|
+
spec.homepage = "https://github.com/miyucy/sassc-image-size"
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.bindir = "exe"
|
17
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "dimensions"
|
21
|
+
spec.add_dependency "sassc-rails"
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sassc-image-size
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- miyucy
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dimensions
|
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: sassc-rails
|
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
|
+
description: image-(size|width|height) function for sassc
|
42
|
+
email:
|
43
|
+
- fistfvck@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- ".rspec"
|
50
|
+
- ".travis.yml"
|
51
|
+
- Gemfile
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- lib/sassc/image/size.rb
|
57
|
+
- sassc-image-size.gemspec
|
58
|
+
homepage: https://github.com/miyucy/sassc-image-size
|
59
|
+
licenses: []
|
60
|
+
metadata: {}
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options: []
|
63
|
+
require_paths:
|
64
|
+
- lib
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project:
|
77
|
+
rubygems_version: 2.5.1
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: image-(size|width|height) function for sassc
|
81
|
+
test_files: []
|