Skip to content

Commit 3595a5e

Browse files
committed
Production and pushing gem
1 parent 971520a commit 3595a5e

16 files changed

+219
-170
lines changed

Gemfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
# the following line to use "https"
33
source 'https://rubygems.org'
44

5-
gem "compass", "1.0.0.alpha.17"
6-
gem "sass", "3.3.0.rc.2"
5+
gem "compass", "> 0.12.0"

Gemfile.lock

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,4 @@ PLATFORMS
3232
ruby
3333

3434
DEPENDENCIES
35-
compass (= 1.0.0.alpha.17)
36-
sass (= 3.3.0.rc.2)
35+
compass (> 0.12.0)

bower.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
{
2-
"name": "my-extension",
2+
"name": "modular-scale",
33
"version": "2.0.alpha1",
44
"main": "stylesheets/_modular-scale.scss",
55
"ignore": [
66
"**/.*",
77
"node_modules",
88
"components"
99
]
10-
// "dependencies": {
11-
// "dependency": ">=1.0"
12-
// }
1310
}

changelog.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Version 2.0.0 (unreleased)
2+
3+
This is a breaking version. You will need to refactor slightly in order to upgrade to this version from a pevious version.
4+
5+
* Complete re-write.
6+
* ratios are variables, not functinos
7+
* Common variables are scoped to "ms-"
8+
* ms-lists() is the list functions
9+
* No more mixins at all, only functions.
10+
* Increased compatability with Sass 3.1 and up
11+
* Compatability with LibSass
12+
* Compass no longer required (non-integer values require Compass)

lib/modular-scale.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
# a prerelease version
1717
# Date is in the form of YYYY-MM-DD
1818
module ModularScale
19-
VERSION = "2.0.alpha1"
20-
DATE = "2013-07-23"
19+
VERSION = "2.0.0.alpha1"
20+
DATE = "2013-12-20"
2121
end
2222

2323
# This is where any custom SassScript should be placed. The functions will be

license.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 Scott Kellum, Mason Wendell
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
Modular Scale
23+
Copyright (C) 2013 Scott Kellum, Mason Wendell
24+
25+
This program is free software: you can redistribute it and/or modify
26+
it under the terms of the GNU General Public License as published by
27+
the Free Software Foundation, either version 3 of the License, or
28+
(at your option) any later version.
29+
30+
This program is distributed in the hope that it will be useful,
31+
but WITHOUT ANY WARRANTY; without even the implied warranty of
32+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33+
GNU General Public License for more details.
34+
35+
You should have received a copy of the GNU General Public License
36+
along with this program. If not, see <http://www.gnu.org/licenses/>.

modular-scale.gemspec

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,14 @@ Gem::Specification.new do |s|
2828
# Uncomment those that you use.
2929

3030
# README file
31-
# s.files = ["README.md"]
31+
s.files = ["readme.md"]
3232

3333
# CHANGELOG
34-
# s.files += ["CHANGELOG.md"]
34+
s.files += ["changelog.md"]
35+
36+
s.license = "MIT"
37+
38+
s.files = ["license.md"]
3539

3640
# Library Files
3741
s.files += Dir.glob("lib/**/*.*")
@@ -52,6 +56,5 @@ Gem::Specification.new do |s|
5256
# These are Gem dependencies, not Compass dependencies. Including gems
5357
# here will make sure the relevant gem and version are installed on the
5458
# user's system when installing your gem.
55-
s.add_dependency("sass", [">=3.2.0"])
56-
s.add_dependency("compass", [">= 0.12.1"])
59+
s.add_dependency("compass", [">= 0.12.0"])
5760
end

stylesheets/modular-scale/_cache.scss

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
// An empty cache map
2-
$ms-cache: ();
2+
$MS-cache: ();
33

4-
@function ms-cache($value, $bases, $ratios, $return) {
4+
@function ms-cache($Value, $Bases, $Ratios, $Return) {
55

6-
$ms-new-map: ();
6+
$MS-new-map: ();
77

8-
@if $value >= 0 {
9-
$ms-new-map: (
10-
"#{$bases} #{$ratios}": (
11-
pos: $return,
8+
@if $Value >= 0 {
9+
$MS-new-map: (
10+
"#{$Bases} #{$Ratios}": (
11+
pos: $Return,
1212
),
1313
);
1414
}
1515

16-
@if $value < 0 {
17-
$ms-new-map: (
18-
"#{$bases} #{$ratios}": (
19-
neg: $return,
16+
@if $Value < 0 {
17+
$MS-new-map: (
18+
"#{$Bases} #{$Ratios}": (
19+
neg: $Return,
2020
),
2121
);
2222
}
2323

24-
@return map-merge($ms-cache, $ms-new-map);
24+
@return map-merge($MS-cache, $MS-new-map);
2525
}

stylesheets/modular-scale/_calc.scss

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
@function ms-calc($value, $base: $ms-base, $ratio: $ms-ratio) {
1+
@function ms-calc($Value, $Base: $ms-base, $Ratio: $ms-ratio) {
22

33
// If pow exists use it.
44
// It supports non-interger values!
5-
@if $ms-pow-exists {
5+
@if $MS-pow-exists {
66

77
// The formula for figuring out modular scales is:
88
// (r^v)*b
9-
@return pow($ratio, $value) * $base;
9+
@return pow($Ratio, $Value) * $Base;
1010
}
1111

1212
// If not, use ms-pow().
1313
// Not as fast or capable of non-integer exponents.
1414
@else {
15-
@return ms-pow($ratio, $value) * $base;
15+
@return ms-pow($Ratio, $Value) * $Base;
1616
}
1717
}
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,60 @@
11
// Outputs a list of values instead of a single value
2-
@function ms-list($start: 0, $end: 0, $bases: $ms-base, $ratios: $ms-ratio) {
2+
@function ms-list($Start: 0, $End: 0, $Bases: $ms-base, $Ratios: $ms-ratio) {
33

4-
$positive-return: ();
5-
$negitive-return: ();
6-
$return: ();
4+
$Positive-return: ();
5+
$Negitive-return: ();
6+
$Return: ();
77

8-
@if $end >= 0 {
8+
@if $End >= 0 {
99
// Generate a list of all possible values
10-
$positive-return: ms-generate-list($end, $bases, $ratios);
10+
$Positive-return: ms-generate-list($End, $Bases, $Ratios);
1111

1212
// Sort the generated lists
13-
$positive-return: ms-sort-list($positive-return);
13+
$Positive-return: ms-sort-list($Positive-return);
1414

1515
// Trim list
16-
$trim-list: ();
16+
$Trim-list: ();
1717
// If the starting value is a positive number
1818
// trim the positive return from that
19-
@if $start >= 0 {
20-
@for $i from ($start + 1) through $end + 1 {
21-
$trim-list: join($trim-list, nth($positive-return, $i));
19+
@if $Start >= 0 {
20+
@for $i from ($Start + 1) through $End + 1 {
21+
$Trim-list: join($Trim-list, nth($Positive-return, $i));
2222
}
2323
}
2424
// If not, then include everything up to the end.
2525
@else {
26-
@for $i from 1 through $end + 1 {
27-
$trim-list: join($trim-list, nth($positive-return, $i));
26+
@for $i from 1 through $End + 1 {
27+
$Trim-list: join($Trim-list, nth($Positive-return, $i));
2828
}
2929
}
30-
$positive-return: $trim-list;
30+
$Positive-return: $Trim-list;
3131
}
3232

3333
// Generate a negitive list
34-
@if $start < 0 {
34+
@if $Start < 0 {
3535
// Generate a list of all possible values
36-
$negitive-return: ms-generate-list($start, $bases, $ratios);
36+
$Negitive-return: ms-generate-list($Start, $Bases, $Ratios);
3737

3838
// Sort the generated lists
39-
$negitive-return: ms-sort-list($negitive-return);
39+
$Negitive-return: ms-sort-list($Negitive-return);
4040

4141
// Trim list
42-
$trim-list: ();
43-
@if $end < 0 {
44-
@for $i from abs($end) through abs($start) {
45-
$trim-list: join($trim-list, nth($negitive-return, $i));
42+
$Trim-list: ();
43+
@if $End < 0 {
44+
@for $i from abs($End) through abs($Start) {
45+
$Trim-list: join($Trim-list, nth($Negitive-return, $i));
4646
}
4747
}
4848
@else {
49-
@for $i from 1 through abs($start) {
50-
$trim-list: join($trim-list, nth($negitive-return, $i));
49+
@for $i from 1 through abs($Start) {
50+
$Trim-list: join($Trim-list, nth($Negitive-return, $i));
5151
}
5252
}
53-
$negitive-return: $trim-list;
53+
$Negitive-return: $Trim-list;
5454
}
5555

5656
// Join both positive and negitive possibilities.
57-
$return: join($negitive-return, $positive-return);
57+
$Return: join($Negitive-return, $Positive-return);
5858

59-
@return $return;
59+
@return $Return;
6060
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,62 @@
11
// The main function that brings it all together
2-
@function ms($value: 0, $bases: $ms-base, $ratios: $ms-ratio) {
2+
@function ms($Value: 0, $Bases: $ms-base, $Ratios: $ms-ratio) {
33

44
// If no multi-base or multi-ratio stuff is going on
55
// then just retrn the basic calculaiton
6-
@if length($bases) == 1 and length($ratios) == 1 {
7-
@return ms-calc($value, $bases, $ratios);
6+
@if length($Bases) == 1 and length($Ratios) == 1 {
7+
@return ms-calc($Value, $Bases, $Ratios);
88
}
99

1010
// Use cached values if they exist
11-
@if $ms-maps-exist {
11+
@if $MS-maps-exist {
1212
// Find the map
1313
// it's labeld with the base and ratio values
14-
@if map-get($ms-cache, "#{$bases} #{$ratios}") {
14+
@if map-get($MS-cache, "#{$Bases} #{$Ratios}") {
1515
// Positive list
16-
$ms-pos: map-get(map-get($ms-cache, "#{$bases} #{$ratios}"), pos);
16+
$MS-pos: map-get(map-get($MS-cache, "#{$Bases} #{$Ratios}"), pos);
1717
// See if the map matches the range
18-
@if $value >= 0 and length($ms-pos) > $value {
19-
@return nth($ms-pos, $value + 1);
18+
@if $Value >= 0 and length($MS-pos) > $Value {
19+
@return nth($MS-pos, $Value + 1);
2020
}
2121
// And again for negitive values
22-
$ms-neg: map-get(map-get($ms-cache, "#{$bases} #{$ratios}"), neg);
23-
@if $value < 0 and length($ms-neg) > abs($value - 1) {
24-
@return nth($ms-neg, $value - 1);
22+
$MS-neg: map-get(map-get($MS-cache, "#{$Bases} #{$Ratios}"), neg);
23+
@if $Value < 0 and length($MS-neg) > abs($Value - 1) {
24+
@return nth($MS-neg, $Value - 1);
2525
}
2626
}
2727
// If nothing matched criteria in map
2828
// then just carry on with calculaitons.
2929
}
3030

3131
// Generate a list of all possible values
32-
$return: ms-generate-list($value, $bases, $ratios);
32+
$Return: ms-generate-list($Value, $Bases, $Ratios);
3333

3434
// Sort the generated lists
35-
$return: ms-sort-list($return);
35+
$Return: ms-sort-list($Return);
3636

3737
// Cache
38-
@if $ms-maps-exist {
39-
$ms-cache: ms-cache($value, $bases, $ratios, $return) !global;
38+
@if $MS-maps-exist {
39+
$MS-cache: ms-cache($Value, $Bases, $Ratios, $Return) !global;
4040
}
4141

4242
// Normalize value for counting from 1
4343
// Because CSS counts things from 1
4444
// So Sass does as well
4545
// So I get to write fun stuff like this
46-
@if $value >= 0 {
47-
$value: $value + 1;
46+
@if $Value >= 0 {
47+
$Value: $Value + 1;
4848
}
4949
@else {
50-
$value: $value - 1;
50+
$Value: $Value - 1;
5151
}
5252

5353
// Find the correct value in the list
54-
$return: nth($return, $value);
54+
$Return: nth($Return, $Value);
5555

56-
@return $return;
56+
@return $Return;
5757
}
5858

5959
// Same function, different name, for good measure.
60-
@function modular-scale($value: 0, $bases: $ms-base, $ratios: $ms-ratio) {
61-
@return ms($value, $bases, $ratios);
60+
@function modular-scale($Value: 0, $Bases: $ms-base, $Ratios: $ms-ratio) {
61+
@return ms($Value, $Bases, $Ratios);
6262
}

0 commit comments

Comments
 (0)