prime_products 0.1.0 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c89a59e2546e8634e232c6a6061743a774327d482bb8848f49dfbb9ac2dbf39e
4
- data.tar.gz: 995d3b55063f6961309571a108abf290911c55feb6e33b0fa85a909ae6769e1d
3
+ metadata.gz: 33ac5620ba1e8f2ad6673b6a0594395d0228b8f79e3b576a0ef333474169bd06
4
+ data.tar.gz: 9b10d62cc31781174c261eb0496dd270b287613ab1b21aa6184d0913851e8269
5
5
  SHA512:
6
- metadata.gz: 3137a492c281a242fa36e46a2fe3f3dda3ce4632ba91ab8e7594292f9a10f52fddbbb50ab25d374d0fce7c972eb942a842b29005f6db706ba49cd58cc7ce6154
7
- data.tar.gz: 9fed6a69ea93e510de70f7a08aa18bb8bde65754cb37974367cbf2f04a638fc1840ebfea99b214901ab2c8e59b6d51932a9d09128deafd2dd1514b992ac391a5
6
+ metadata.gz: 11d1a587e00911b5c2199eea91465b6cf88d1159ee1474f0b09f8ae2fac9981dac0b4aedebc851d45b9dfb42ed9ed0b244ca2757102d51881f2e80f5c3b66ed0
7
+ data.tar.gz: f3f2cd5387c6d78787322fe0629023e7a9eb2f90081362d0d2577023611e25d190bb1cadaf646e8f9f76b2222920934a01c45bd8cfda23c45b50671e82832c5c
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # v0.1.1 (25 Nov 2018)
2
+
3
+ * Rename `PrimeProducts::ProductsTable` to `PrimeProducts::MultiplicationTable`
4
+
5
+ # v0.1.0 (25 Nov 2018)
6
+
7
+ * Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- prime_products (0.1.0)
4
+ prime_products (0.1.1)
5
5
  hanami-cli (~> 0.3.0)
6
6
  immutable-ruby (~> 0.0.3)
7
7
  terminal-table (~> 1.8.0)
data/README.md CHANGED
@@ -35,6 +35,22 @@ prime_products 10
35
35
 
36
36
  If you do not provide an argument, we will use the first 5 by default.
37
37
 
38
+ ## Exploring the code
39
+
40
+ The code is logically separated into parts, in line with the single responsibility principle.
41
+
42
+ When you run the `prime_products` executable included with the gem, `exe/prime_products` is executed, which calls `PrimeProducts::CLI.call`.
43
+
44
+ `PrimeProducts::CLI.call` defaults to outputting the `STDOUT` and reading input from `ARGV`, but this can be customised, allowing for a "dependency injection" approach to testing.
45
+
46
+ It finds the number of primes to use, looking at `ARGV` and defaulting to `CLI::DEFAULT_NUMBER_OF_PRIMES` if no option has been provided.
47
+
48
+ It then calls `PrimeProducts.generate_table` with the `number_of_primes`, and writes the result to the output,
49
+
50
+ `PrimeProducts.generate_table` finds the requested number of prime numbers using `PrimeProducts::PrimeNumbers.first`, and then asks `PrimeProducts::MultiplicationTable.generate` to generate a multiplication table from them.
51
+
52
+ `PrimeProducts::PrimeNumbers.first` uses a simple, naive but sufficiently performant method of finding the primes - see the "Benchmarking" section below - and returns them in an `Immutable::SortedSet` to avoid the danger of accidental mutation.
53
+
38
54
  ## Benchmarking
39
55
 
40
56
  This gem uses a naive method of finding the first *n* primes which does not scale especially well. However, this seems reasonable given that the primes will be displayed on-screen, and so it is unlikely you will want to see a large number at once.
@@ -3,7 +3,7 @@
3
3
  require "terminal-table"
4
4
 
5
5
  module PrimeProducts
6
- module ProductsTable
6
+ module MultiplicationTable
7
7
  class << self
8
8
  # Generates an ASCII "multiplication table" of the supplied `numbers`, suitable
9
9
  # for presentation in a shell.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PrimeProducts
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "prime_products/cli"
4
4
  require "prime_products/prime_numbers"
5
- require "prime_products/products_table"
5
+ require "prime_products/multiplication_table"
6
6
  require "prime_products/version"
7
7
 
8
8
  module PrimeProducts
@@ -25,6 +25,6 @@ module PrimeProducts
25
25
  # @return [String] the generated table
26
26
  def self.generate_table(number_of_primes:)
27
27
  prime_numbers = PrimeNumbers.first(number_of_primes)
28
- ProductsTable.generate(prime_numbers)
28
+ MultiplicationTable.generate(prime_numbers)
29
29
  end
30
30
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prime_products
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Rogers
@@ -149,10 +149,9 @@ files:
149
149
  - ".rspec"
150
150
  - ".rubocop.yml"
151
151
  - ".ruby-version"
152
- - CODE_OF_CONDUCT.md
152
+ - CHANGELOG.md
153
153
  - Gemfile
154
154
  - Gemfile.lock
155
- - LICENSE.txt
156
155
  - README.md
157
156
  - Rakefile
158
157
  - benchmarks/prime_numbers.rb
@@ -161,8 +160,8 @@ files:
161
160
  - exe/prime_products
162
161
  - lib/prime_products.rb
163
162
  - lib/prime_products/cli.rb
163
+ - lib/prime_products/multiplication_table.rb
164
164
  - lib/prime_products/prime_numbers.rb
165
- - lib/prime_products/products_table.rb
166
165
  - lib/prime_products/version.rb
167
166
  - prime_products.gemspec
168
167
  homepage:
data/CODE_OF_CONDUCT.md DELETED
@@ -1,74 +0,0 @@
1
- # Contributor Covenant Code of Conduct
2
-
3
- ## Our Pledge
4
-
5
- In the interest of fostering an open and welcoming environment, we as
6
- contributors and maintainers pledge to making participation in our project and
7
- our community a harassment-free experience for everyone, regardless of age, body
8
- size, disability, ethnicity, gender identity and expression, level of experience,
9
- nationality, personal appearance, race, religion, or sexual identity and
10
- orientation.
11
-
12
- ## Our Standards
13
-
14
- Examples of behavior that contributes to creating a positive environment
15
- include:
16
-
17
- * Using welcoming and inclusive language
18
- * Being respectful of differing viewpoints and experiences
19
- * Gracefully accepting constructive criticism
20
- * Focusing on what is best for the community
21
- * Showing empathy towards other community members
22
-
23
- Examples of unacceptable behavior by participants include:
24
-
25
- * The use of sexualized language or imagery and unwelcome sexual attention or
26
- advances
27
- * Trolling, insulting/derogatory comments, and personal or political attacks
28
- * Public or private harassment
29
- * Publishing others' private information, such as a physical or electronic
30
- address, without explicit permission
31
- * Other conduct which could reasonably be considered inappropriate in a
32
- professional setting
33
-
34
- ## Our Responsibilities
35
-
36
- Project maintainers are responsible for clarifying the standards of acceptable
37
- behavior and are expected to take appropriate and fair corrective action in
38
- response to any instances of unacceptable behavior.
39
-
40
- Project maintainers have the right and responsibility to remove, edit, or
41
- reject comments, commits, code, wiki edits, issues, and other contributions
42
- that are not aligned to this Code of Conduct, or to ban temporarily or
43
- permanently any contributor for other behaviors that they deem inappropriate,
44
- threatening, offensive, or harmful.
45
-
46
- ## Scope
47
-
48
- This Code of Conduct applies both within project spaces and in public spaces
49
- when an individual is representing the project or its community. Examples of
50
- representing a project or community include using an official project e-mail
51
- address, posting via an official social media account, or acting as an appointed
52
- representative at an online or offline event. Representation of a project may be
53
- further defined and clarified by project maintainers.
54
-
55
- ## Enforcement
56
-
57
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
- reported by contacting the project team at me@timrogers.co.uk. All
59
- complaints will be reviewed and investigated and will result in a response that
60
- is deemed necessary and appropriate to the circumstances. The project team is
61
- obligated to maintain confidentiality with regard to the reporter of an incident.
62
- Further details of specific enforcement policies may be posted separately.
63
-
64
- Project maintainers who do not follow or enforce the Code of Conduct in good
65
- faith may face temporary or permanent repercussions as determined by other
66
- members of the project's leadership.
67
-
68
- ## Attribution
69
-
70
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
72
-
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 Tim Rogers
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.