matsuya 0.0.1

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: 01b46c6341bd1e6e751e65d6dcfc53dfe98edcbd
4
+ data.tar.gz: f0cdd9320b3a5331666e5164dc6f06a6e4ed942e
5
+ SHA512:
6
+ metadata.gz: 0b78a871a114d8668435ccd50e3f7831e40e22f2b9d31eefa692e554b5fb6eca258d5edcfe9a29e8b715ba4e366f01dac410473b71320c8398df465cbc9f00f5
7
+ data.tar.gz: c0af79ee6d65a9a67c114e6710a45fc4f8470f8746e6854157fe27e89450f838b5c42680dcf590e630d5d6df88fd959be6a8e5d5af05cdc873bc030eb583eed9
data/.gitignore ADDED
@@ -0,0 +1,15 @@
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
15
+ /vendor/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in matsuya.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Toshiaki Asai
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,31 @@
1
+ # Matsuya
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'matsuya'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install matsuya
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/matsuya/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/matsuya ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'matsuya'
4
+ puts Matsuya.order
@@ -0,0 +1,3 @@
1
+ module Matsuya
2
+ VERSION = "0.0.1"
3
+ end
data/lib/matsuya.rb ADDED
@@ -0,0 +1,136 @@
1
+ # -*- coding: utf-8 -*-
2
+ require "matsuya/version"
3
+ require 'egison'
4
+ require 'set'
5
+
6
+ module Matsuya
7
+ # 松屋の商品。価格は、牛めしなら並盛など、標準の量と思われるものを入れておく
8
+ Menu = Struct.new(:pattern, :price)
9
+
10
+ # 松屋に実際にあるメニュー。
11
+ # 牛めしのようにプレミアムとそうでないものがある場合は、プレミアムだけを書く
12
+ # オリジナルカレギュウ(プレミアム牛肉使用)も、プレミアムとして扱い、プレミアム牛肉使用と書いていないほうは書かない
13
+ Sample = Set.new([ Menu.new(%i[プレミアム 牛 めし], 380),
14
+ Menu.new(%i[プレミアム 旨辛 ネギ たま 牛 めし], 480),
15
+ Menu.new(%i[プレミアム おろし ポン酢 牛めし], 480),
16
+ Menu.new(%i[プレミアム キムチ 牛 めし], 480),
17
+ Menu.new(%i[オリジナル カレー], 330),
18
+ Menu.new(%i[オリジナル カレギュウ (プレミアム牛肉使用)], 500),
19
+ Menu.new(%i[オリジナル カレギュウ], 490),
20
+ Menu.new(%i[オリジナル ハンバーグ カレー], 590),
21
+ Menu.new(%i[ネギ たっぷり ネギ 塩 豚 カルビ 丼], 450),
22
+ Menu.new(%i[ビビンバ 丼], 450),
23
+ Menu.new(%i[キムチ カルビ 丼], 490),
24
+ Menu.new(%i[豚 テキ 定食], 690),
25
+ Menu.new(%i[シャンピニオン ソース ハンバーグ 定食], 650),
26
+ Menu.new(%i[牛 焼肉 定食], 590),
27
+ Menu.new(%i[カルビ 焼肉 定食], 630),
28
+ Menu.new(%i[豚 バラ 焼肉 定食], 550),
29
+ Menu.new(%i[スタミナ 豚 バラ 生姜焼 定食], 590),
30
+ Menu.new(%i[鶏 チリ ソース 定食], 630),
31
+ Menu.new(%i[ブラウン ソース ハンバーグ 定食], 630),
32
+ Menu.new(%i[豆腐 キムチ チゲ 膳 (プレミアム牛肉使用)], 530),
33
+ Menu.new(%i[チゲ カルビ 焼肉 膳 (プレミアム牛肉使用)], 720),
34
+ ])
35
+
36
+ # 松屋ネットワーク
37
+ NetworkNode = Struct.new(:node, :follow) do
38
+ def inspect
39
+ "#<#{node}->(#{follow.inspect})>"
40
+ end
41
+ end
42
+
43
+ class << self
44
+ # こんなことに使われるなんて可哀想なライブラリだな
45
+ include Egison
46
+
47
+ # 松屋ネットワークを構築し、始点を返す。
48
+ # ==== Return
49
+ # Matsuya::NetworkNode beginノード
50
+ def network
51
+ dic = {begin: NetworkNode.new(:begin, [])}
52
+ Sample.each do |menu|
53
+ [:begin, *menu.pattern, menu.price].each_cons(2) do |current, follow|
54
+ node = dic[current] ||= NetworkNode.new(current, [])
55
+ if follow.is_a? Symbol
56
+ node.follow << dic[follow] ||= NetworkNode.new(follow, [])
57
+ else
58
+ node.follow << follow
59
+ end
60
+ end
61
+ end
62
+ dic.values
63
+ end
64
+
65
+ # お客様に提供する商品を作る。私は接客は不得意なので、ランダムなものが出てくる。
66
+ # おかの値が1に近づくほど狂った商品が出てくる。
67
+ # ==== Args
68
+ # [okano:]
69
+ # Float おかの値。おかの値が高いと商品が変異する確率が上がる。0-1の範囲の値。
70
+ # [current:]
71
+ # Matsuya::NetworkNode 再帰呼出し用。省略する。
72
+ # ==== Return
73
+ # Array 材料を並べた配列
74
+ def generate(okano: 1/10r, current: network.find{|n|n.node == :begin})
75
+ if current.is_a? NetworkNode
76
+ nex = current.follow.sample
77
+ if nex.is_a?(NetworkNode) and rand < okano
78
+ [current.node, *generate(okano: okano, current: network.sample)]
79
+ else
80
+ [current.node, *generate(okano: okano, current: nex)]
81
+ end
82
+ end
83
+ end
84
+
85
+ # 材料を選択したら釜に入れてぐーるぐーる。
86
+ # キムカル丼のように、『キムチ+カルビ』がキムカルに変化するなど、松屋活用を考慮して
87
+ # Matsuya.generate の戻り値をStringに変換する
88
+ # ==== Args
89
+ # [dish] Array 現在の皿の状態
90
+ # ==== Return
91
+ # String できたー!どの特性を残そう?
92
+ def preparation(dish)
93
+ match(dish) do
94
+ with(Egison::List.(*_head, :キムチ, :カルビ, *_tail)) do
95
+ [head, :キムカル, tail]
96
+ end
97
+
98
+ with(Egison::List.(*_head, :ビビンバ, :丼, *_tail)) do
99
+ [head, :ビビン丼, tail]
100
+ end
101
+
102
+ with(Egison::List.(*_head, :鶏, :チリ, *_tail)) do
103
+ [head, :鶏のチリ, tail]
104
+ end
105
+
106
+ with(Egison::List.(*_head, :カルビ, :焼肉, *_tail)) do
107
+ [head, :カルビ焼, tail]
108
+ end
109
+
110
+ with(Egison::List.(*_head, :プレミアム, *_center, :(プレミアム牛肉使用), *_tail)) do
111
+ [head, :プレミアム, center + tail]
112
+ end
113
+
114
+ with(Egison::List.(*_head, :牛, :めし, *_center, :(プレミアム牛肉使用), *_tail)) do
115
+ [:プレミアム, head, :牛, :めし, center + tail]
116
+ end
117
+
118
+ with(Egison::Multiset.(*_not_match)) do
119
+ not_match
120
+ end
121
+ end
122
+ .map{|node| if node.is_a? Array then preparation(node) else node end }
123
+ .flatten
124
+ end
125
+
126
+ # 商品を注文し、商品を受け取る
127
+ # ==== Args
128
+ # [okano]
129
+ # Float おかの値。おかの値が高いと商品が変異する確率が上がる。0-1の範囲の値。
130
+ # ==== Return
131
+ # String 商品名
132
+ def order(okano=1/10r) # !> shadowing outer local variable - ys2
133
+ preparation(generate.reject{|x|x==:begin}).join
134
+ end
135
+ end
136
+ end
data/matsuya.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'matsuya/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "matsuya"
8
+ spec.version = Matsuya::VERSION
9
+ spec.authors = ["Toshiaki Asai"]
10
+ spec.email = ["toshi.alternative@gmail.com"]
11
+ spec.summary = "I'm hungry. gyu-meshi! gyu-meshi!"
12
+ spec.description = "Generate Okanic Matsuya food."
13
+ spec.homepage = "https://github.com/toshia/matsuya-generator-ruby"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = 'matsuya'
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '~> 2.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.7"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "egison", "~> 1.0"
26
+ end
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: matsuya
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Toshiaki Asai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-05 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: egison
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: Generate Okanic Matsuya food.
56
+ email:
57
+ - toshi.alternative@gmail.com
58
+ executables:
59
+ - matsuya
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - bin/matsuya
69
+ - lib/matsuya.rb
70
+ - lib/matsuya/version.rb
71
+ - matsuya.gemspec
72
+ homepage: https://github.com/toshia/matsuya-generator-ruby
73
+ licenses:
74
+ - MIT
75
+ metadata: {}
76
+ post_install_message:
77
+ rdoc_options: []
78
+ require_paths:
79
+ - lib
80
+ required_ruby_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - "~>"
83
+ - !ruby/object:Gem::Version
84
+ version: '2.0'
85
+ required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ requirements: []
91
+ rubyforge_project:
92
+ rubygems_version: 2.4.5.1
93
+ signing_key:
94
+ specification_version: 4
95
+ summary: I'm hungry. gyu-meshi! gyu-meshi!
96
+ test_files: []