chemistry 0.0.3 → 0.1.0

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/Rakefile CHANGED
@@ -1,13 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
2
 
3
- LIB_FILES = FileList.new('lib/**/*.rb').
4
- exclude('lib/chemistry/version.rb', 'lib/chemistry/element/*.rb')
5
- TEST_FILES = LIB_FILES.pathmap('%{^lib,test}d/test_%f')
6
-
7
- task :test do
8
- TEST_FILES.zip(LIB_FILES).each do |test_file, lib_file|
9
- ruby "-I lib -I . -I test -r #{lib_file} #{test_file}"
10
- end
3
+ task :default do
4
+ puts 'Smile :D'
11
5
  end
12
-
13
- task :default => :test
@@ -16,4 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency('chemistry-element')
21
+ gem.add_dependency('chemistry-temperature')
19
22
  end
@@ -1,3 +1,3 @@
1
1
  module Chemistry
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -1,8 +1,2 @@
1
1
  require 'minitest/autorun'
2
2
  require 'minitest/colorize'
3
-
4
- class ElementTestCase < MiniTest::Unit::TestCase
5
- def element
6
- @element ||= Class.new(Chemistry::Element)
7
- end
8
- end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chemistry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,40 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-09 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-08-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: chemistry-element
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: chemistry-temperature
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  description: Chemistry is a toolkit for dealing with compounds
15
47
  email:
16
48
  - isaac@isaacbfsanders.com
@@ -26,24 +58,7 @@ files:
26
58
  - Rakefile
27
59
  - chemistry.gemspec
28
60
  - lib/chemistry.rb
29
- - lib/chemistry/dsl.rb
30
- - lib/chemistry/element.rb
31
- - lib/chemistry/element/beryllium.rb
32
- - lib/chemistry/element/boron.rb
33
- - lib/chemistry/element/helium.rb
34
- - lib/chemistry/element/hydrogen.rb
35
- - lib/chemistry/element/lithium.rb
36
- - lib/chemistry/temperature.rb
37
- - lib/chemistry/temperature/celsius.rb
38
- - lib/chemistry/temperature/fahrenheit.rb
39
- - lib/chemistry/temperature/kelvin.rb
40
61
  - lib/chemistry/version.rb
41
- - test/chemistry/temperature/test_celsius.rb
42
- - test/chemistry/temperature/test_fahrenheit.rb
43
- - test/chemistry/temperature/test_kelvin.rb
44
- - test/chemistry/test_dsl.rb
45
- - test/chemistry/test_element.rb
46
- - test/chemistry/test_temperature.rb
47
62
  - test/test_chemistry.rb
48
63
  - test/test_helper.rb
49
64
  homepage: http://isaacbfsanders.com/chemistry
@@ -60,7 +75,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
60
75
  version: '0'
61
76
  segments:
62
77
  - 0
63
- hash: -1034708689434177440
78
+ hash: 2683493068438182152
64
79
  required_rubygems_version: !ruby/object:Gem::Requirement
65
80
  none: false
66
81
  requirements:
@@ -69,7 +84,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
84
  version: '0'
70
85
  segments:
71
86
  - 0
72
- hash: -1034708689434177440
87
+ hash: 2683493068438182152
73
88
  requirements: []
74
89
  rubyforge_project:
75
90
  rubygems_version: 1.8.24
@@ -77,11 +92,5 @@ signing_key:
77
92
  specification_version: 3
78
93
  summary: Chemistry is a toolkit for dealing with compounds
79
94
  test_files:
80
- - test/chemistry/temperature/test_celsius.rb
81
- - test/chemistry/temperature/test_fahrenheit.rb
82
- - test/chemistry/temperature/test_kelvin.rb
83
- - test/chemistry/test_dsl.rb
84
- - test/chemistry/test_element.rb
85
- - test/chemistry/test_temperature.rb
86
95
  - test/test_chemistry.rb
87
96
  - test/test_helper.rb
@@ -1,15 +0,0 @@
1
- require 'chemistry/element'
2
-
3
- module Chemistry::DSL
4
- extend self
5
-
6
- def element(name, &definition)
7
- if block_given?
8
- element_class = Class.new(Chemistry::Element)
9
- Chemistry::Element.const_set(name, element_class)
10
- element_class.instance_eval &definition if block_given?
11
- else
12
- raise ArgumentError, "`element` must be given a block"
13
- end
14
- end
15
- end
@@ -1,41 +0,0 @@
1
- module Chemistry
2
- class Element
3
- class << self
4
- def symbol symbol
5
- if symbol.is_a? String
6
- const_set :SYMBOL, symbol
7
- else
8
- raise TypeError, "can't convert #{symbol.class} into String"
9
- end
10
- end
11
-
12
- def atomic_number atomic_number
13
- if atomic_number.is_a? Integer
14
- const_set :ATOMIC_NUMBER, atomic_number
15
- else
16
- raise TypeError, "can't convert #{atomic_number.class} into Integer"
17
- end
18
- end
19
-
20
- def atomic_weight atomic_weight
21
- if atomic_weight.is_a? Numeric
22
- const_set :ATOMIC_WEIGHT, atomic_weight
23
- else
24
- raise TypeError, "can't convert #{atomic_weight.class} into Numeric"
25
- end
26
- end
27
- end
28
-
29
- def symbol
30
- self.class::SYMBOL
31
- end
32
-
33
- def atomic_number
34
- self.class::ATOMIC_NUMBER
35
- end
36
-
37
- def atomic_weight
38
- self.class::ATOMIC_WEIGHT
39
- end
40
- end
41
- end
@@ -1,7 +0,0 @@
1
- require 'chemistry/element/dsl'
2
-
3
- Chemistry::Element::DSL.element "Beryllium" do
4
- symbol "Be"
5
- atomic_number 4
6
- atomic_weight 9.012182
7
- end
@@ -1,7 +0,0 @@
1
- require 'chemistry/element/dsl'
2
-
3
- Chemistry::Element::DSL.element "Boron" do
4
- symbol "B"
5
- atomic_number 5
6
- atomic_weight 10.811
7
- end
@@ -1,7 +0,0 @@
1
- require 'chemistry/element/dsl'
2
-
3
- Chemistry::Element::DSL.element "Helium" do
4
- symbol "He"
5
- atomic_number 2
6
- atomic_weight 4.002602
7
- end
@@ -1,7 +0,0 @@
1
- require 'chemistry/element/dsl'
2
-
3
- Chemistry::Element::DSL.element "Hydrogen" do
4
- symbol "H"
5
- atomic_number 1
6
- atomic_weight 1.00794
7
- end
@@ -1,7 +0,0 @@
1
- require 'chemistry/element/dsl'
2
-
3
- Chemistry::Element::DSL.element "Lithium" do
4
- symbol "Li"
5
- atomic_number 3
6
- atomic_weight 6.941
7
- end
@@ -1,33 +0,0 @@
1
- require 'chemistry/temperature/kelvin'
2
- require 'chemistry/temperature/fahrenheit'
3
- require 'chemistry/temperature/celsius'
4
-
5
- module Chemistry
6
- class Temperature
7
- class << self
8
- def kelvin(temperature)
9
- Chemistry::Temperature::Kelvin.new(temperature)
10
- end
11
-
12
- def celsius(temperature)
13
- Chemistry::Temperature::Celsius.new(temperature)
14
- end
15
-
16
- def fahrenheit(temperature)
17
- Chemistry::Temperature::Fahrenheit.new(temperature)
18
- end
19
- end
20
-
21
- def initialize(temperature)
22
- @temperature = temperature
23
- end
24
-
25
- def to_i
26
- @temperature.to_i
27
- end
28
-
29
- def to_f
30
- @temperature.to_f
31
- end
32
- end
33
- end
@@ -1,27 +0,0 @@
1
- require 'chemistry/temperature'
2
-
3
- module Chemistry
4
- class Temperature
5
- class Celsius < Chemistry::Temperature
6
- def to_celsius
7
- self
8
- end
9
-
10
- def to_kelvin
11
- Chemistry::Temperature.kelvin convert_to_kelvin
12
- end
13
-
14
- def convert_to_kelvin
15
- @temperature + 273.15
16
- end
17
-
18
- def to_fahrenheit
19
- Chemistry::Temperature.fahrenheit convert_to_fahrenheit
20
- end
21
-
22
- def convert_to_fahrenheit
23
- (@temperature * (9.0/5.0)) + 32.0
24
- end
25
- end
26
- end
27
- end
@@ -1,23 +0,0 @@
1
- require 'chemistry/temperature'
2
-
3
- module Chemistry
4
- class Temperature
5
- class Fahrenheit < Chemistry::Temperature
6
- def to_fahrenheit
7
- self
8
- end
9
-
10
- def to_kelvin
11
- to_celsius.to_kelvin
12
- end
13
-
14
- def to_celsius
15
- Chemistry::Temperature.celsius convert_to_celsius
16
- end
17
-
18
- def convert_to_celsius
19
- (@temperature - 32.0) / (9.0/5.0)
20
- end
21
- end
22
- end
23
- end
@@ -1,23 +0,0 @@
1
- require 'chemistry/temperature'
2
-
3
- module Chemistry
4
- class Temperature
5
- class Kelvin < Chemistry::Temperature
6
- def to_kelvin
7
- self
8
- end
9
-
10
- def to_celsius
11
- Chemistry::Temperature.celsius convert_to_celsius
12
- end
13
-
14
- def to_fahrenheit
15
- to_celsius.to_fahrenheit
16
- end
17
-
18
- def convert_to_celsius
19
- @temperature - 273.15
20
- end
21
- end
22
- end
23
- end
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ToCelsiusTest < MiniTest::Unit::TestCase
4
- def test_returns_self
5
- temp = Chemistry::Temperature::Celsius.new(1)
6
- assert_equal temp, temp.to_celsius
7
- end
8
- end
9
-
10
- class ToKelvinTest < MiniTest::Unit::TestCase
11
- def test_instance_of_kelvin
12
- temp = Chemistry::Temperature::Celsius.new(1)
13
- assert temp.to_kelvin.instance_of? Chemistry::Temperature::Kelvin
14
- end
15
-
16
- def test_difference_of_273
17
- base = 1
18
- temp = Chemistry::Temperature::Celsius.new(base)
19
- assert_equal (temp.to_i - temp.to_kelvin.to_i).abs, 273
20
- end
21
- end
22
-
23
- class ToFahrenheitTest < MiniTest::Unit::TestCase
24
- def test_0C_is_32F
25
- temp = Chemistry::Temperature::Celsius.new(0)
26
- assert_equal temp.to_fahrenheit.to_i, 32
27
- end
28
- end
@@ -1,15 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ToFahrenheitTest < MiniTest::Unit::TestCase
4
- def test_returns_self
5
- temp = Chemistry::Temperature::Fahrenheit.new(1)
6
- assert_equal temp, temp.to_fahrenheit
7
- end
8
- end
9
-
10
- class ToCelsiusTest < MiniTest::Unit::TestCase
11
- def test_32F_is_0C
12
- temp = Chemistry::Temperature::Fahrenheit.new(32)
13
- assert_equal temp.to_celsius.to_i, 0
14
- end
15
- end
@@ -1,28 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ToKelvinTest < MiniTest::Unit::TestCase
4
- def test_returns_self
5
- temp = Chemistry::Temperature::Kelvin.new(1)
6
- assert_equal temp, temp.to_kelvin
7
- end
8
- end
9
-
10
- class ToCelsiusTest < MiniTest::Unit::TestCase
11
- def test_instance_of_celsius
12
- temp = Chemistry::Temperature::Kelvin.new(1)
13
- assert temp.to_celsius.instance_of? Chemistry::Temperature::Celsius
14
- end
15
-
16
- def test_difference_of_273
17
- base = 1
18
- temp = Chemistry::Temperature::Kelvin.new(base)
19
- assert_equal (temp.to_i - temp.to_celsius.to_i).abs, 273
20
- end
21
- end
22
-
23
- class ToFahrenheitTest < MiniTest::Unit::TestCase
24
- def test_273_15K_is_32F
25
- temp = Chemistry::Temperature::Kelvin.new(273.15)
26
- assert_equal temp.to_fahrenheit.to_i, 32
27
- end
28
- end
@@ -1,43 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ElementTest < MiniTest::Unit::TestCase
4
- def test_raises_error_without_name
5
- assert_raises ArgumentError do
6
- Chemistry::DSL.element
7
- end
8
- end
9
-
10
- def test_raises_error_without_block
11
- assert_raises ArgumentError do
12
- Chemistry::DSL.element "Hydrogen"
13
- end
14
- end
15
-
16
- def test_defines_an_element
17
- assert_raises NameError do
18
- Chemistry::Element::Foobar
19
- end
20
-
21
- Chemistry::DSL.element "Foobar" do
22
- end
23
-
24
- assert_equal Chemistry::Element <=> Chemistry::Element::Foobar, 1
25
- end
26
- end
27
-
28
- class DefinitionTest < MiniTest::Unit::TestCase
29
- include Chemistry::DSL
30
-
31
- def test_full_definition
32
- element "Hydrogen" do
33
- symbol 'H'
34
- atomic_number 1
35
- atomic_weight 1.00794
36
- end
37
-
38
- h_atom = Chemistry::Element::Hydrogen.new
39
-
40
- assert_equal h_atom.symbol, 'H'
41
- assert_equal h_atom.atomic_number, 1
42
- end
43
- end
@@ -1,101 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ClassLevelAtomicNumberTest < ElementTestCase
4
- def test_defines_a_constant
5
- assert_raises NameError do
6
- element::ATOMIC_NUMBER
7
- end
8
-
9
- element.atomic_number 14
10
-
11
- assert_equal element::ATOMIC_NUMBER, 14
12
- end
13
-
14
- def test_must_be_an_integer
15
- assert_raises TypeError do
16
- element.atomic_number "a"
17
- end
18
-
19
- assert_raises TypeError do
20
- element.atomic_number 1.2
21
- end
22
-
23
- assert element.atomic_number 12
24
- end
25
- end
26
-
27
- class InstanceLevelAtomicNumberTest < ElementTestCase
28
- def test_requires_atomic_number_to_be_defined_on_the_class_level
29
- assert_raises NameError do
30
- element.new.atomic_number
31
- end
32
-
33
- element.atomic_number 123
34
-
35
- assert_equal element.new.atomic_number, 123
36
- end
37
- end
38
-
39
- class ClassLevelAtomicWeightTest < ElementTestCase
40
- def test_defines_a_constant
41
- assert_raises NameError do
42
- element::ATOMIC_WEIGHT
43
- end
44
-
45
- element.atomic_weight 1.12342314
46
-
47
- assert_equal element::ATOMIC_WEIGHT, 1.12342314
48
- end
49
-
50
- def test_must_be_a_number
51
- assert_raises TypeError do
52
- element.atomic_weight "a"
53
- end
54
-
55
- assert element.atomic_weight 1.2
56
- end
57
- end
58
-
59
- class InstanceLevelAtomicWeightTest < ElementTestCase
60
- def test_requires_atomic_weight_to_be_defined_on_the_class_level
61
- assert_raises NameError do
62
- element.new.atomic_weight
63
- end
64
-
65
- element.atomic_weight 1.12342314
66
-
67
- assert_equal element.new.atomic_weight, 1.12342314
68
- end
69
- end
70
-
71
- class ClassLevelSymbolTest < ElementTestCase
72
- def test_defines_a_constant
73
- assert_raises NameError do
74
- element::SYMBOL
75
- end
76
-
77
- element.symbol "H"
78
-
79
- assert_equal element::SYMBOL, "H"
80
- end
81
-
82
- def test_must_be_a_string_or_symbol
83
- assert_raises TypeError do
84
- element.symbol 1
85
- end
86
-
87
- assert element.symbol 'H'
88
- end
89
- end
90
-
91
- class InstanceLevelSymbolTest < ElementTestCase
92
- def test_requires_symbol_to_be_defined_on_the_class_level
93
- assert_raises NameError do
94
- element.new.symbol
95
- end
96
-
97
- element.symbol 'He'
98
-
99
- assert_equal element.new.symbol, 'He'
100
- end
101
- end
@@ -1,36 +0,0 @@
1
- require 'test_helper'
2
-
3
- class KelvinTest < MiniTest::Unit::TestCase
4
- def test_returns_kelvin_wrapper
5
- assert Chemistry::Temperature.kelvin(1).
6
- instance_of?(Chemistry::Temperature::Kelvin)
7
- end
8
- end
9
-
10
- class ToITest < MiniTest::Unit::TestCase
11
- def test_returns_temperature
12
- temp = 1
13
- assert_equal Chemistry::Temperature.new(temp).to_i, temp.to_i
14
- end
15
- end
16
-
17
- class ToFTest < MiniTest::Unit::TestCase
18
- def test_returns_temperature
19
- temp = 1.0
20
- assert_equal Chemistry::Temperature.new(temp).to_f, temp.to_f
21
- end
22
- end
23
-
24
- class FahrenheitTest < MiniTest::Unit::TestCase
25
- def test_returns_fahrenheit_wrapper
26
- assert Chemistry::Temperature.fahrenheit(1).
27
- instance_of?(Chemistry::Temperature::Fahrenheit)
28
- end
29
- end
30
-
31
- class CelsiusTest < MiniTest::Unit::TestCase
32
- def test_returns_celsius_wrapper
33
- assert Chemistry::Temperature.celsius(1).
34
- instance_of?(Chemistry::Temperature::Celsius)
35
- end
36
- end