botcore 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: 3a21cc1faf015bae47d1a80d0ce65ba21f4a3b19
4
+ data.tar.gz: 0645582f2c7b079141f3e182045aaaa5fa503d73
5
+ SHA512:
6
+ metadata.gz: 0b5ed1c3ee573b7c77f7f4477da4cce4e80974c817afb0b23caf752767cd8e5e7bfadd7999620d833bb0b8edb1953db95bab03963bfcde270e6b7484860a72e7
7
+ data.tar.gz: 9b7ffcc496f77fc0ce2173ae5f7ce11f52b61ec4d1cb644cadecae9971c6e7c72ee5468d87dbed1558cc9614babfb97793f53e7cf1e2d13496087e3962d2a60c
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ config.txt
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.0
5
+ before_install: gem install bundler -v 1.12.5
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at tomcha@tomcha.net. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in botcore.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 tomcha
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,39 @@
1
+ # Botcore
2
+
3
+ This program is "BOT" application's brain program. It works, "better take an umbrella percentage in Osaka", "garbage collection day in Mino-city", "Brand search of liquor" programs.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'botcore'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install botcore
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Development
26
+
27
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake true` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
28
+
29
+ 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).
30
+
31
+ ## Contributing
32
+
33
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/botcore. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
34
+
35
+
36
+ ## License
37
+
38
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
+
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 "botcore"
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/botcore.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'botcore/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "botcore"
8
+ spec.version = Botcore::VERSION
9
+ spec.authors = ["tomcha"]
10
+ spec.email = ["tomcha@tomcha.net"]
11
+
12
+ spec.summary = %q{Bot progoram core application}
13
+ spec.description = %q{Bot progoram core application}
14
+ spec.homepage = "https://github.com/tomcha/botcore"
15
+ spec.license = "MIT"
16
+
17
+ spec.add_development_dependency "rspec"
18
+
19
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
20
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
21
+ #if spec.respond_to?(:metadata)
22
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
23
+ #else
24
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
25
+ #end
26
+
27
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.12"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ end
data/lib/botcore.rb ADDED
@@ -0,0 +1,8 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require "botcore/version"
3
+ require "botcore/dust_calender"
4
+ require "botcore/scrap_weather_report"
5
+ require "botcore/sakenote_api"
6
+ module Botcore
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,58 @@
1
+ module Botcore
2
+ class DustCalender
3
+ def initialize(*weeknumber)
4
+ def initialize(*weeknumber)
5
+ if (weeknumber.size > 0)
6
+ # #テスト用イニシャライザ
7
+ @today_weeknumber = weeknumber[0]
8
+ @tomorrow_weeknumber = weeknumber[0]
9
+ @today_weekday = weeknumber[1]
10
+ else
11
+ @today_weeknumber = ((Time.now.day) / 7) + 1
12
+ @tomorrow_weeknumber = ((Time.now.day - 1) / 7) + 1
13
+ @today_weekday = Time.now.wday
14
+ end
15
+ end
16
+
17
+ def tomorrow_schedule
18
+ tomorrow_schedule = Array.new
19
+ case @today_weekday
20
+ when 0
21
+ tomorrow_schedule << '明日は燃えるゴミの日'
22
+ when 2
23
+ if (@tomorrow_weeknumber == 1 || @tomorrow_weeknumber == 3)
24
+ tomorrow_schedule << '明日はかん・びんの日'
25
+ elsif (@tomorrow_weeknumber == 2 || @tomorrow_weeknumber == 4)
26
+ tomorrow_schedule << '明日は不燃、危険、大型ゴミの日'
27
+ end
28
+ when 3
29
+ tomorrow_schedule << '明日は燃えるゴミの日'
30
+ if (@tomorrow_weeknumber == 1 || @tomorrow_weeknumber == 3)
31
+ tomorrow_schedule << '明日は古着・ダンボールの日'
32
+ end
33
+ end
34
+ return tomorrow_schedule
35
+ end
36
+
37
+ def today_schedule
38
+ today_schedule = Array.new
39
+ case @today_weekday
40
+ when 1
41
+ today_schedule << '今日は燃えるゴミの日'
42
+ when 3
43
+ if (@today_weeknumber == 1 || @today_weeknumber == 3)
44
+ today_schedule << '今日はかん・びんの日'
45
+ elsif (@today_weeknumber == 2 || @today_weeknumber == 4)
46
+ today_schedule << '今日は不燃、危険、大型ゴミの日'
47
+ end
48
+ when 4
49
+ today_schedule << '今日は燃えるゴミの日'
50
+ if (@today_weeknumber == 1 || @today_weeknumber == 3)
51
+ today_schedule << '今日は古着・ダンボールの日'
52
+ end
53
+ end
54
+ return today_schedule
55
+ end
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,56 @@
1
+ require 'botcore/sakenote_api/todofuken'
2
+ require 'net/http'
3
+ require 'uri'
4
+ require 'openssl'
5
+ require 'json'
6
+
7
+ module Botcore
8
+ class Sakenote
9
+ @apitoken
10
+ def initialize
11
+ File.open('config.txt') do |f|
12
+ f.each_line do |txt|
13
+ if txt =~ /sakenote_apitoken:(.+)/
14
+ @apitoken = $1
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ def loaded_apitoken?
21
+ @apitoken ? true : false
22
+ end
23
+
24
+ def invest_maker(place)
25
+ sake_list = Hash.new
26
+ if place =~ /(.+)(都|道|府|県)/
27
+ place = $1
28
+ end
29
+ tf = Botcore::SakenoteApi::Todofuken.new
30
+ prefecture_code = tf.get_fukennum(place)
31
+ url_text = 'https://www.sakenote.com/api/v1/sakes'
32
+ uri = URI.parse(url_text)
33
+ http = Net::HTTP.new(uri.host, uri.port)
34
+ http.use_ssl = true
35
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
36
+ options = {
37
+ token: @apitoken,
38
+ prefecture_code: prefecture_code,
39
+ page: 0,
40
+ }.select{ |k, v| !v.nil? }
41
+ begin
42
+ options[:page] += 1
43
+ req = Net::HTTP::Get.new(uri.request_uri, initheader = { 'Content-Type' => 'application/json' })
44
+ req.body = options.to_json
45
+ res = http.request(req)
46
+ body = JSON.parse(res.body)
47
+ sakes = body["sakes"]
48
+ sakes.each do |s|
49
+ sake_list[s["sake_name"]] = s["maker_name"]
50
+ end
51
+ puts options[:page]
52
+ end while options[:page] < body["num_pages"]
53
+ sake_list
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,79 @@
1
+ module Botcore
2
+ module SakenoteApi
3
+ class Todofuken
4
+ def initialize
5
+ @name_code_data = {
6
+ '北海道' => '01',
7
+ '青森県' => '02',
8
+ '岩手県' => '03',
9
+ '宮城県' => '04',
10
+ '秋田県' => '05',
11
+ '山形県' => '06',
12
+ '福島県' => '07',
13
+ '茨城県' => '08',
14
+ '栃木県' => '09',
15
+ '群馬県' => '10',
16
+ '埼玉県' => '11',
17
+ '千葉県' => '12',
18
+ '東京都' => '13',
19
+ '神奈川県' => '14',
20
+ '新潟県' => '15',
21
+ '富山県' => '16',
22
+ '石川県' => '17',
23
+ '福井県' => '18',
24
+ '山梨県' => '19',
25
+ '長野県' => '20',
26
+ '岐阜県' => '21',
27
+ '静岡県' => '22',
28
+ '愛知県' => '23',
29
+ '三重県' => '24',
30
+ '滋賀県' => '25',
31
+ '京都府' => '26',
32
+ '大阪府' => '27',
33
+ '兵庫県' => '28',
34
+ '奈良県' => '29',
35
+ '和歌山県' => '30',
36
+ '鳥取県' => '31',
37
+ '島根県' => '32',
38
+ '岡山県' => '33',
39
+ '広島県' => '34',
40
+ '山口県' => '35',
41
+ '徳島県' => '36',
42
+ '香川県' => '37',
43
+ '愛媛県' => '38',
44
+ '高知県' => '39',
45
+ '福岡県' => '40',
46
+ '佐賀県' => '41',
47
+ '長崎県' => '42',
48
+ '熊本県' => '43',
49
+ '大分県' => '44',
50
+ '宮崎県' => '45',
51
+ '鹿児島県' => '46',
52
+ '沖縄県' => '47',
53
+ }
54
+ end
55
+
56
+ def get_fukennum(fuken_name)
57
+ @fuken_name = fuken_name
58
+ k = @name_code_data.keys
59
+ k.each do |fuken|
60
+ if (fuken =~ /^#{@fuken_name}(都|道|府|県)?$/)
61
+ fuken_no = @name_code_data[fuken]
62
+ return fuken_no.to_i
63
+ end
64
+ end
65
+ nil
66
+ end
67
+
68
+ def fuken_name?(fuken_name)
69
+ keys = @name_code_data.keys
70
+ keys.each do |fuken|
71
+ if (fuken =~ /^#{fuken_name}(都|道|府|県)?$/)
72
+ return true
73
+ end
74
+ end
75
+ false
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,61 @@
1
+ require 'net/http'
2
+
3
+ module Botcore
4
+ class ScrapWeatherReport
5
+ def initialize(*place_name)
6
+
7
+ @tenki_jp_place_data = {
8
+ sapporo: '1/2/1400',
9
+ hakodate: '1/4/2300',
10
+ yokohama: '3/17/4610',
11
+ tokyo: '3/16/4410',
12
+ nagoya: '5/26/5110',
13
+ tsu: '5/27/5310',
14
+ osaka: '6/30/6200',
15
+ kobe: '6/31/6310',
16
+ kyoto: '6/29/6110',
17
+ fukuoka: '9/43/8210',
18
+ ooita: '9/47/8310',
19
+ nagasaki: '9/45/8410',
20
+ naha: '10/50/9110',
21
+ }
22
+
23
+ if(place_name.size >0)
24
+ pn = place_name[0].to_sym
25
+ if (@tenki_jp_place_data[pn] != nil)
26
+ @targeturl = "http://www.tenki.jp/indexes/umbrella/#{@tenki_jp_place_data[pn]}.html"
27
+ else
28
+ @targeturl = nil
29
+ end
30
+ else
31
+ #近畿地方 大阪府のデータ
32
+ @targeturl = 'http://www.tenki.jp/indexes/umbrella/6/30/6200.html'
33
+ end
34
+ end
35
+
36
+ def get_umbrella_data
37
+ uri = URI.parse(@targeturl)
38
+ res = Net::HTTP.get(uri)
39
+ res.force_encoding("utf-8")
40
+ res =~ /<dl id="exponentLargeLeft">(.+?)<\/dl>/m
41
+ today_html = $1
42
+ today_html =~ /alt="指数:(.+?):(.+?)"/
43
+ @today_rainypercent = $1
44
+ @today_umbrella_advice = $2
45
+
46
+ res =~ /<dl id="exponentLargeRight">(.+?)<\/dl>/m
47
+ tomorrow_html = $1
48
+ tomorrow_html =~ /alt="指数:(.+?):(.+?)"/
49
+ @tomorrow_rainypercent = $1
50
+ @tomorrow_umbrella_advice = $2
51
+
52
+ umbrella_data = {today_rainypercent: @today_rainypercent,
53
+ today_umbrella_advice: @today_umbrella_advice,
54
+ tomorrow_rainypercent: @tomorrow_rainypercent,
55
+ tomorrow_umbrella_advice: @tomorrow_umbrella_advice}
56
+ return umbrella_data
57
+ end
58
+ end
59
+ end
60
+
61
+ __END__
@@ -0,0 +1,3 @@
1
+ module Botcore
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: botcore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - tomcha
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-08-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: Bot progoram core application
56
+ email:
57
+ - tomcha@tomcha.net
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - bin/console
71
+ - bin/setup
72
+ - botcore.gemspec
73
+ - lib/botcore.rb
74
+ - lib/botcore/dust_calender.rb
75
+ - lib/botcore/sakenote_api.rb
76
+ - lib/botcore/sakenote_api/todofuken.rb
77
+ - lib/botcore/scrap_weather_report.rb
78
+ - lib/botcore/version.rb
79
+ homepage: https://github.com/tomcha/botcore
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.5.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Bot progoram core application
103
+ test_files: []