seamusabshere-conversions 1.2 → 1.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -1,15 +1,32 @@
1
- Conversions
2
- -----------
1
+ = Conversions
3
2
 
4
- A plugin to convert units.
3
+ The conversions plugin does a number of things. The core functionality is the unit conversion:
5
4
 
6
- Installation
7
- -----------
5
+ 1.miles.to(:kilometres) #=> 1.609344
6
+ 1.pounds.to(:kilograms) #=> 0.453592
8
7
 
9
- As a GemPlugin:
8
+ It also adds a class method to ActiveRecord::Base that allows you to define conversion methods for attributes:
10
9
 
11
- config.gem 'Fingertips-conversions', :lib => 'conversions', :source => 'http://gems.github.com'
10
+ class Car < ActiveRecord::Base
11
+ conversion_accessor :weight, :internal => :kilograms, :external => :pounds
12
+ end
12
13
 
13
- As a normal plugin:
14
+ car = Car.new(:weight => 1500)
15
+ car.weight_in_pounds #=> 3306.93393
14
16
 
15
- script/install plugin git://github.com/Fingertips/conversions.git
17
+
18
+ == Installation
19
+
20
+ === As a gem
21
+
22
+ Configure the gem in environment.rb:
23
+
24
+ config.gem 'Fingertips-conversions', :lib => 'conversions', :source => 'http://gems.github.com'
25
+
26
+ Install them using Rails' rake task:
27
+
28
+ $ rake gems:install
29
+
30
+ === In your vendor directory:
31
+
32
+ script/install plugin git://github.com/Fingertips/conversions.git
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- require 'rake'
2
1
  require 'rake/testtask'
3
2
  require 'rake/rdoctask'
4
3
 
@@ -12,11 +11,24 @@ Rake::TestTask.new(:test) do |t|
12
11
  t.verbose = true
13
12
  end
14
13
 
15
- desc 'Generate documentation for conversions plugin.'
16
- Rake::RDocTask.new(:rdoc) do |rdoc|
17
- rdoc.rdoc_dir = 'rdoc'
18
- rdoc.title = 'Conversions'
19
- rdoc.options << '--line-numbers' << '--inline-source' << '--charset' << 'utf-8'
20
- rdoc.rdoc_files.include('README')
21
- rdoc.rdoc_files.include('lib/**/*.rb')
14
+ namespace :rdoc do
15
+ desc 'Generate documentation for conversions plugin.'
16
+ Rake::RDocTask.new(:generate) do |rdoc|
17
+ rdoc.rdoc_dir = 'documentation'
18
+ rdoc.title = 'Conversions'
19
+ rdoc.options << '--line-numbers' << '--inline-source' << '--charset' << 'utf-8'
20
+ rdoc.rdoc_files.include('README', 'lib/**/*.rb')
21
+ end
22
22
  end
23
+
24
+ namespace :gem do
25
+ desc "Build the gem"
26
+ task :build do
27
+ sh 'gem build conversions.gemspec'
28
+ end
29
+
30
+ desc "Install the gem"
31
+ task :install => :build do
32
+ sh 'sudo gem install conversions-*.gem'
33
+ end
34
+ end
@@ -1,13 +1,22 @@
1
- Gem::Specification.new do |s|
2
- s.name = "conversions"
3
- s.version = "1.2"
4
- s.date = "2009-01-12"
5
- s.summary = "A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
6
- s.homepage = "http://github.com/Fingertips/conversions/tree/master"
7
- s.description = "A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
8
- s.authors = "Fingertips"
9
- s.email = "manfred@fngtps.com"
10
- #s.files = Dir['[a-zA-Z]*'] + Dir['lib/**/*.rb'] + Dir['rails/*.rb'] + Dir['test/**/*']
11
- s.files = ["conversions.gemspec", "init.rb", "lib", "LICENSE", "rails", "Rakefile", "README", "test", "TODO", "lib/conversions/active_record_accessors.rb", "lib/conversions/ext.rb", "lib/conversions/unit.rb", "lib/conversions.rb", "rails/init.rb", "test/accessor_test.rb", "test/ext_test.rb", "test/test_helper.rb", "test/unit_test.rb"]
12
- s.test_file = "test/unit_test.rb"
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "conversions"
3
+ spec.version = "1.2.1"
4
+
5
+ spec.author = "Manfred Stienstra"
6
+ spec.email = "manfred@fngtps.com"
7
+
8
+ spec.description = <<-EOF
9
+ A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
10
+ EOF
11
+ spec.summary = <<-EOF
12
+ A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
13
+ EOF
14
+ spec.homepage = "http://github.com/Fingertips/conversions/tree/master"
15
+
16
+ spec.files = ["conversions.gemspec", "init.rb", "lib", "LICENSE", "rails", "Rakefile", "README", "test", "TODO", "lib/conversions/active_record_accessors.rb", "lib/conversions/ext.rb", "lib/conversions/unit.rb", "lib/conversions.rb", "rails/init.rb", "test/accessor_test.rb", "test/ext_test.rb", "test/test_helper.rb", "test/unit_test.rb"]
17
+ spec.test_files = ["test/unit_test.rb", "test/accessor_test.rb", "test/ext_test.rb", "test/test_helper.rb"]
18
+
19
+ spec.has_rdoc = true
20
+ spec.extra_rdoc_files = ['README', 'LICENSE']
21
+ spec.rdoc_options << "--charset=utf-8"
13
22
  end
@@ -17,6 +17,9 @@ module Conversions
17
17
  },
18
18
  :cubic_feet => {
19
19
  :cubic_meters => 0.0283168466
20
+ },
21
+ :miles_per_gallon => {
22
+ :kilometres_per_litre => 0.425143707
20
23
  }
21
24
  }
22
25
  end
@@ -28,6 +28,9 @@ class UnitTest < Test::Unit::TestCase
28
28
 
29
29
  amount = Conversions::Unit.new(10.0, :kilograms)
30
30
  assert_equal 22.05, amount.to(:pounds, 2), DELTA
31
+
32
+ amount = Conversions::Unit.new(10.0, :miles_per_gallon)
33
+ assert_equal 4.25, amount.to(:kilometres_per_litre, 2), DELTA
31
34
  end
32
35
 
33
36
  def test_identity_transforms
metadata CHANGED
@@ -1,26 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seamusabshere-conversions
3
3
  version: !ruby/object:Gem::Version
4
- version: "1.2"
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
- - Fingertips
7
+ - Manfred Stienstra
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-01-12 00:00:00 -08:00
12
+ date: 2009-01-11 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
16
- description: A Ruby on Rails plugin that adds conversion capabilities to numeric objects
16
+ description: A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
17
17
  email: manfred@fngtps.com
18
18
  executables: []
19
19
 
20
20
  extensions: []
21
21
 
22
- extra_rdoc_files: []
23
-
22
+ extra_rdoc_files:
23
+ - README
24
+ - LICENSE
24
25
  files:
25
26
  - conversions.gemspec
26
27
  - init.rb
@@ -40,11 +41,11 @@ files:
40
41
  - test/ext_test.rb
41
42
  - test/test_helper.rb
42
43
  - test/unit_test.rb
43
- has_rdoc: false
44
+ has_rdoc: true
44
45
  homepage: http://github.com/Fingertips/conversions/tree/master
45
46
  post_install_message:
46
- rdoc_options: []
47
-
47
+ rdoc_options:
48
+ - --charset=utf-8
48
49
  require_paths:
49
50
  - lib
50
51
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -65,6 +66,9 @@ rubyforge_project:
65
66
  rubygems_version: 1.2.0
66
67
  signing_key:
67
68
  specification_version: 2
68
- summary: A Ruby on Rails plugin that adds conversion capabilities to numeric objects
69
+ summary: A Ruby on Rails plugin that adds conversion capabilities to numeric objects"
69
70
  test_files:
70
71
  - test/unit_test.rb
72
+ - test/accessor_test.rb
73
+ - test/ext_test.rb
74
+ - test/test_helper.rb