jacobat-cyclic 0.0.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.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ == 0.0.1 2009-05-18
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,12 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/cyclic.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_cyclic.rb
11
+ test/test_helper.rb
12
+ website/index.txt
data/PostInstall.txt ADDED
@@ -0,0 +1,7 @@
1
+
2
+ For more information on cyclic, see http://cyclic.rubyforge.org
3
+
4
+ NOTE: Change this information in PostInstall.txt
5
+ You can also delete it if you don't want it.
6
+
7
+
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = cyclic
2
+
3
+ * http://github.com/jacobat/cyclic
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIX (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2009 Jacob Atzen
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
2
+ %w[rake rake/clean fileutils newgem rubigen].each { |f| require f }
3
+ require File.dirname(__FILE__) + '/lib/cyclic'
4
+
5
+ # Generate all the Rake tasks
6
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
7
+ $hoe = Hoe.new('cyclic', Cyclic::VERSION) do |p|
8
+ p.developer('Jacob Atzen', 'jacob@jacobatzen.dk')
9
+ p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
10
+ p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
11
+ p.rubyforge_name = p.name # TODO this is default value
12
+ # p.extra_deps = [
13
+ # ['activesupport','>= 2.0.2'],
14
+ # ]
15
+ p.extra_dev_deps = [
16
+ ['newgem', ">= #{::Newgem::VERSION}"]
17
+ ]
18
+
19
+ p.clean_globs |= %w[**/.DS_Store tmp *.log]
20
+ path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
21
+ p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
22
+ p.rsync_args = '-av --delete --ignore-errors'
23
+ end
24
+
25
+ require 'newgem/tasks' # load /tasks/*.rake
26
+ Dir['tasks/**/*.rake'].each { |t| load t }
27
+
28
+ # TODO - want other tests/tasks run by default? Add them to the list
29
+ # task :default => [:spec, :features]
data/lib/cyclic.rb ADDED
@@ -0,0 +1,25 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ module Cyclic
5
+ VERSION = '0.0.1'
6
+
7
+ class Buffer
8
+ def initialize(size)
9
+ @size = size
10
+ @buffer = []
11
+ end
12
+
13
+ def push(*elements)
14
+ @buffer.push(*elements)
15
+ @buffer = @buffer[-@size, @size] if(@buffer.size > @size)
16
+ end
17
+
18
+ alias_method :<<, :push
19
+
20
+ def read
21
+ @buffer
22
+ end
23
+ end
24
+ end
25
+
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/cyclic.rb'}"
9
+ puts "Loading cyclic gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,55 @@
1
+ require "test/unit"
2
+
3
+ require "cyclic"
4
+
5
+ class TestCyclic < Test::Unit::TestCase
6
+
7
+ def setup
8
+ @buffer = Cyclic::Buffer.new(5)
9
+ end
10
+
11
+ def test_should_put_items_into_buffer
12
+ @buffer.push(1, 2, 3, 4, 5)
13
+ assert_equal([1, 2, 3, 4, 5], @buffer.read)
14
+ end
15
+
16
+ def test_should_cycle_buffer_when_more_items_enter
17
+ @buffer.push(1, 2, 3)
18
+ @buffer.push(4, 5, 6)
19
+ assert_equal([2, 3, 4, 5, 6], @buffer.read)
20
+ end
21
+
22
+ def test_should_allow_more_items_than_buffer_holds
23
+ @buffer.push(*(1..10).to_a)
24
+ assert_equal((6..10).to_a, @buffer.read)
25
+ end
26
+
27
+ def test_should_allow_other_classes_than_fixnums
28
+ words = %w(one two three four five six)
29
+ @buffer.push(*words)
30
+ assert_equal(%w(two three four five six), @buffer.read)
31
+ end
32
+
33
+ def test_should_allow_serialization_to_yaml
34
+ words = %w(one two three four five six)
35
+ @buffer.push(*words)
36
+ new_buffer = YAML::load(YAML::dump(@buffer))
37
+ assert_equal(words[1,5], new_buffer.read)
38
+ end
39
+
40
+ def test_should_allow_pushing_after_deserialization
41
+ words = %w(one two three four five six)
42
+ @buffer.push(*words)
43
+ new_buffer = YAML::load(YAML::dump(@buffer))
44
+ new_buffer.push(*words)
45
+ assert_equal(words[1,5], new_buffer.read)
46
+ end
47
+
48
+ def test_should_have_ltlt_as_alias_for_push
49
+ words = %w(one two three four five six)
50
+ words.each do |word|
51
+ @buffer << word
52
+ end
53
+ assert_equal(words[1,5], @buffer.read)
54
+ end
55
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/cyclic'
data/website/index.txt ADDED
File without changes
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jacobat-cyclic
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jacob Atzen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-18 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: newgem
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 1.4.1
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: hoe
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.8.0
34
+ version:
35
+ description: FIX (describe your package)
36
+ email:
37
+ - jacob@jacobatzen.dk
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - History.txt
44
+ - Manifest.txt
45
+ - PostInstall.txt
46
+ - README.rdoc
47
+ - website/index.txt
48
+ files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - PostInstall.txt
52
+ - README.rdoc
53
+ - Rakefile
54
+ - lib/cyclic.rb
55
+ - script/console
56
+ - script/destroy
57
+ - script/generate
58
+ - test/test_cyclic.rb
59
+ - test/test_helper.rb
60
+ - website/index.txt
61
+ has_rdoc: true
62
+ homepage: http://github.com/jacobat/cyclic
63
+ post_install_message: PostInstall.txt
64
+ rdoc_options:
65
+ - --main
66
+ - README.rdoc
67
+ require_paths:
68
+ - lib
69
+ required_ruby_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: "0"
74
+ version:
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: "0"
80
+ version:
81
+ requirements: []
82
+
83
+ rubyforge_project: cyclic
84
+ rubygems_version: 1.2.0
85
+ signing_key:
86
+ specification_version: 2
87
+ summary: FIX (describe your package)
88
+ test_files:
89
+ - test/test_cyclic.rb
90
+ - test/test_helper.rb