woahdae-units 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,22 +2,43 @@
2
2
 
3
3
  This is a package for people who want units with their numbers. For all of the conversions provided in units/standard, please see Numeric.
4
4
 
5
- == Download
5
+ == Install
6
6
 
7
- * http://rubyforge.org/projects/units
8
- * gem install units
9
- * svn co http://rufy.com/svn/units/trunk
7
+ * gem install woahdae-units
10
8
 
11
9
  ==Basic Usage
10
+
12
11
  require 'units/standard'
13
12
  1.lb.to_ounces # => 16.0
14
13
 
14
+ ===Currency (currently broken)
15
+
15
16
  require 'units/currency'
16
17
  1.euro.usd # => 1.2545
17
18
 
18
19
  1.usd.unit # => :usd
19
20
  1.usd.to_yen # => 108.9 # this information is grabbed on the fly via a SOAP call
20
21
  1.usd.to_yet.unit # => :yen
22
+
23
+ ===ActiveRecord
24
+
25
+ The tests are probably the best documentation, but here's some anyways.
26
+
27
+ Every unit-y field has to have the base attribute (ex. quantity) as well as the unit attribute
28
+ (quantity_unit). Then you just do acts_as_unitable :quantity (can take multiple attributes). It will
29
+ then load the unit into your base attribute when accessed via the accessor (ex. item.quantity.unit = :something)
30
+ and set it via the setter (ex. item.quantity = 5.somethings).
31
+
32
+ Also takes a string, so you can say item.quantity = "5 somethings", although I'm thinking of taking that out
33
+ and moving it to a helper.
34
+
35
+ The basics:
36
+
37
+ require 'units/active_record'
38
+
39
+ class Item < ActiveRecord::Base
40
+ acts_as_unitable :quantity
41
+ end
21
42
 
22
43
  ==Comparing Units with Rails' ActiveSupport
23
44
 
@@ -76,4 +97,7 @@ This is a package for people who want units with their numbers. For all of the c
76
97
  * Lucas Carlson (mailto:lucas@rufy.com)
77
98
  * John Butler (mailto:john@likealightbulb.com)
78
99
 
100
+ == Contributors
101
+ * Woody Peterson
102
+
79
103
  This library is released under the terms of the BSD license. See LICENSE for more details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.1.1
@@ -1,6 +1,6 @@
1
1
  module Units
2
2
  module ActiveRecord
3
- def acts_as_units(*methods)
3
+ def acts_as_unitable(*methods)
4
4
  methods.each do |method|
5
5
  define_method(method) do
6
6
  unit_attr = "#{method}_unit".to_sym
@@ -16,7 +16,7 @@ ActiveRecord::Schema.define do
16
16
  end
17
17
 
18
18
  class Item < ActiveRecord::Base
19
- acts_as_units :quantity
19
+ acts_as_unitable :quantity
20
20
  end
21
21
 
22
22
 
@@ -2,20 +2,20 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{units}
5
- s.version = "1.1.0"
5
+ s.version = "1.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Lucas Carlson"]
9
- s.date = %q{2009-07-31}
9
+ s.date = %q{2009-08-02}
10
10
  s.description = %q{A simple way to add units and conversion ability to numbers in Ruby}
11
11
  s.email = %q{lucas@rufy.com}
12
12
  s.extra_rdoc_files = [
13
13
  "LICENSE",
14
- "README"
14
+ "README.rdoc"
15
15
  ]
16
16
  s.files = [
17
17
  "LICENSE",
18
- "README",
18
+ "README.rdoc",
19
19
  "Rakefile",
20
20
  "VERSION",
21
21
  "lib/units.rb",
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: woahdae-units
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Carlson
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-07-31 00:00:00 -07:00
12
+ date: 2009-08-02 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -21,10 +21,10 @@ extensions: []
21
21
 
22
22
  extra_rdoc_files:
23
23
  - LICENSE
24
- - README
24
+ - README.rdoc
25
25
  files:
26
26
  - LICENSE
27
- - README
27
+ - README.rdoc
28
28
  - Rakefile
29
29
  - VERSION
30
30
  - lib/units.rb