te_reo_maori 0.1.1 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9c4d305f849d2fb625c6d34cf88e0bf45ef333ae788ab8ae68fb997208582e8
4
- data.tar.gz: 8d9ebc46de387bf2423bd5442e9645de57f0e07ca4ea25606c36a57135157c6c
3
+ metadata.gz: 33fd56f0fbea59f62ed3418fbd08300062f79157c5420213908d57b0f4b10c5b
4
+ data.tar.gz: 61891b379f7de2fc0b89c4c9a45b405053e2f859ee77e7a5afd49d1c1ed3a6f4
5
5
  SHA512:
6
- metadata.gz: 89addf2f4b6d484bc4fb1d2def719d61019de90846a1a929b42cefff1f40a80a1d317bf3430b6dcbf3a822e3a3a5a0242916425fce225cf2ce4717b46260207f
7
- data.tar.gz: 336ff0c1fbaf7b977e8ad8e35dfbccf70e8f9eb09c63dd45646d3d2a9858df88c0343d6527d79cd92404e1e2eddb77fb7a1ba650d6d10ac08e6b50979051790f
6
+ metadata.gz: 462f7843737bdd38df06ea4d46355d41bc3688f85d8d016aac68e5dc722c1055711f5ca8c028ea6bc24b2a27baf4e6688a3cba4f3c3737a6605b60af5a48b0f9
7
+ data.tar.gz: fab3e451336138f49b03697f412d3fdb61b62687d7765f6a510aa7efdaf4564fd31791167b3ff5ba8e5a0f0ea466bdb3050e7605f072a609f11b1f541c7166ed
data/ChangeLog CHANGED
@@ -1,2 +1,10 @@
1
- * v 0.1.1 Has docker image. Handle up to 99
2
- * v 0.1.0 Handles numbers 1-19
1
+ * 0.1.6 - Allow input of macrons
2
+ - Fixed math test
3
+ - Use Ruby 2.7 in docker
4
+ * 0.1.5 - Added simple addition math test
5
+ * 0.1.4 - Pronounce integers on inspection for better terminal experience
6
+ - Handle up to 999 and accent marks
7
+ * 0.1.3 Bug fix. 'Whakahua' did not handle 'iwa' and numbers like toru tekau
8
+ * 0.1.2 whakahua method to pronounce numbers
9
+ * 0.1.1 Has docker image. Handle up to 99
10
+ * 0.1.0 Handles numbers 1-19
data/Dockerfile CHANGED
@@ -1,10 +1,10 @@
1
- FROM ruby:2.6
1
+ FROM ruby:2.7
2
2
  MAINTAINER Samuel Garratt
3
3
 
4
4
  RUN mkdir /app
5
5
  WORKDIR /app
6
6
  COPY . /app
7
7
  RUN gem install bundler
8
- RUN bundle install
8
+ RUN bundle install --without development
9
9
 
10
10
  ENTRYPOINT ["ruby", "exe/te_reo_maori"]
data/Gemfile CHANGED
@@ -5,5 +5,7 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in te_reo_maori.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 12.0'
9
- gem 'rspec', '~> 3.0'
8
+ group :development do
9
+ gem 'rake', '~> 12.0'
10
+ gem 'rspec', '~> 3.0'
11
+ end
data/README.md CHANGED
@@ -4,6 +4,12 @@ Tool to aid one to learn Maori and enable one to program in Maori.
4
4
 
5
5
  ## Installation
6
6
 
7
+ Execute interactive terminal in docker
8
+
9
+ `docker run --rm -it registry.gitlab.com/samuel-garratt/te_reo_maori`
10
+
11
+ ### As a ruby gem
12
+
7
13
  Add this line to your application's Gemfile:
8
14
 
9
15
  ```ruby
@@ -25,8 +31,14 @@ Count in maori
25
31
  ```ruby
26
32
  tahi + rua
27
33
  # Will give a result of 3
34
+ 3.whakahua
35
+ # Will return 'toru'
36
+ whakahua(tahi + tahi)
37
+ # Will return 'rua'
28
38
  ```
29
39
 
40
+ Execute in interactive terminal. After installing type `te_reo_maori` on command prompt to open it.
41
+
30
42
  ## Development
31
43
 
32
44
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -35,7 +47,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
35
47
 
36
48
  ## Contributing
37
49
 
38
- Bug reports and pull requests are welcome on GitLab at https://github.com/samuelgarratt/te_reo_maori. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/te_reo_maori/blob/master/CODE_OF_CONDUCT.md).
50
+ Bug reports and pull requests are welcome on GitLab at https://gitlab.com/samuel-garratt/te_reo_maori. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://gitlab.com/samuel-garratt/te_reo_maori/blob/master/CODE_OF_CONDUCT.md).
39
51
 
40
52
 
41
53
  ## License
@@ -44,4 +56,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
44
56
 
45
57
  ## Code of Conduct
46
58
 
47
- Everyone interacting in the TeReoMaori project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/te_reo_maori/blob/master/CODE_OF_CONDUCT.md).
59
+ Everyone interacting in the TeReoMaori project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://gitlab.com/samuel-garratt/te_reo_maori/blob/master/CODE_OF_CONDUCT.md).
@@ -10,14 +10,19 @@ def putanga
10
10
  end
11
11
 
12
12
  extend Tau # Make numbers available
13
+ extend WhakamatautauPangarau
13
14
 
14
15
  puts 'Nau mai haere mai. Welcome to this application for learning and interacting with Maori.'
15
16
  puts 'Type "putanga" to exit'
17
+ puts 'Type "pangarau" for maths test'
16
18
  puts 'Try and perform +, -, * (times), / (divide) with Maori'
17
19
  puts 'The numbers are: '
18
20
  Tau.rarangi.each do |tau, whakamaoritanga|
19
21
  puts "#{tau}: #{whakamaoritanga}"
20
22
  end
21
- puts 'Example of bigger numbers. 12: (tekau ma rua). Add 23 + 33: (rua tekau ma toru) + (toru tekau ma toru) '
23
+ puts 'If you type a number and press you will see Maori equivalent. Numbers > 10 must be wrapped in (). Greatest supported is 999'
24
+ puts 'Example of bigger numbers. 12: "tekau ma rua". Add 23 + 33: "(rua tekau ma toru) + (toru tekau ma toru)"'
25
+ puts 'See integer form by calling "tau", e.g., "((rua tekau ma toru) + (toru tekau ma toru)).tau" '
26
+ puts 'If you have any ideas on how this can be improved add issue to https://gitlab.com/samuel-garratt/te_reo_maori/-/issues'
22
27
 
23
28
  IRB.start(__FILE__)
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'te_reo_maori/version'
4
4
  require 'te_reo_maori/tau'
5
+ require 'te_reo_maori/whakamatautau_pangarau'
5
6
 
6
7
  module TeReoMaori
7
8
  class Error < StandardError; end
@@ -1,12 +1,20 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'whakahua'
4
+
3
5
  # Number in Maori
4
6
  module Tau
7
+ def whakahua(tau)
8
+ raise "Class '#{tau.class}' not implmemented" unless tau.is_a? Integer
9
+
10
+ tau.whakahua
11
+ end
12
+
5
13
  # List numbers
6
14
  def self.rarangi
7
15
  {
8
- 1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'wha', 5 => 'rima', 6 => 'ono', 7 => 'waru',
9
- 8 => 'iwa', 10 => 'tekau'
16
+ 1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'whā', 5 => 'rima', 6 => 'ono', 7 => 'waru',
17
+ 8 => 'iwa', 9 => 'iwa', 10 => 'tekau'
10
18
  }
11
19
  end
12
20
 
@@ -36,6 +44,8 @@ module Tau
36
44
  digit(4, second_digit)
37
45
  end
38
46
 
47
+ alias whā wha
48
+
39
49
  # 5
40
50
  def rima(second_digit = nil)
41
51
  digit(5, second_digit)
@@ -67,4 +77,6 @@ module Tau
67
77
  def ma(extra_digit)
68
78
  extra_digit
69
79
  end
80
+
81
+ alias mā ma
70
82
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TeReoMaori
4
- VERSION = '0.1.1'
4
+ VERSION = '0.1.6'
5
5
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Extension to Integer for Maori
4
+ class Integer
5
+ def inspect
6
+ whakahua
7
+ end
8
+
9
+ # Numeric form of integer
10
+ def tau
11
+ to_s
12
+ end
13
+
14
+ # @param [Integer] upper_part Integer of number of 100s
15
+ # @param [String] lower_part Already translated part less than 100
16
+ def add_parts(upper_part, lower_part)
17
+ if upper_part == 0
18
+ lower_part
19
+ elsif upper_part == 1
20
+ "kotahi rau #{lower_part}"
21
+ else
22
+ "#{upper_part.whakahua} rau #{lower_part}"
23
+ end
24
+ end
25
+
26
+ # Pronounce number
27
+ def whakahua
28
+ raise NotImplementedError, "Amount of #{self} implemented yet" if self > 999 || self < 1
29
+ return 'kotahi rau' if self == 100
30
+
31
+ lower_part = self % 100
32
+ upper_part = self / 100
33
+
34
+ last_digit = lower_part % 10
35
+ last_digit_word = Tau.rarangi[last_digit]
36
+
37
+ first_digit = (lower_part / 10)
38
+ if first_digit.positive?
39
+ if last_digit.zero?
40
+ return add_parts(upper_part, 'tekau') if first_digit == 1
41
+
42
+ return add_parts upper_part, "#{Tau.rarangi[first_digit]} tekau"
43
+ end
44
+
45
+ return add_parts upper_part, "tekau mā #{last_digit_word}" if first_digit == 1
46
+
47
+ return add_parts upper_part, "#{Tau.rarangi[first_digit]} tekau mā #{last_digit_word}"
48
+ end
49
+ add_parts upper_part, last_digit_word
50
+ end
51
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Math test
4
+ module WhakamatautauPangarau
5
+ # Mathematics. Start a maths test
6
+ def pangarau
7
+ puts 'Nau mai. Please type the answer in Teo Reo Maori (e.g "tahi" for 1) when prompted'
8
+ tau1 = rand(100).to_i
9
+ tau2 = rand(100).to_i
10
+ whakautu_tika = tau1 + tau2
11
+ puts "#{tau1.inspect} + #{tau2.inspect}?"
12
+ whakautu = eval(gets).to_i
13
+ if whakautu == whakautu_tika
14
+ puts 'Ka pai. Correct!'
15
+ else
16
+ puts "Incorrect. You put '#{whakautu.inspect} (#{whakautu})'.
17
+ Correct answer is '#{whakautu_tika.inspect} (#{whakautu_tika})'"
18
+ end
19
+ end
20
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: te_reo_maori
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Garratt
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-18 00:00:00.000000000 Z
11
+ date: 2020-09-30 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Tool to aid one to learn Maori and enable one to program in Maori.
14
14
  email:
@@ -34,6 +34,8 @@ files:
34
34
  - lib/te_reo_maori.rb
35
35
  - lib/te_reo_maori/tau.rb
36
36
  - lib/te_reo_maori/version.rb
37
+ - lib/te_reo_maori/whakahua.rb
38
+ - lib/te_reo_maori/whakamatautau_pangarau.rb
37
39
  - te_reo_maori.gemspec
38
40
  homepage: https://gitlab.com/samuel-garratt/te_reo_maori
39
41
  licenses: