analog 0.3 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d51400d28d570348eff96771885c19af401f4cf5
4
- data.tar.gz: 4d7926c87476b2057ae901f7baeb65a6b969bef8
3
+ metadata.gz: a6ecbb065dc457e1c7083a6fb9dccd5009803cc9
4
+ data.tar.gz: 1ae46aeb485d2b1cd55cfca16215461485ea5ee3
5
5
  SHA512:
6
- metadata.gz: 749cb1957e2a5c79b9177cf0d19baeee45fec89abd5d2d60630314d231bb76124e213a8fe9da54475fb39a6e675b84ad653e8dd4f3fed8ef2ee1a3799b7469e9
7
- data.tar.gz: 4b7a657eec352c1b81dbd877aad80585a4a4180c62994c57e38463752cfe85f50da552fa5c7f0a2abedec141e74b20669fb7b2f11ccbac340b25a0ed359bcd6d
6
+ metadata.gz: 584c06d0f46fa1413f2a7388189b0d0eeed82f57e363f042d0abe1711f7847aaf46473c4b97ef765ebb198440cb3f3fb9ea96953bb04d1ecaae8c7f97c928074
7
+ data.tar.gz: 27172f45799a415d540608514248a7d753a20d9064cdd5e040f81a613920ef35846d409ce4f597c7d283a020c178aa0ef654b9c513ce47877a08b3d9f7035ed9
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Ari Russo
1
+ Copyright 2014-2015 Ari Russo
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
data/README.md CHANGED
@@ -6,20 +6,18 @@ A Ruby helper for scaling numbers.
6
6
 
7
7
  Provides a quick way to scale a number from one range or set to another.
8
8
 
9
- This is useful for converting data from raw values to a range used for display or other kinds of output.
10
-
11
- I use it all the time in music programming, converting OSC messages to musical notes and things like that and figure it might be useful to others.
12
-
13
9
  A simple example is:
14
10
 
15
- You want to plot a point on a 500px graph using a data that lies in the 0..1 range.
11
+ You'd like to plot a point on a 500px graph using a data that lies in the 0..1 range.
16
12
 
17
13
  ```ruby
18
- Scale.transform(0.5).using(0..1, 0..500)
14
+ Scale.transform(0.5).from(0..1).to(0..500)
19
15
  => 250
20
16
  ```
21
17
 
22
- Please note: I am not a Math Person. If I've named any concepts here poorly, [please let me know](https://github.com/arirusso/analog/issues). Or [submit a pull request](https://github.com/arirusso/analog/pulls)
18
+ It's commonly useful for preparing data to be consumed by generalized APIs and communication protocols.
19
+
20
+ Personally, I've used it in graphics, audio and for converting music data between OSC and MIDI.
23
21
 
24
22
  #### Usage
25
23
 
@@ -27,21 +25,30 @@ Please note: I am not a Math Person. If I've named any concepts here poorly, [p
27
25
  require "scale"
28
26
  ```
29
27
 
30
- This example will scale a number down by 1/10th`
28
+ This example will scale a number down by 1/10th
31
29
 
32
30
  ```ruby
33
- Scale.transform(22).using(0..150, 0..15)
31
+ Scale.transform(22).from(0..150).to(0..15)
34
32
  => 2
35
33
 
36
34
  ```
37
35
 
38
- You can use Arrays and Sets
36
+ Output a float by using a float in the destination range
37
+
38
+
39
39
  ```ruby
40
- Scale.transform(8).using(Set.new([0, 2, 4, 8, 16, 64]), 0..10)
41
- => 6
40
+ Scale.transform(22).from(0..150).to(0..15.0)
41
+ => 2.2
42
42
 
43
- Scale.transform(0.40).using(0..1, [0, 2, 4, 8, 12, 16, 32, 64, 128, 512])
43
+ ```
44
+
45
+ Use Arrays and Sets
46
+ ```ruby
47
+ Scale.transform(0.40).from(0..1).to([0, 2, 4, 8, 12, 16, 32, 64, 128, 512])
44
48
  => 8
49
+
50
+ Scale.transform(8).from(Set.new([0, 2, 4, 8, 16, 64])).to(0..10)
51
+ => 6
45
52
  ```
46
53
 
47
54
  See the [examples](https://github.com/arirusso/analog/tree/master/examples) for more
@@ -62,7 +69,7 @@ See the [core_ext example](https://github.com/arirusso/analog/blob/master/exampl
62
69
  #### Installation
63
70
 
64
71
  gem install analog
65
-
72
+
66
73
  or with Bundler
67
74
 
68
75
  gem "analog"
@@ -70,5 +77,4 @@ or with Bundler
70
77
  #### License
71
78
 
72
79
  Licensed under Apache 2.0, See the file LICENSE
73
- Copyright (c) 2014 [Ari Russo](http://arirusso.com)
74
-
80
+ Copyright (c) 2014-2014 [Ari Russo](http://arirusso.com)
data/lib/scale.rb CHANGED
@@ -1,11 +1,15 @@
1
- # classes
1
+ # Analog
2
+ # Helper for scaling numbers
3
+ # (c) 2014-2015 Ari Russo
4
+ # Licensed under Apache 2.0
5
+ #
2
6
  require "scale/destination"
3
7
  require "scale/scheme"
4
8
  require "scale/source"
5
9
 
6
- # A Ruby helper for scaling numbers
10
+ # Helper for scaling numbers
7
11
  module Scale
8
12
 
9
- VERSION = "0.3"
13
+ VERSION = "0.4.1"
10
14
 
11
15
  end
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class CoreExtTest < Test::Unit::TestCase
3
+ class CoreExtTest < Minitest::Test
4
4
 
5
5
  context "Numeric" do
6
6
 
@@ -36,7 +36,7 @@ class CoreExtTest < Test::Unit::TestCase
36
36
 
37
37
  should "scale neg/neg into neg/pos" do
38
38
  output = -14.scaled_using(-24..-12, -3..3.0)
39
- assert_equal(2, output)
39
+ assert_equal(2, output)
40
40
  end
41
41
 
42
42
  should "scale neg/neg to another neg/neg" do
@@ -60,7 +60,7 @@ class CoreExtTest < Test::Unit::TestCase
60
60
 
61
61
  should "output a float when specified" do
62
62
  output = 12.scaled_to(0..1.0).from(0..120)
63
- assert_equal(0.10, output)
63
+ assert_equal(0.10, output)
64
64
  end
65
65
 
66
66
  end
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class Scale::DestinationTest < Test::Unit::TestCase
3
+ class Scale::DestinationTest < Minitest::Test
4
4
 
5
5
  context "Destination" do
6
6
 
@@ -26,4 +26,3 @@ class Scale::DestinationTest < Test::Unit::TestCase
26
26
  end
27
27
 
28
28
  end
29
-
data/test/helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  dir = File.dirname(File.expand_path(__FILE__))
2
- $LOAD_PATH.unshift dir + '/../lib'
2
+ $LOAD_PATH.unshift dir + "/../lib"
3
3
 
4
- require 'test/unit'
4
+ require "minitest/autorun"
5
5
  require "mocha/test_unit"
6
6
  require "shoulda-context"
7
7
 
data/test/scale_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class ScaleTest < Test::Unit::TestCase
3
+ class ScaleTest < Minitest::Test
4
4
 
5
5
  context "Scale" do
6
6
 
@@ -28,7 +28,7 @@ class ScaleTest < Test::Unit::TestCase
28
28
 
29
29
  should "scale neg/neg into neg/pos" do
30
30
  output = Scale.transform(-14).using(-24..-12, -3..3.0)
31
- assert_equal(2, output)
31
+ assert_equal(2, output)
32
32
  end
33
33
 
34
34
  should "scale neg/neg to another neg/neg" do
@@ -53,7 +53,7 @@ class ScaleTest < Test::Unit::TestCase
53
53
 
54
54
  should "output a float when specified" do
55
55
  output = Scale.transform(12).using(0..120, 0..1.0)
56
- assert_equal(0.10, output)
56
+ assert_equal(0.10, output)
57
57
  end
58
58
 
59
59
  should "take an ascending array as the destination" do
data/test/scheme_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class Scale::SchemeTest < Test::Unit::TestCase
3
+ class Scale::SchemeTest < Minitest::Test
4
4
 
5
5
  context "Scheme" do
6
6
 
data/test/source_test.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  require "helper"
2
2
 
3
- class Scale::SourceTest < Test::Unit::TestCase
3
+ class Scale::SourceTest < Minitest::Test
4
4
 
5
5
  context "Source" do
6
6
 
metadata CHANGED
@@ -1,58 +1,96 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: analog
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.3'
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ari Russo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-05 00:00:00.000000000 Z
11
+ date: 2015-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: minitest
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.5'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 5.5.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '5.5'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 5.5.0
13
33
  - !ruby/object:Gem::Dependency
14
34
  name: mocha
15
35
  requirement: !ruby/object:Gem::Requirement
16
36
  requirements:
17
37
  - - "~>"
18
38
  - !ruby/object:Gem::Version
19
- version: '0'
39
+ version: '1.1'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 1.1.0
20
43
  type: :development
21
44
  prerelease: false
22
45
  version_requirements: !ruby/object:Gem::Requirement
23
46
  requirements:
24
47
  - - "~>"
25
48
  - !ruby/object:Gem::Version
26
- version: '0'
49
+ version: '1.1'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 1.1.0
27
53
  - !ruby/object:Gem::Dependency
28
54
  name: rake
29
55
  requirement: !ruby/object:Gem::Requirement
30
56
  requirements:
31
57
  - - "~>"
32
58
  - !ruby/object:Gem::Version
33
- version: '0'
59
+ version: '10.4'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 10.4.2
34
63
  type: :development
35
64
  prerelease: false
36
65
  version_requirements: !ruby/object:Gem::Requirement
37
66
  requirements:
38
67
  - - "~>"
39
68
  - !ruby/object:Gem::Version
40
- version: '0'
69
+ version: '10.4'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 10.4.2
41
73
  - !ruby/object:Gem::Dependency
42
74
  name: shoulda-context
43
75
  requirement: !ruby/object:Gem::Requirement
44
76
  requirements:
45
77
  - - "~>"
46
78
  - !ruby/object:Gem::Version
47
- version: '0'
79
+ version: '1.2'
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 1.2.1
48
83
  type: :development
49
84
  prerelease: false
50
85
  version_requirements: !ruby/object:Gem::Requirement
51
86
  requirements:
52
87
  - - "~>"
53
88
  - !ruby/object:Gem::Version
54
- version: '0'
55
- description: Provides a quick way to scale a number from one range or set to another
89
+ version: '1.2'
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: 1.2.1
93
+ description: Scale a number from one range or set to another
56
94
  email:
57
95
  - ari.russo@gmail.com
58
96
  executables: []
@@ -95,7 +133,7 @@ rubyforge_project: analog
95
133
  rubygems_version: 2.2.2
96
134
  signing_key:
97
135
  specification_version: 4
98
- summary: A Ruby helper for scaling numbers
136
+ summary: Helper for scaling numbers
99
137
  test_files:
100
138
  - test/core_ext_test.rb
101
139
  - test/destination_test.rb