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.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +22 -0
- data/Rakefile +8 -0
- data/lib/periodic_table_jasnow.rb +8 -0
- data/lib/periodic_table_jasnow/periodic_table_jasnow_api.rb +47 -0
- data/lib/periodic_table_jasnow/version.rb +3 -0
- data/oxygen_weight.rb +3 -0
- data/periodic_table_jasnow.gemspec +24 -0
- data/spec/lib/periodic_table_jasnow_spec.rb +10 -0
- data/spec/spec_helper.rb +1 -0
- metadata +114 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
rvm --create use 1.9.3@periodic_table_jasnow
|
data/Gemfile
ADDED
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.
|
data/README.md
ADDED
|
@@ -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
|
data/Rakefile
ADDED
|
@@ -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
|
data/oxygen_weight.rb
ADDED
|
@@ -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
|
data/spec/spec_helper.rb
ADDED
|
@@ -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
|