Otenki_C 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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9ed9073b8da9705f097cfdd8f6ac3b0a1617533d
4
+ data.tar.gz: 630c3c01aabd865578374f4b74ae4f91fa8651d4
5
+ SHA512:
6
+ metadata.gz: 5d47bb71e89649fbeb394e6d560f3af0eabd00043d07c480aac554cb55dd3e8745fa8f6ddc4470845f813580d0c2f964eaa01c1ff683687532dd53dbc21ec5d5
7
+ data.tar.gz: d02714b85991de5e6435f0bcfda01f157190e6ea3606962474a8965995bef7b6d0e7bab59967d0e1d84ebc6ee069a90f749834d984ba26fb834010a37a2beb6c
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in Otenki_C.gemspec
4
+ gemspec
data/Otenki_C.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'Otenki_C/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "Otenki_C"
8
+ spec.version = OtenkiC::VERSION
9
+ spec.authors = ["z13052hn","a1628nm","b1621ry","z16013ts"]
10
+ spec.email = ["a1628nm@aiit.ac.jp"]
11
+ spec.summary = %q{}
12
+ spec.description = %q{}
13
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
+ spec.bindir = "exe"
15
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_development_dependency "bundler", "~> 1.12"
19
+ spec.add_development_dependency "rake", "~> 10.0"
20
+ end
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # OtenkiC
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/Otenki_C`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'Otenki_C'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install Otenki_C
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Otenki_C.
36
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "Otenki_C"
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,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/Otenki_C.rb ADDED
@@ -0,0 +1,25 @@
1
+ require "./Otenki_C/version"
2
+ #yahoo.rbの読み込み
3
+ require "./Otenki_C/yahoo"
4
+ #google geocodeの読み込み
5
+ require "./Otenki_C/googlemap"
6
+ #表示用
7
+ require "./Otenki_C/rainfall"
8
+
9
+ module OtenkiC
10
+ def otenki(zipcode)
11
+ #郵便番号の取得
12
+
13
+ #郵便番号から緯度と経度を取得
14
+ lat, lng = googlemap(zipcode)
15
+ #緯度経度から天気の情報を取得
16
+ weatherResultHash = weather(lng,lat)
17
+ #表示用
18
+ rainfall(weatherResultHash)
19
+
20
+ end
21
+ module_function :otenki
22
+ end
23
+
24
+ puts "郵便番号を入力してください"
25
+ OtenkiC.otenki(gets.to_s)
@@ -0,0 +1,17 @@
1
+ require 'json'
2
+ require 'net/http'
3
+
4
+ def googlemap(zipcode)
5
+
6
+ #zipcode = "1000001"
7
+ uri = URI.parse('http://maps.googleapis.com/maps/api/geocode/json?address=' + zipcode + '&language=ja&sensor=false')
8
+ #puts uri
9
+ json = Net::HTTP.get(uri)
10
+
11
+ result = JSON.parse(json)
12
+ #puts result
13
+ lat = result["results"][0]["geometry"]["location"]["lat"]
14
+ lng = result["results"][0]["geometry"]["location"]["lng"]
15
+
16
+ return lat, lng
17
+ end
@@ -0,0 +1,22 @@
1
+ def rainfall(weatherResultHash)
2
+ rainfall = weatherResultHash["Feature"][0]["Property"]["WeatherList"]["Weather"][0]["Rainfall"]
3
+ if rainfall == 0.0
4
+ puts "雨は降っていません"
5
+ elsif rainfall < 0.5
6
+ puts "霧雨です"
7
+ elsif rainfall < 3.0
8
+ puts "弱い雨です"
9
+ elsif rainfall < 10.0
10
+ puts "雨です"
11
+ elsif rainfall < 20.0
12
+ puts "やや強い雨です"
13
+ elsif rainfall < 30.0
14
+ puts "強い雨です"
15
+ elsif rainfall < 50.0
16
+ puts "激しい雨です"
17
+ elsif rainfall < 80.0
18
+ puts "非常に激しい雨です"
19
+   else
20
+ print("猛烈な雨です")
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ module OtenkiC
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,18 @@
1
+ require 'open-uri'
2
+ require'json'
3
+ #lat 緯度
4
+ #lng 経度
5
+ def weather(lng,lat)
6
+ #API用のurlの生成
7
+ url = "http://weather.olp.yahooapis.jp/v1/place?coordinates=#{lng},#{lat}&output=json&appid=dj0zaiZpPUk2ck1KQVhwV2pLQiZzPWNvbnN1bWVyc2VjcmV0Jng9OTE-"
8
+ #Yahoo天気APIを呼び出し
9
+ result = open(url)
10
+ #Json=>hashに変換
11
+ hash = JSON.load(result)
12
+
13
+ #デバック用
14
+ #puts url
15
+ #puts hash["Feature"][0]["Property"]["WeatherList"]["Weather"][0]["Rainfall"]
16
+ #最後の2つの配列と連想配列だけいじると値が取れる
17
+ return hash
18
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: Otenki_C
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - z13052hn
8
+ - a1628nm
9
+ - b1621ry
10
+ - z16013ts
11
+ autorequire:
12
+ bindir: exe
13
+ cert_chain: []
14
+ date: 2016-08-11 00:00:00.000000000 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ requirement: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - "~>"
21
+ - !ruby/object:Gem::Version
22
+ version: '1.12'
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: '1.12'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - "~>"
35
+ - !ruby/object:Gem::Version
36
+ version: '10.0'
37
+ type: :development
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '10.0'
44
+ description: ''
45
+ email:
46
+ - a1628nm@aiit.ac.jp
47
+ executables: []
48
+ extensions: []
49
+ extra_rdoc_files: []
50
+ files:
51
+ - ".gitignore"
52
+ - Gemfile
53
+ - Otenki_C.gemspec
54
+ - README.md
55
+ - Rakefile
56
+ - bin/console
57
+ - bin/setup
58
+ - lib/Otenki_C.rb
59
+ - lib/Otenki_C/googlemap.rb
60
+ - lib/Otenki_C/rainfall.rb
61
+ - lib/Otenki_C/version.rb
62
+ - lib/Otenki_C/yahoo.rb
63
+ homepage:
64
+ licenses: []
65
+ metadata: {}
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubyforge_project:
82
+ rubygems_version: 2.4.5.1
83
+ signing_key:
84
+ specification_version: 4
85
+ summary: ''
86
+ test_files: []