ruboty-fop 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 212794e3bd6576267d491e38b97bb94c39cb8066e711a2a3ca441f34bdfc1297
4
- data.tar.gz: c7cdf07a5c44abcfcb71605b552ecfd10c56a2389038fa868ec2f8cf0983f47f
3
+ metadata.gz: 738aecee9800922f4f72ee55b24ea1cea5350203e58587f46c66ea2c547dfba3
4
+ data.tar.gz: 84f602dd1affa279e20883a36927c23a1fb4e3ac0c69a782bb826faaef33d084
5
5
  SHA512:
6
- metadata.gz: 2ec6dc54f568315dce5bbf54adb3b2663bfd393ecc867a07a37d2d41aa329270a17ee104db4ee67073ed940bb113f545b67770496f6ffefada81cf93d668bbe6
7
- data.tar.gz: 23756a9ba67258cc7fb07ac7efae9b89b22efc86834a7dc9f38b1e5bcbfbcf88e08d853e99028126c2b8ca9169c4097af2ee7dd6b1dc87646a5db5d0651b2232
6
+ metadata.gz: 58ecdfe269f3aa4ce77c1ea9fa27ce3fef6b77a836e9ba721dba5e6506a8a30310354510ead2b56aef13b758ed83db12eb2998bf71d63c111151187814cbae62
7
+ data.tar.gz: ef763b7848544704a10719f3ecfc28d1c9cf9d31e28464bce5f060a72f96ab3601cf0ee9c32ec61db26df27483efb2320fc4d0b3245c7eb71e8a132bbb28ac20
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruboty-fop (0.0.2)
4
+ ruboty-fop (0.0.3)
5
5
  fop
6
6
  ruboty
7
7
 
@@ -1,3 +1,3 @@
1
1
  module RubotyFop
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -38,8 +38,8 @@ CARD:
38
38
 
39
39
  CLASS: #{fop.valid_dom_classes.map { |_| "`#{_.code}` #{_.name}" }.join(", ")}
40
40
  FARE:
41
- #{fop.valid_dom_fares.map { |_| "- dom: `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")}
42
- #{fop.valid_intl_fares.map { |_| "- intl: `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")}
41
+ #{fop.valid_dom_fares.map { |_| "- dom: `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")}
42
+ #{fop.valid_intl_fares.map { |_| "- intl: `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")}
43
43
  EOF
44
44
  rescue ::Fop::Error
45
45
  message.reply e.inspect
@@ -128,15 +128,15 @@ FARE:
128
128
  #{from.code} (#{from.name}) - #{to.code} (#{to.name})
129
129
  #{klass ? "#{klass.name}, " : nil}#{fare.name}, #{status.name} (#{card.name})
130
130
 
131
- *single-trip #{result.miles} miles, #{result.fop} FOP*
132
- *round-trip #{result.miles * 2} miles, #{result.fop * 2} FOP*
131
+ #{bold}single-trip #{result.miles} miles, #{result.fop} FOP#{bold}
132
+ #{italic}round-trip #{result.miles * 2} miles, #{result.fop * 2} FOP#{italic}
133
133
 
134
- Mileage:
135
- - #{result.flight_miles} (#{result.flight_miles_remark})
136
- #{result.bonus_miles ? "- #{result.bonus_miles} (#{result.bonus_miles_remark})" : nil}
137
- FOP:
138
- - #{result.flight_miles} * #{result.fop_rate}
139
- #{result.fop_bonus ? "- #{result.fop_bonus } (#{result.fop_bonus_remark})" : nil}
134
+ #{bold}Mileage:#{bold}
135
+ - #{result.flight_miles} (#{result.flight_miles_remark.gsub(/\*|_/,'')})
136
+ #{result.bonus_miles ? "- #{result.bonus_miles} (#{result.bonus_miles_remark.gsub(/\*|_/,'')})" : nil}
137
+ #{bold}FOP:#{bold}
138
+ #{result.flight_miles} x #{result.fop_rate}
139
+ #{result.fop_bonus ? "- #{result.fop_bonus } (#{result.fop_bonus_remark.gsub(/\*|_/,'')})" : nil}
140
140
  EOF
141
141
  rescue ::Fop::Error => e
142
142
  message.reply e.message
@@ -191,7 +191,7 @@ FOP:
191
191
  def find_dom_fare(str)
192
192
  fare = fop.valid_dom_fares.find { |_| _.code == str }
193
193
  unless fare
194
- list = fop.valid_dom_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")
194
+ list = fop.valid_dom_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")
195
195
  if str
196
196
  raise ::Fop::Error, "fare #{str.inspect} is not valid\n#{list}"
197
197
  else
@@ -204,7 +204,7 @@ FOP:
204
204
  def find_intl_fare(str)
205
205
  fare = fop.valid_intl_fares.find { |_| _.code == str }
206
206
  unless fare
207
- list = fop.valid_intl_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark}" }.join("\n")
207
+ list = fop.valid_intl_fares.map { |_| "- `#{_.code}` #{_.name}: #{_.remark.gsub(/\*|_/,'')}" }.join("\n")
208
208
  if str
209
209
  raise ::Fop::Error, "fare #{str.inspect} is not valid\n#{list}"
210
210
  else
@@ -248,6 +248,20 @@ FOP:
248
248
  def parse_options(str)
249
249
  str&.scan(/-(.+?) (.+?)(?:\s+|$)/)&.map{ |_| [_[0].to_sym, _[1]] }.to_h || {}
250
250
  end
251
+
252
+ def bold
253
+ markdown? ? '**' : '*'
254
+ end
255
+
256
+ def italic
257
+ '_'
258
+ end
259
+
260
+ def markdown?
261
+ return @use_markdown if @markdown_detected
262
+ @markdown_detected = true
263
+ @use_markdown = ENV['RUBOTY_FOP_MARKDOWN'] || Ruboty::AdapterBuilder.adapter_classes.last.name.include?('Discord')
264
+ end
251
265
  end
252
266
  end
253
267
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruboty-fop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sorah Fukumori