convert_temperature 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/.gitignore +9 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +44 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/convert_temperature.gemspec +25 -0
- data/lib/convert_temperature.rb +54 -0
- data/lib/convert_temperature/request.rb +20 -0
- data/lib/convert_temperature/version.rb +3 -0
- metadata +107 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 ecmel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# ConvertTemperature
|
2
|
+
|
3
|
+
Temperature Unit Convertor - Celsius, Fahrenheit, Rankine, and Kelvin
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'convert_temperature'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install convert_temperature
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
##### Abbreviations
|
24
|
+
`Fahrenheit --> fah`, `Celsius --> cel`, `Kelvin --> kel`, `Rankine --> ran`
|
25
|
+
|
26
|
+
|
27
|
+
##### Examples
|
28
|
+
```ruby
|
29
|
+
ConvertTemp.fah_to_cel(temperature) #Convert from Fahrenheit to Celsius
|
30
|
+
ConvertTemp.cel_to_fah(temperature) #Convert from Celsius to Fahrenheit
|
31
|
+
ConvertTemp.kel_to_fah(temperature) #Convert from Kelvin to Fahrenheit
|
32
|
+
ConvertTemp.ran_to_cel(temperature) #Convert from Rankine to Celsius
|
33
|
+
```
|
34
|
+
Others convert has the same logic.
|
35
|
+
|
36
|
+
## Contributing
|
37
|
+
|
38
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/ecmelkytz/convert_temperature.
|
39
|
+
|
40
|
+
- Fork it --> https://github.com/ecmelkytz/convert_temperature
|
41
|
+
- Create your feature branch (git checkout -b your-new-branch)
|
42
|
+
- Commit your changes (git commit -a -m 'your-commit')
|
43
|
+
- Push to the branch (git push origin your-new-branch)
|
44
|
+
- Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "convert_temperature"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'convert_temperature/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "convert_temperature"
|
8
|
+
spec.version = ConvertTemp::VERSION
|
9
|
+
spec.authors = ["ecmel"]
|
10
|
+
spec.email = ["ecmel.kytz@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Convert Temperature}
|
13
|
+
spec.description = %q{Temperature Unit Convertor - Celsius, Fahrenheit, Rankine, and Kelvin}
|
14
|
+
spec.homepage = "https://github.com/ecmelkytz/convert_temperature"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_runtime_dependency "savon"
|
25
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require "convert_temperature/version"
|
2
|
+
require "convert_temperature/request"
|
3
|
+
|
4
|
+
module ConvertTemp
|
5
|
+
class << self
|
6
|
+
def fah_to_cel(temp)
|
7
|
+
Request.new.query(temp, 'degreeFahrenheit', 'degreeCelsius')
|
8
|
+
end
|
9
|
+
|
10
|
+
def fah_to_kel(temp)
|
11
|
+
Request.new.query(temp, 'degreeFahrenheit', 'kelvin')
|
12
|
+
end
|
13
|
+
|
14
|
+
def fah_to_ran(temp)
|
15
|
+
Request.new.query(temp, 'degreeFahrenheit', 'degreeRankine')
|
16
|
+
end
|
17
|
+
|
18
|
+
def cel_to_fah(temp)
|
19
|
+
Request.new.query(temp, 'degreeCelsius', 'degreeFahrenheit')
|
20
|
+
end
|
21
|
+
|
22
|
+
def cel_to_kel(temp)
|
23
|
+
Request.new.query(temp, 'degreeCelsius', 'kelvin')
|
24
|
+
end
|
25
|
+
|
26
|
+
def cel_to_ran(temp)
|
27
|
+
Request.new.query(temp, 'degreeCelsius', 'degreeRankine')
|
28
|
+
end
|
29
|
+
|
30
|
+
def kel_to_fah(temp)
|
31
|
+
Request.new.query(temp, 'kelvin', 'degreeFahrenheit')
|
32
|
+
end
|
33
|
+
|
34
|
+
def kel_to_cel(temp)
|
35
|
+
Request.new.query(temp, 'kelvin', 'degreeCelsius')
|
36
|
+
end
|
37
|
+
|
38
|
+
def kel_to_ran(temp)
|
39
|
+
Request.new.query(temp, 'kelvin', 'degreeRankine')
|
40
|
+
end
|
41
|
+
|
42
|
+
def ran_to_fah(temp)
|
43
|
+
Request.new.query(temp, 'degreeRankine', 'degreeFahrenheit')
|
44
|
+
end
|
45
|
+
|
46
|
+
def ran_to_cel(temp)
|
47
|
+
Request.new.query(temp, 'degreeRankine', 'degreeCelsius')
|
48
|
+
end
|
49
|
+
|
50
|
+
def ran_to_kel(temp)
|
51
|
+
Request.new.query(temp, 'degreeRankine', 'kelvin')
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
module ConvertTemp
|
4
|
+
class Request
|
5
|
+
def initialize
|
6
|
+
@client = Savon.client do
|
7
|
+
wsdl "http://www.webservicex.net/ConvertTemperature.asmx?WSDL"
|
8
|
+
convert_request_keys_to :camelcase
|
9
|
+
open_timeout 10
|
10
|
+
read_timeout 10
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def query(temp, from_unit, to_unit)
|
15
|
+
response = @client.call :convert_temp, message: {temperature: temp, from_unit: from_unit, to_unit: to_unit}
|
16
|
+
result = response.to_hash[:convert_temp_response][:convert_temp_result]
|
17
|
+
result
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: convert_temperature
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ecmel
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-01-10 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.10'
|
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: '1.10'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '10.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: '10.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: Temperature Unit Convertor - Celsius, Fahrenheit, Rankine, and Kelvin
|
63
|
+
email:
|
64
|
+
- ecmel.kytz@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .travis.yml
|
71
|
+
- CODE_OF_CONDUCT.md
|
72
|
+
- Gemfile
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.md
|
75
|
+
- Rakefile
|
76
|
+
- bin/console
|
77
|
+
- bin/setup
|
78
|
+
- convert_temperature.gemspec
|
79
|
+
- lib/convert_temperature.rb
|
80
|
+
- lib/convert_temperature/request.rb
|
81
|
+
- lib/convert_temperature/version.rb
|
82
|
+
homepage: https://github.com/ecmelkytz/convert_temperature
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
post_install_message:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
88
|
+
- lib
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 1.8.23
|
104
|
+
signing_key:
|
105
|
+
specification_version: 3
|
106
|
+
summary: Convert Temperature
|
107
|
+
test_files: []
|