primes-utils 1.0.1 → 1.0.2

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
  SHA1:
3
- metadata.gz: 25b2ae668e65792c80d4ac4b920c48f769d81536
4
- data.tar.gz: c5c4458b63c7865b8929fd85734dad1dd0b57c0e
3
+ metadata.gz: 3e261f1f23f43554136ce43468417e9f32064458
4
+ data.tar.gz: a5967146da4d22f3ac4c06791da236f14eac123a
5
5
  SHA512:
6
- metadata.gz: 29fb66f3b01e551576df95d57ff7321ee5d919d0d494f145e7d5e2d53538802e2f497d4ed4d130981a826153f904ff3c1648fd174135732077b25d82598df396
7
- data.tar.gz: c81e947ae5a70024cd3cf1928551d92abc00f8efcc32c85bf9ade7bd60e96e745e205129066d5f97588c31fd3a8ed74153e506ffacdc6df63d5591325787124d
6
+ metadata.gz: 74603be0a2f1ef0c3b486e4aa002d09910b22ec5883f970e5f93ae2cf7bde19db0ebd623db0b38505a5506319b3129e95f14bcb9cd2c8b2be633f223010dc253
7
+ data.tar.gz: db37760451a0d10a5ec5ff8e8074c90d986bd585133e19534d5bf2d977c726f789ad7d7fdbba8e79146f1032079dfc5b5efcc55bdbf4ad0b38173dc46758b546
data/README.md CHANGED
@@ -17,6 +17,10 @@ And then execute:
17
17
  Or install it yourself as:
18
18
 
19
19
  $ gem install primes-utils
20
+
21
+ Then require as:
22
+
23
+ require 'primes/utils'
20
24
 
21
25
  ## Methods
22
26
 
@@ -86,11 +90,9 @@ Each has a pure ruby implementation, and also a hybrid implementation which uses
86
90
  Unix cli command `factor` if its available on the host OS. `factor` [5] is an extremely fast
87
91
  C coded factoring algorithm, part of the GNU Core Utilities package [4].
88
92
 
89
- Upon loading, the gem tests if the host `RUBY_PLATFORM` value is contained in a list
90
- of known OSes which has the `factor` command. If so, it wraps a system call to `factor` and uses
91
- it for `prime?` and `prime_division/factors`. If not, it uses a fast pure ruby implementation for
92
- each method based on the Sieve of Zakiya (SoZ)[1][2][3]. OSes not on the list that have `factor`
93
- can be added to the `factor_platforms` array to accommodate them.
93
+ Upon loading, the gem tests if the desired `factor` command exists on the host OS.
94
+ If so, it wraps a system call to it and uses it for `prime?` and `prime_division/factors`.
95
+ If not, it uses a fast pure ruby implementation for each method based on the Sieve of Zakiya (SoZ)[1][2][3].
94
96
 
95
97
  ## Author
96
98
  Jabari Zakiya
@@ -1,12 +1,17 @@
1
1
  require "primes/utils/version"
2
-
3
2
  require 'rational' if RUBY_VERSION =~ /^(1.8)/ # for 'gcd' method
4
3
 
5
4
  module Primes
6
5
  module Utils
7
6
  private
8
- factor_platforms = %w/linux bsd unix/
9
- os_has_factor = factor_platforms.any? {|p| RUBY_PLATFORM.match(p)}
7
+ os_has_factor = false
8
+ begin
9
+ if `factor 10`.split(' ') == ["10:", "2", "5"]
10
+ os_has_factor = true
11
+ end
12
+ rescue
13
+ os_has_factor = false
14
+ end}
10
15
 
11
16
  public
12
17
  if os_has_factor # for platforms with cli 'factor' command
@@ -1,5 +1,5 @@
1
1
  module Primes
2
2
  module Utils
3
- VERSION = "1.0.1"
3
+ VERSION = "1.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: primes-utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jabari Zakiya
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-01 00:00:00.000000000 Z
11
+ date: 2015-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
+ prerelease: false
15
16
  requirement: !ruby/object:Gem::Requirement
16
17
  requirements:
17
18
  - - "~>"
18
19
  - !ruby/object:Gem::Version
19
20
  version: '1.9'
20
- type: :development
21
- prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - "~>"
25
24
  - !ruby/object:Gem::Version
26
25
  version: '1.9'
26
+ type: :development
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
+ prerelease: false
29
30
  requirement: !ruby/object:Gem::Requirement
30
31
  requirements:
31
32
  - - "~>"
32
33
  - !ruby/object:Gem::Version
33
34
  version: '10.0'
34
- type: :development
35
- prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - "~>"
39
38
  - !ruby/object:Gem::Version
40
39
  version: '10.0'
40
+ type: :development
41
41
  description: 'Methods: prime?, primemr?, primes, nthprime/primenth, factors/prime_division'
42
42
  email:
43
43
  - jzakiya@gmail.com