te_reo_maori 0.1.0 → 0.1.5

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: 15f1388c18d6a441b6fd21c1ce469812ba9699ae0d077652810a123a3f02d7c2
4
- data.tar.gz: ce16604c09f8dc6cd936af662947675086e41c08ada7588a9f2c4e0aab5a03b8
3
+ metadata.gz: 4d7e033dd690ec5a8b082f109638dedcfca0ecd77ec637426486f283b905d229
4
+ data.tar.gz: 733fba9ba22ac5574c552fd9854c961737175e255fce0485ee5031d3958afb91
5
5
  SHA512:
6
- metadata.gz: d7f8c9574ed5707599ffb943c159d833018678a3bbf83d4efdb6e7411b84eca56585ba9b40a30299b2eb5bb718767e08006ce6dbb693fb2071d88ee2172a0d23
7
- data.tar.gz: 226301514fb751764e133fff9def65574c5eb288218c2da2d353567511ef09776328863c598d21bab2757a8b3310f9d7cea19a241fb9e8d0f1b54fe1bb5223f4
6
+ metadata.gz: b0f769a32c1154f0a7914b9f4929358223dfea55685ae46b18e2a5f3b89403135e5027c465977c3361eed96c47fe046df18a36a6ff99019d41189a80761c29c1
7
+ data.tar.gz: 5c84a699c686ec242211b051eb682b7abfc0633d6082fb355cac2cc511380c9e073f71bedee4eda849869ba5c909b300ddfcca5bbc31b28e6554cadaac152ae8
@@ -1,8 +1,28 @@
1
1
  image: ruby:2.6
2
2
 
3
- before_script:
4
- - bundle install
5
-
6
3
  test:
4
+ before_script:
5
+ - bundle install
7
6
  script:
8
7
  - rake
8
+
9
+ include:
10
+ - template: Code-Quality.gitlab-ci.yml
11
+
12
+ docker_build:
13
+ variables:
14
+ # Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
15
+ DOCKER_HOST: tcp://docker:2376
16
+ DOCKER_TLS_CERTDIR: "/certs"
17
+ stage: deploy # Part of a later stage
18
+ services:
19
+ - docker:19.03.5-dind
20
+ image: docker:19.03.5
21
+ script:
22
+ - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
23
+ - docker pull --quiet $CI_REGISTRY_IMAGE:latest || true
24
+ - docker build -t $CI_REGISTRY_IMAGE:latest .
25
+ - docker push $CI_REGISTRY_IMAGE:latest
26
+ only:
27
+ - master
28
+ needs: ["test"]
data/ChangeLog CHANGED
@@ -1 +1,7 @@
1
- * v 0.1.0 Handles numbers 1-19
1
+ * 0.1.5 - Added simple addition math test
2
+ * 0.1.4 - Pronounce integers on inspection for better terminal experience
3
+ - Handle up to 999 and accent marks
4
+ * 0.1.3 Bug fix. 'Whakahua' did not handle 'iwa' and numbers like toru tekau
5
+ * 0.1.2 whakahua method to pronounce numbers
6
+ * 0.1.1 Has docker image. Handle up to 99
7
+ * 0.1.0 Handles numbers 1-19
@@ -0,0 +1,10 @@
1
+ FROM ruby:2.6
2
+ MAINTAINER Samuel Garratt
3
+
4
+ RUN mkdir /app
5
+ WORKDIR /app
6
+ COPY . /app
7
+ RUN gem install bundler
8
+ RUN bundle install
9
+
10
+ ENTRYPOINT ["ruby", "exe/te_reo_maori"]
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:latest`
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).
@@ -5,4 +5,24 @@ require 'irb'
5
5
  $LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib')
6
6
  require 'te_reo_maori'
7
7
 
8
+ def putanga
9
+ exit
10
+ end
11
+
12
+ extend Tau # Make numbers available
13
+ extend WhakamatautauPangarau
14
+
15
+ puts 'Nau mai haere mai. Welcome to this application for learning and interacting with Maori.'
16
+ puts 'Type "putanga" to exit'
17
+ puts 'Type "pangarau" for maths test'
18
+ puts 'Try and perform +, -, * (times), / (divide) with Maori'
19
+ puts 'The numbers are: '
20
+ Tau.rarangi.each do |tau, whakamaoritanga|
21
+ puts "#{tau}: #{whakamaoritanga}"
22
+ end
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'
27
+
8
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,49 +1,78 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- class Tau < Integer
4
- end
3
+ require_relative 'whakahua'
5
4
 
6
- def tahi
7
- 1
8
- end
5
+ # Number in Maori
6
+ module Tau
7
+ def whakahua(tau)
8
+ raise "Class '#{tau.class}' not implmemented" unless tau.is_a? Integer
9
9
 
10
- def rua
11
- 2
12
- end
10
+ tau.whakahua
11
+ end
13
12
 
14
- def toru
15
- 3
16
- end
13
+ # List numbers
14
+ def self.rarangi
15
+ {
16
+ 1 => 'tahi', 2 => 'rua', 3 => 'toru', 4 => 'whā', 5 => 'rima', 6 => 'ono', 7 => 'waru',
17
+ 8 => 'iwa', 9 => 'iwa', 10 => 'tekau'
18
+ }
19
+ end
17
20
 
18
- def wha
19
- 4
20
- end
21
+ def digit(tau, second_digit)
22
+ return tau if second_digit.nil?
21
23
 
22
- def rima
23
- 5
24
- end
24
+ ((tau - 1) * 10) + second_digit
25
+ end
25
26
 
26
- def ono
27
- 6
28
- end
27
+ # 1
28
+ def tahi
29
+ 1
30
+ end
29
31
 
30
- def whitu
31
- 7
32
- end
32
+ # 2
33
+ def rua(second_digit = nil)
34
+ digit(2, second_digit)
35
+ end
33
36
 
34
- def waru
35
- 8
36
- end
37
+ # 3
38
+ def toru(second_digit = nil)
39
+ digit(3, second_digit)
40
+ end
37
41
 
38
- def iwa
39
- 9
40
- end
42
+ # 4
43
+ def wha(second_digit = nil)
44
+ digit(4, second_digit)
45
+ end
41
46
 
42
- def tekau(extra_digit = nil)
43
- extra_digit ? 10 + extra_digit : 10
44
- end
47
+ # 5
48
+ def rima(second_digit = nil)
49
+ digit(5, second_digit)
50
+ end
51
+
52
+ # 6
53
+ def ono(second_digit = nil)
54
+ digit(6, second_digit)
55
+ end
56
+
57
+ def whitu(second_digit = nil)
58
+ digit(7, second_digit)
59
+ end
60
+
61
+ def waru(second_digit = nil)
62
+ digit(8, second_digit)
63
+ end
64
+
65
+ def iwa(second_digit = nil)
66
+ digit(9, second_digit)
67
+ end
68
+
69
+ # 10. Used to add groups of 10
70
+ def tekau(extra_digit = nil)
71
+ extra_digit ? 10 + extra_digit : 10
72
+ end
45
73
 
46
- # Add extra digit
47
- def ma(extra_digit)
48
- extra_digit
74
+ # Add extra digit
75
+ def ma(extra_digit)
76
+ extra_digit
77
+ end
49
78
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module TeReoMaori
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.5'
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,18 @@
1
+ # Math test
2
+ module WhakamatautauPangarau
3
+ # Mathematics. Start a maths test
4
+ def pangarau
5
+ puts 'Nau mai. Please type the answer in Teo Reo Maori (e.g "tahi" for 1) when prompted'
6
+ tau1 = rand(100).to_i
7
+ tau2 = rand(100).to_i
8
+ whakautu_tika = tau1 + tau2 + 1
9
+ puts "#{tau1.inspect} + #{tau2.inspect}?"
10
+ whakautu = eval(gets).to_i
11
+ if whakautu == whakautu_tika
12
+ puts 'Ka pai. Correct!'
13
+ else
14
+ puts "Incorrect. You put '#{whakautu.inspect} (#{whakautu})'.
15
+ Correct answer is '#{whakautu_tika.inspect} (#{whakautu_tika})'"
16
+ end
17
+ end
18
+ 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.0
4
+ version: 0.1.5
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-17 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:
@@ -23,6 +23,7 @@ files:
23
23
  - ".rspec"
24
24
  - CODE_OF_CONDUCT.md
25
25
  - ChangeLog
26
+ - Dockerfile
26
27
  - Gemfile
27
28
  - LICENSE.txt
28
29
  - README.md
@@ -33,6 +34,8 @@ files:
33
34
  - lib/te_reo_maori.rb
34
35
  - lib/te_reo_maori/tau.rb
35
36
  - lib/te_reo_maori/version.rb
37
+ - lib/te_reo_maori/whakahua.rb
38
+ - lib/te_reo_maori/whakamatautau_pangarau.rb
36
39
  - te_reo_maori.gemspec
37
40
  homepage: https://gitlab.com/samuel-garratt/te_reo_maori
38
41
  licenses: