rdata 0.0.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
19
+
20
+ # Sublime
21
+ *.sublime-*
data/.rvmrc ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional,
7
+ # Only full ruby name is supported here, for short names use:
8
+ # echo "rvm use 1.9.3" > .rvmrc
9
+ environment_id="ruby-1.9.3-p194@rdata"
10
+
11
+ # Uncomment the following lines if you want to verify rvm version per project
12
+ # rvmrc_rvm_version="1.17.0 (stable)" # 1.10.1 seams as a safe start
13
+ # eval "$(echo ${rvm_version}.${rvmrc_rvm_version} | awk -F. '{print "[[ "$1*65536+$2*256+$3" -ge "$4*65536+$5*256+$6" ]]"}' )" || {
14
+ # echo "This .rvmrc file requires at least RVM ${rvmrc_rvm_version}, aborting loading."
15
+ # return 1
16
+ # }
17
+
18
+ # First we attempt to load the desired environment directly from the environment
19
+ # file. This is very fast and efficient compared to running through the entire
20
+ # CLI and selector. If you want feedback on which environment was used then
21
+ # insert the word 'use' after --create as this triggers verbose mode.
22
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments"
23
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
24
+ then
25
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
26
+ [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]] &&
27
+ \. "${rvm_path:-$HOME/.rvm}/hooks/after_use" || true
28
+ else
29
+ # If the environment file has not yet been created, use the RVM CLI to select.
30
+ rvm --create "$environment_id" || {
31
+ echo "Failed to create RVM environment '${environment_id}'."
32
+ return 1
33
+ }
34
+ fi
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
@@ -0,0 +1,26 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rdata (0.2.0)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rake (10.0.2)
11
+ rspec (2.12.0)
12
+ rspec-core (~> 2.12.0)
13
+ rspec-expectations (~> 2.12.0)
14
+ rspec-mocks (~> 2.12.0)
15
+ rspec-core (2.12.0)
16
+ rspec-expectations (2.12.0)
17
+ diff-lcs (~> 1.1.3)
18
+ rspec-mocks (2.12.0)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ rake
25
+ rdata!
26
+ rspec
File without changes
@@ -0,0 +1,36 @@
1
+ # RData
2
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/samdunne/rdata)
3
+ [![Build Status](https://secure.travis-ci.org/samdunne/rdata.png?branch=master)](https://travis-ci.org/samdunne/rdata)
4
+
5
+ ## Installation
6
+ ```ruby
7
+ gem install rdata
8
+ ```
9
+
10
+ Or in a Gemfile
11
+
12
+ ```ruby
13
+ gem 'rdata'
14
+ ```
15
+
16
+ ## Usage
17
+ ```ruby
18
+ require 'rdata'
19
+ ```
20
+
21
+ ## Stacks
22
+
23
+ ### Initialization
24
+
25
+ ```ruby
26
+ @stack = RData.Stack
27
+ ```
28
+
29
+ ### Operations
30
+
31
+ ```ruby
32
+ @stack.push(x) # => Returns 'x'
33
+ @stack.pop # => Returns 'top'
34
+ @stack.top # => Returns 'top'
35
+ @stack.is_empty? # => Returns true/false
36
+ ```
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -1,5 +1,8 @@
1
- class RData
2
- def self.hi
3
- puts "Hello world!"
4
- end
1
+ require 'rdata/version'
2
+ require "rdata/stack.rb"
3
+
4
+ module RData
5
+ def self.Stack
6
+ Stack.new
7
+ end
5
8
  end
File without changes
@@ -0,0 +1,23 @@
1
+ module RData
2
+
3
+ class Queue
4
+
5
+ def initialize
6
+ @queue = Array[]
7
+ @head, @tail = 0
8
+ end
9
+
10
+ def enqueue(x)
11
+ @queue[@tail] = x
12
+ @tail = (@tail == @length) ? 1 : @tail - 1
13
+ end
14
+
15
+ def dequeue
16
+ x = @head
17
+ @head = (@head == @length) ? 1 : @head + 1
18
+ return x
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,44 @@
1
+ =begin
2
+
3
+ This is the Stack class. It allows easy implementation of stacks and use of their operations
4
+
5
+ # @stack = RData.Stack
6
+ # @stack.operation
7
+ # ... etc ...
8
+
9
+ =end
10
+
11
+ module RData
12
+
13
+ class Stack
14
+
15
+ def initialize
16
+ @stack = Array[]
17
+ @top = 0
18
+ end
19
+
20
+ def top
21
+ return @stack[@top]
22
+ end
23
+
24
+ def push(x)
25
+ @top = @top + 1
26
+ @stack[@top] = x
27
+ end
28
+
29
+ def pop
30
+ if self.is_empty? == "true"
31
+ raise '[underflow] Cannot pop data from an empty stack'
32
+ else
33
+ @top = @top - 1
34
+ return @stack[@top + 1]
35
+ end
36
+ end
37
+
38
+ def is_empty?
39
+ (@top == 0) ? 'true' : 'false'
40
+ end
41
+
42
+ end
43
+
44
+ end
@@ -0,0 +1,3 @@
1
+ module RData
2
+ VERSION = "0.2.0"
3
+ end
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ $:.push File.expand_path("../lib", __FILE__)
4
+
5
+ require "rdata/version"
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = 'rdata'
9
+ s.version = RData::VERSION
10
+ s.authors = ["Sam Dunne"]
11
+ s.email = ['sam@sam-dunne.com']
12
+ s.date = '2012-11-28'
13
+ s.homepage = 'https://github.com/samdunne/rdata'
14
+ s.summary = "Common Datastructures in Ruby"
15
+ s.description = "A datastructures library for ruby"
16
+
17
+
18
+ s.files = `git ls-files`.split("\n")
19
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
20
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
+ s.require_paths = ["lib"]
22
+
23
+ s.add_development_dependency 'rake'
24
+ s.add_development_dependency 'rspec'
25
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe RData do
4
+ it "should return data for a stack" do
5
+ element_data = RData.Stack
6
+ #element_data.should be_nil
7
+ element_data.push(1).should == 1
8
+ element_data.pop.should == 1
9
+ element_data.is_empty?.should be_true
10
+ end
11
+ end
@@ -0,0 +1 @@
1
+ require 'rdata'
data/version ADDED
File without changes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdata
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,14 +10,62 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
  date: 2012-11-28 00:00:00.000000000 Z
13
- dependencies: []
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
14
46
  description: A datastructures library for ruby
15
- email: sam@sam-dunne.com
47
+ email:
48
+ - sam@sam-dunne.com
16
49
  executables: []
17
50
  extensions: []
18
51
  extra_rdoc_files: []
19
52
  files:
53
+ - .gitignore
54
+ - .rvmrc
55
+ - Gemfile
56
+ - Gemfile.lock
57
+ - LICENSE.txt
58
+ - README.md
59
+ - Rakefile
20
60
  - lib/rdata.rb
61
+ - lib/rdata/linked_lists.rb
62
+ - lib/rdata/queue.rb
63
+ - lib/rdata/stack.rb
64
+ - lib/rdata/version.rb
65
+ - rdata.gemspec
66
+ - spec/rdata_spec.rb
67
+ - spec/spec_helper.rb
68
+ - version
21
69
  homepage: https://github.com/samdunne/rdata
22
70
  licenses: []
23
71
  post_install_message:
@@ -30,16 +78,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
30
78
  - - ! '>='
31
79
  - !ruby/object:Gem::Version
32
80
  version: '0'
81
+ segments:
82
+ - 0
83
+ hash: 1130484059901550349
33
84
  required_rubygems_version: !ruby/object:Gem::Requirement
34
85
  none: false
35
86
  requirements:
36
87
  - - ! '>='
37
88
  - !ruby/object:Gem::Version
38
89
  version: '0'
90
+ segments:
91
+ - 0
92
+ hash: 1130484059901550349
39
93
  requirements: []
40
94
  rubyforge_project:
41
95
  rubygems_version: 1.8.24
42
96
  signing_key:
43
97
  specification_version: 3
44
98
  summary: Common Datastructures in Ruby
45
- test_files: []
99
+ test_files:
100
+ - spec/rdata_spec.rb
101
+ - spec/spec_helper.rb