kibo-rb 0.1.4 → 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
  SHA1:
3
- metadata.gz: aa812fe79975eeef4edaed4b21b30b6d6fbb3757
4
- data.tar.gz: 9d15736917ff7068172fe36514be28bcd9ec7763
3
+ metadata.gz: 81e08918d1abe240f0df8f5fafe6e85eb0021e4f
4
+ data.tar.gz: f47b01b2b3e5e0a3ef72c83cdec0963eb9dcb63e
5
5
  SHA512:
6
- metadata.gz: e04809a20416cf895dccda5e156a028361bf26acccab87bd4b0c48de0d0f407d0119f9f12717e2e21de6be1d44e748a0c0a0c66e5550beb11779117626802277
7
- data.tar.gz: 9812e765944cd6628c3558f1bdcca058e138528fb83bab8a361b6e9038dc9fb7b126a0fa7bc02df462118d4836f8fd43668b8cfcdbeea7a92004e12090a023aa
6
+ metadata.gz: 2fd2ff01a978be070c9ad4abaa4b9bdb0163c74f99e2f85755e1233d847e466f627256c2a706df6d29234f3f1eca219be2be09d871feaada35673b15595fb176
7
+ data.tar.gz: 5c30a58f7a7c64cc65c35c4c5f5f7d7ce0e63246735a761d5cda39b5ba8902f483c31b814b5a8a5ad2591ff94e6be958479afd1dd70c3b018a9318895279c9cb
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .DS_Store
11
+ Gemfile.lock
12
+ kibo-rb-0.1.4.gem
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in kibo.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 oelizondo
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.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # Kibo
2
+
3
+ Small API for sorting and finding elements in arrays and other data structures.
4
+
5
+ ###What's so good about it?
6
+
7
+ Almost everything is O(logn) or O(nlogn).
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'kibo'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install kibo
24
+
25
+ ## Usage
26
+
27
+ Kibo is really easy to use, you just have to:
28
+
29
+ ```ruby
30
+ Kibo::Search.bsearch(your_array, your_element)
31
+ ```
32
+
33
+ Kibo also comes with a Native option
34
+
35
+ ```ruby
36
+ require 'kibo_native'
37
+
38
+ a = (1..1_000_000).to_a
39
+ a.binsearch(563_321)
40
+ ```
41
+
42
+ Kibo Native overrides the Array class to include the method ```binsearch``` so you don't have to make additional objects.
43
+ Kibo will return true if the element exists in your array. Right now, ```.sbearch``` method only works wih integers, other data types will come later!
44
+
45
+ ## Benchmarks
46
+
47
+ Write benchmarks
48
+
49
+ ##TODO
50
+
51
+ * Write benchmarks for all methods
52
+ * Wrtie tests for all methods
53
+ * Implement sorts
54
+ * Implement other search methods
55
+
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
60
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "kibo"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/kibo-rb-0.1.4.gem ADDED
Binary file
data/kibo.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'kibo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "kibo-rb"
8
+ spec.version = Kibo::VERSION
9
+ spec.authors = ["oelizondo"]
10
+ spec.email = ["oscarmarcelo95@gmail.com"]
11
+
12
+ spec.summary = %q{Kibo is a small library that implements classic algorithms like binary search, sorts, etc..}
13
+ spec.description = %q{Kibo is a small library that implements classic algorithms like binary search, merge, sort, bubble sorts, etc..}
14
+ spec.homepage = "https://github.com/oelizondo/Kibo"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ if spec.respond_to?(:metadata)
23
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
24
+ else
25
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
26
+ end
27
+
28
+ spec.add_development_dependency "bundler", "~> 1.11"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
@@ -0,0 +1,25 @@
1
+ class Array
2
+ def binsearch(element)
3
+ higher = self.length
4
+ lower = 0
5
+ half = higher / 2
6
+ not_done = true
7
+
8
+ return false if !element.is_a? Integer
9
+ return false if self[self.length-1] < element
10
+
11
+ while not_done
12
+ if element == self[half]
13
+ not_done = false
14
+ elsif element < self[half]
15
+ higher = half
16
+ half = (half - lower) / 2
17
+ else
18
+ lower = half
19
+ half = (higher + lower) / 2
20
+ end
21
+ end
22
+
23
+ true
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ module Kibo
2
+ class Search
3
+
4
+ def self.bsearch(arr, element)
5
+ higher = arr.length
6
+ lower = 0
7
+ half = higher / 2
8
+ not_done = true
9
+
10
+ return false if !element.is_a? Integer
11
+ return false if arr[arr.length-1] < element
12
+
13
+ while not_done
14
+ if element == arr[half]
15
+ not_done = false
16
+ elsif element < arr[half]
17
+ higher = half
18
+ half = (half - lower) / 2
19
+ else
20
+ lower = half
21
+ half = (higher + lower) / 2
22
+ end
23
+ end
24
+
25
+ true
26
+ end
27
+
28
+ end
29
+ end
data/lib/kibo/sort.rb ADDED
@@ -0,0 +1,25 @@
1
+ module Kibo
2
+ class Sort
3
+ def initialize(arr, type)
4
+ case type
5
+ when 'merge'
6
+ eval("Merge.new(#{arr})")
7
+ when 'quick'
8
+ eval("Quick.new(#{arr})")
9
+ end
10
+ end
11
+ end
12
+
13
+ class Merge
14
+ def initialize(arr)
15
+ @arr = arr
16
+ end
17
+ end
18
+
19
+ class Quick
20
+ def initialize(arr)
21
+ @arr = arr
22
+ end
23
+ end
24
+
25
+ end
@@ -0,0 +1,3 @@
1
+ module Kibo
2
+ VERSION = "0.1.5"
3
+ end
data/lib/kibo.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require "kibo/version"
2
2
  require "kibo/search.rb"
3
3
  require "kibo/kibo_native.rb"
4
- #require 'kibo/sort'
5
4
 
6
5
  module Kibo
7
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kibo-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - oelizondo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-15 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -46,11 +46,25 @@ executables: []
46
46
  extensions: []
47
47
  extra_rdoc_files: []
48
48
  files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/console
55
+ - bin/setup
56
+ - kibo-rb-0.1.4.gem
57
+ - kibo.gemspec
49
58
  - lib/kibo.rb
59
+ - lib/kibo/kibo_native.rb
60
+ - lib/kibo/search.rb
61
+ - lib/kibo/sort.rb
62
+ - lib/kibo/version.rb
50
63
  homepage: https://github.com/oelizondo/Kibo
51
64
  licenses:
52
65
  - MIT
53
- metadata: {}
66
+ metadata:
67
+ allowed_push_host: https://rubygems.org
54
68
  post_install_message:
55
69
  rdoc_options: []
56
70
  require_paths: