z14016yh_calcbmi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 25cd79cb9ddcf37ab64a511098405b0ef94b6b96
4
+ data.tar.gz: 4911378286d4b7cff69e1225d7db198e0eb63138
5
+ SHA512:
6
+ metadata.gz: fb47a696def72926b668424a264398034c4f64b8866b95ab663d6be40a65a48b26e4a2717d2c56cf37fc0248b73185a07464c1e36c710e9455babda5a250f2a4
7
+ data.tar.gz: 1595b19ee75fd42a803aea8767d8a3a4e22926497823858f49eb10646e62c0eea98ebc5ea0e96f346b13acb160601c0d9e46c76344bf89423e19c94127535955
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in z14016yh_calcbmi.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 hitomy
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,45 @@
1
+ # Z14016yhCalcbmi
2
+
3
+ Calculate BMI
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'z14016yh_calcbmi'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install z14016yh_calcbmi
20
+
21
+ ## Usage
22
+
23
+ $ z14016yh\_calcbmi
24
+ Please enter your height(cm) => 176
25
+ Please enter your weight(Kg) => 75
26
+ ==> Your BMI is 24.21
27
+
28
+ or
29
+
30
+ [LC\_MESSAGES | LC\_ALL | LANG = ja\*]
31
+
32
+ $ z14016yh\_calcbmi
33
+ あなたの身長を入力してください(cm)? => 176
34
+ あなたの体重を入力してください(kg)? => 75
35
+ あなたのBMIは 24.21 です
36
+
37
+ ## Contributing
38
+
39
+ 1. Fork it ( https://github.com/[my-github-username]/z14016yh\_calcbmi/fork )
40
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
41
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
42
+ 4. Push to the branch (`git push origin my-new-feature`)
43
+ 5. Create a new Pull Request
44
+
45
+
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << 'test'
6
+ end
7
+ desc "Run tests"
8
+
9
+ task :default => :test
10
+
11
+
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # = Calculate BMI command.
4
+ # License:: MIT
5
+ #
6
+ # Calculate Your BMI.
7
+
8
+
9
+
10
+ require 'z14016yh_calcbmi'
11
+
12
+ Z14016yhCalcbmi.calc
13
+
@@ -0,0 +1,7 @@
1
+ en:
2
+ messages:
3
+ question_enter_height: "Please enter your height(cm)? => "
4
+ question_enter_weight: "Please enter your weight(kg)? => "
5
+ answer_bmi: "=> Your BMI is %{bmi_value} "
6
+ error_messages:
7
+ input_error: "Input Error!!!: Please enter in half-width number. "
@@ -0,0 +1,7 @@
1
+ ja:
2
+ messages:
3
+ question_enter_height: "あなたの身長を入力してください(cm)? => "
4
+ question_enter_weight: "あなたの体重を入力してください(kg)? => "
5
+ answer_bmi: "=> あなたのBMIは %{bmi_value} です "
6
+ error_messages:
7
+ input_error: "入力エラー: 半角数字で入力してください "
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # = Calculate BMI Library
4
+ # License:: MIT
5
+ #
6
+ # Calculate Your BMI Library.
7
+ #
8
+
9
+ require "z14016yh_calcbmi/version"
10
+ require "rubygems"
11
+ require "i18n"
12
+
13
+ #
14
+ # Calculate Your BMI Library.
15
+ #
16
+ class Z14016yhCalcbmi
17
+
18
+ #
19
+ # Calculate BMI Method /w terminal.
20
+ #
21
+ def self.calc()
22
+ loadI18n()
23
+
24
+ height, weight = getInputData()
25
+ if height == 0 or weight == 0
26
+ puts I18n.t("error_messages.input_error")
27
+ return
28
+ end
29
+
30
+ bmi = calcBMI(height, weight)
31
+
32
+ puts I18n.t("messages.answer_bmi", {bmi_value: bmi})
33
+ end
34
+
35
+ #
36
+ # Calculate BMI Method
37
+ #
38
+ def self.calcBMI(height, weight)
39
+ heightM = height / 100
40
+ bmi = weight / (heightM * heightM)
41
+
42
+ return bmi.to_f
43
+ end
44
+
45
+
46
+ private
47
+
48
+ def self.getInputData()
49
+ print I18n.t("messages.question_enter_height")
50
+ height = gets.to_f
51
+ print I18n.t("messages.question_enter_weight")
52
+ weight = gets.to_f
53
+ return height, weight
54
+ end
55
+
56
+ def self.loadI18n()
57
+ localePath = getLocalePath()
58
+ ymls = File.join(localePath, "*.yml")
59
+
60
+ I18n.load_path = Dir[ymls]
61
+
62
+ I18n.enforce_available_locales=false
63
+ I18n.default_locale = :en
64
+ I18n.backend.load_translations
65
+ I18n.locale = getSystemLocale() || I18n.default_locale
66
+ end
67
+
68
+ def self.getSystemLocale()
69
+ locale_name_re = %r[
70
+ (?<language>[[:alpha:]]{2,3})
71
+ (?:_ (?<territory>[[:alpha:]]{2,3}) )?
72
+ (?:\. (?<codeset>[^@]+) )?
73
+ (?:@ (?<modifier>.*) )?
74
+ ]x
75
+ env_locale= ENV["LC_MESSAGES"] || ENV["LC_ALL"] || ENV["LANG"] || "C"
76
+ locale = nil
77
+ if m = locale_name_re.match(env_locale)
78
+ lang, territory, encoding_name, modifier = m[:language], m[:territory], m[:codeset], m[:modifier]
79
+ locale = lang
80
+
81
+ end
82
+
83
+ return locale
84
+ end
85
+
86
+ def self.getLocalePath()
87
+ myScriptPath = File.expand_path(File.dirname(__FILE__))
88
+ localePath = File.join(myScriptPath, "locale")
89
+ return localePath
90
+ end
91
+ end
92
+
93
+ if $0 == __FILE__ then
94
+ Z14016yhCalcbmi.calc
95
+ end
96
+
97
+
@@ -0,0 +1,3 @@
1
+ class Z14016yhCalcbmi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'minitest/autorun'
4
+ #require 'flexmock/test_unit'
5
+
6
+ require 'z14016yh_calcbmi'
7
+
8
+ class Z14016yhCalcbmiTest < Minitest::Unit::TestCase
9
+ def test_calc_bmi
10
+ r = Z14016yhCalcbmi.calcBMI(200, 20)
11
+ assert_equal 5, r, "calculate error!!"
12
+ end
13
+ end
14
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'z14016yh_calcbmi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "z14016yh_calcbmi"
8
+ spec.version = Z14016yhCalcbmi::VERSION
9
+ spec.authors = ["hitomy"]
10
+ spec.email = ["hitomy@shimpro.com"]
11
+ spec.summary = %q{Calculate Your BMI.}
12
+ spec.description = %q{Calculate Your BMI.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_development_dependency "flexmock" "~> 1.3.0"
25
+ spec.add_runtime_dependency "i18n", "~> 0.6.0"
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,114 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: z14016yh_calcbmi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - hitomy
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-11-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: flexmock~> 1.3.0
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: i18n
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.6.0
69
+ description: Calculate Your BMI.
70
+ email:
71
+ - hitomy@shimpro.com
72
+ executables:
73
+ - z14016yh_calcbmi
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - bin/z14016yh_calcbmi
83
+ - lib/locale/en.yml
84
+ - lib/locale/ja.yml
85
+ - lib/z14016yh_calcbmi.rb
86
+ - lib/z14016yh_calcbmi/version.rb
87
+ - test/test_z14016yh_calcbmi.rb
88
+ - z14016yh_calcbmi.gemspec
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - ">="
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.2.2
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: Calculate Your BMI.
113
+ test_files:
114
+ - test/test_z14016yh_calcbmi.rb