periodic_table_jasnow 0.0.2

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.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm --create use 1.9.3@periodic_table_jasnow
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'rake'
4
+
5
+ # Specify your gem's dependencies in periodic_table_jasnow.gemspec
6
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Al Snow
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,22 @@
1
+ # periodic_table_jasnow
2
+
3
+ Provide periodic table data.
4
+
5
+ ## Installation
6
+
7
+ $ gem install periodic_table_jasnow
8
+
9
+ ## Usage
10
+
11
+ require 'periodic_table_jasnow'
12
+
13
+ # Lookup data for an element by name.
14
+ PeriodicTableJasnow.lookup 'oxygen'
15
+
16
+ ## Contributing
17
+
18
+ 1. Fork it
19
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
20
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
21
+ 4. Push to the branch (`git push origin my-new-feature`)
22
+ 5. Create new Pull Request
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new
6
+
7
+ task :default => :spec
8
+ task :test => :spec
@@ -0,0 +1,8 @@
1
+ require 'periodic_table_jasnow/version'
2
+ require 'periodic_table_jasnow/periodic_table_jasnow_api'
3
+
4
+ module PeriodicTableJasnow
5
+ def self.lookup(element_name)
6
+ PeriodicTableJasnowApi.new.query(element_name)
7
+ end
8
+ end
@@ -0,0 +1,47 @@
1
+ require 'savon'
2
+
3
+ module PeriodicTableJasnow
4
+ class PeriodicTableJasnowApi
5
+ def initialize
6
+ @client = Savon::Client.new do
7
+ wsdl.document = 'http://www.webservicex.net/periodictable.asmx?WSDL'
8
+ end
9
+ end
10
+
11
+ def query(element_name)
12
+ api_response = @client.request :get_atomic_number do
13
+ soap.body = {'ElementName' => element_name}
14
+ end
15
+ result = api_response.to_hash[:get_atomic_number_response][:get_atomic_number_result]
16
+ ApiResponse.new(result)
17
+ end
18
+ end
19
+
20
+ # Wow, this is ugly. I did not expect nested XML.
21
+ class ApiResponse
22
+ attr_reader :atomic_weight,
23
+ :symbol,
24
+ :atomic_number,
25
+ :element_name,
26
+ :boiling_point,
27
+ :ionisation_potential,
28
+ :electro_negativity,
29
+ :atomic_radius,
30
+ :melting_point,
31
+ :density
32
+
33
+ def initialize(result)
34
+ xml = Nokogiri::XML.parse(result)
35
+ @atomic_weight = xml.at('AtomicWeight').text
36
+ @symbol = xml.at('Symbol').text
37
+ @atomic_number = xml.at('AtomicNumber').text
38
+ @element_name = xml.at('ElementName').text
39
+ @boiling_point = xml.at('BoilingPoint').text
40
+ @ionisation_potential = xml.at('IonisationPotential').text
41
+ @electro_negativity = xml.at('EletroNegativity').text
42
+ @atomic_radius = xml.at('AtomicRadius').text
43
+ @melting_point = xml.at('MeltingPoint').text
44
+ @density = xml.at('Density').text
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module PeriodicTableJasnow
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,3 @@
1
+ require 'periodic_table_jasnow'
2
+
3
+ puts PeriodicTableJasnow.lookup('oxygen').atomic_weight
@@ -0,0 +1,24 @@
1
+ require File.expand_path('../lib/periodic_table_jasnow/version', __FILE__)
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.name = "periodic_table_jasnow"
5
+ gem.version = PeriodicTableJasnow::VERSION
6
+ gem.authors = ["Al Snow"]
7
+ gem.email = ["jasnow@hotmail.com"]
8
+ gem.homepage = "http://www.linkedin.com/in/alsnow"
9
+ gem.summary = %q{Provide data on elements in the periodic table.}
10
+ gem.description = %q{Provide periodic table data.}
11
+
12
+ gem.rubyforge_project = "periodic_table_jasnow"
13
+
14
+ gem.files = `git ls-files`.split("\n")
15
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.add_development_dependency 'rake'
20
+ gem.add_development_dependency 'rspec'
21
+
22
+ gem.add_runtime_dependency 'savon'
23
+ end
24
+
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe PeriodicTableJasnow do
4
+ it "should return data for a named element" do
5
+ element_data = PeriodicTableJasnow.lookup('oxygen')
6
+ element_data.should_not be_nil
7
+ element_data.symbol.should == 'O'
8
+ element_data.atomic_weight.should == '15.9994'
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ require 'periodic_table_jasnow'
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: periodic_table_jasnow
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Al Snow
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-23 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
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: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: savon
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: Provide periodic table data.
63
+ email:
64
+ - jasnow@hotmail.com
65
+ executables: []
66
+ extensions: []
67
+ extra_rdoc_files: []
68
+ files:
69
+ - .gitignore
70
+ - .rvmrc
71
+ - Gemfile
72
+ - LICENSE
73
+ - README.md
74
+ - Rakefile
75
+ - lib/periodic_table_jasnow.rb
76
+ - lib/periodic_table_jasnow/periodic_table_jasnow_api.rb
77
+ - lib/periodic_table_jasnow/version.rb
78
+ - oxygen_weight.rb
79
+ - periodic_table_jasnow.gemspec
80
+ - spec/lib/periodic_table_jasnow_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: http://www.linkedin.com/in/alsnow
83
+ licenses: []
84
+ post_install_message:
85
+ rdoc_options: []
86
+ require_paths:
87
+ - lib
88
+ required_ruby_version: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ segments:
95
+ - 0
96
+ hash: -863709336681070855
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ segments:
104
+ - 0
105
+ hash: -863709336681070855
106
+ requirements: []
107
+ rubyforge_project: periodic_table_jasnow
108
+ rubygems_version: 1.8.24
109
+ signing_key:
110
+ specification_version: 3
111
+ summary: Provide data on elements in the periodic table.
112
+ test_files:
113
+ - spec/lib/periodic_table_jasnow_spec.rb
114
+ - spec/spec_helper.rb