bicycle 0.3.1 → 0.4.0
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 +4 -4
- data/.rubocop.yml +25 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -0
- data/Gemfile +3 -6
- data/Gemfile.lock +26 -28
- data/Rakefile +15 -15
- data/VERSION +1 -1
- data/bicycle.gemspec +34 -26
- data/lib/bicycle.rb +3 -3
- data/lib/bicycle/methods.rb +96 -0
- data/test/helper.rb +11 -11
- data/test/test_bicycle.rb +94 -92
- metadata +39 -20
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 631d1e80fe359b6d80d4b64264de0372f1544ab0
|
|
4
|
+
data.tar.gz: 6f60649c7788282ec14d9389f6af08cb382a9d26
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8ad62188f06498b4e3e9c4c328803ef8ea88efb269fbcac3fec8bc703ca164ae97ea2c0d39d33c9296e7582c9fa3502120317eef0be2c49e34c0b71240f64bb
|
|
7
|
+
data.tar.gz: 0d477808fabe2fc9ebe54e91375ea5fec2f0fa8b1d4bfb8c34fba9328bc092596870303f9219a47f7cefe2c496252f0804c27c7deb32ed4662cd0c52d638cd0a
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 2.4
|
|
3
|
+
|
|
4
|
+
# Use double quotes ALL THE TIME!!!
|
|
5
|
+
Style/StringLiterals:
|
|
6
|
+
EnforcedStyle: double_quotes
|
|
7
|
+
|
|
8
|
+
# Disable Style/Documentation because...
|
|
9
|
+
Style/Documentation:
|
|
10
|
+
Enabled: false
|
|
11
|
+
|
|
12
|
+
# Increase line length to 120
|
|
13
|
+
Metrics/LineLength:
|
|
14
|
+
Max: 120
|
|
15
|
+
|
|
16
|
+
# Exclude class and method length for test
|
|
17
|
+
Metrics/BlockLength:
|
|
18
|
+
Exclude:
|
|
19
|
+
- "test/**/*"
|
|
20
|
+
Metrics/ClassLength:
|
|
21
|
+
Exclude:
|
|
22
|
+
- "test/**/*"
|
|
23
|
+
Metrics/MethodLength:
|
|
24
|
+
Exclude:
|
|
25
|
+
- "test/**/*"
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bicycle
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.4.2
|
data/.travis.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
language: ruby
|
data/Gemfile
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source "http://rubygems.org"
|
|
2
|
-
# Add dependencies required to use your gem here.
|
|
3
|
-
# Example:
|
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
|
5
4
|
|
|
6
|
-
# Add dependencies to develop your gem here.
|
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
|
8
5
|
group :development do
|
|
9
6
|
gem "bundler"
|
|
10
7
|
gem "jeweler"
|
|
11
8
|
gem "minitest"
|
|
12
9
|
gem "turn"
|
|
13
10
|
gem "yard"
|
|
14
|
-
end
|
|
11
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
GEM
|
|
2
2
|
remote: http://rubygems.org/
|
|
3
3
|
specs:
|
|
4
|
-
addressable (2.
|
|
5
|
-
public_suffix (~> 2.0, >= 2.0.2)
|
|
4
|
+
addressable (2.4.0)
|
|
6
5
|
ansi (1.5.0)
|
|
7
6
|
builder (3.2.3)
|
|
8
7
|
descendants_tracker (0.0.4)
|
|
@@ -10,52 +9,51 @@ GEM
|
|
|
10
9
|
faraday (0.9.2)
|
|
11
10
|
multipart-post (>= 1.2, < 3)
|
|
12
11
|
git (1.3.0)
|
|
13
|
-
github_api (0.
|
|
14
|
-
addressable (~> 2.
|
|
15
|
-
descendants_tracker (~> 0.0.
|
|
12
|
+
github_api (0.16.0)
|
|
13
|
+
addressable (~> 2.4.0)
|
|
14
|
+
descendants_tracker (~> 0.0.4)
|
|
16
15
|
faraday (~> 0.8, < 0.10)
|
|
17
|
-
hashie (>=
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
jeweler (2.3.3)
|
|
16
|
+
hashie (>= 3.4)
|
|
17
|
+
mime-types (>= 1.16, < 3.0)
|
|
18
|
+
oauth2 (~> 1.0)
|
|
19
|
+
hashie (3.5.7)
|
|
20
|
+
highline (1.7.10)
|
|
21
|
+
jeweler (2.3.9)
|
|
24
22
|
builder
|
|
25
|
-
bundler
|
|
23
|
+
bundler
|
|
26
24
|
git (>= 1.2.5)
|
|
27
|
-
github_api (~> 0.
|
|
25
|
+
github_api (~> 0.16.0)
|
|
28
26
|
highline (>= 1.6.15)
|
|
29
27
|
nokogiri (>= 1.5.10)
|
|
30
|
-
psych
|
|
28
|
+
psych
|
|
31
29
|
rake
|
|
32
30
|
rdoc
|
|
33
31
|
semver2
|
|
34
32
|
jwt (1.5.6)
|
|
35
|
-
|
|
33
|
+
mime-types (2.99.3)
|
|
34
|
+
mini_portile2 (2.3.0)
|
|
36
35
|
minitest (4.7.5)
|
|
37
|
-
multi_json (1.
|
|
36
|
+
multi_json (1.13.1)
|
|
38
37
|
multi_xml (0.6.0)
|
|
39
38
|
multipart-post (2.0.0)
|
|
40
|
-
nokogiri (1.
|
|
41
|
-
mini_portile2 (~> 2.
|
|
42
|
-
oauth2 (1.
|
|
43
|
-
faraday (>= 0.8, < 0.
|
|
39
|
+
nokogiri (1.8.2)
|
|
40
|
+
mini_portile2 (~> 2.3.0)
|
|
41
|
+
oauth2 (1.4.0)
|
|
42
|
+
faraday (>= 0.8, < 0.13)
|
|
44
43
|
jwt (~> 1.0)
|
|
45
44
|
multi_json (~> 1.3)
|
|
46
45
|
multi_xml (~> 0.5)
|
|
47
46
|
rack (>= 1.2, < 3)
|
|
48
|
-
psych (
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
rdoc (5.1.0)
|
|
47
|
+
psych (3.0.2)
|
|
48
|
+
rack (2.0.4)
|
|
49
|
+
rake (12.3.1)
|
|
50
|
+
rdoc (6.0.3)
|
|
53
51
|
semver2 (3.4.2)
|
|
54
52
|
thread_safe (0.3.6)
|
|
55
53
|
turn (0.9.7)
|
|
56
54
|
ansi
|
|
57
55
|
minitest (~> 4)
|
|
58
|
-
yard (0.9.
|
|
56
|
+
yard (0.9.12)
|
|
59
57
|
|
|
60
58
|
PLATFORMS
|
|
61
59
|
ruby
|
|
@@ -68,4 +66,4 @@ DEPENDENCIES
|
|
|
68
66
|
yard
|
|
69
67
|
|
|
70
68
|
BUNDLED WITH
|
|
71
|
-
1.
|
|
69
|
+
1.16.1
|
data/Rakefile
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "rubygems"
|
|
4
|
+
require "bundler"
|
|
5
5
|
begin
|
|
6
6
|
Bundler.setup(:default, :development)
|
|
7
7
|
rescue Bundler::BundlerError => e
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
warn e.message
|
|
9
|
+
warn "Run `bundle install` to install missing gems"
|
|
10
10
|
exit e.status_code
|
|
11
11
|
end
|
|
12
|
-
require
|
|
12
|
+
require "rake"
|
|
13
13
|
|
|
14
|
-
require
|
|
14
|
+
require "jeweler"
|
|
15
15
|
Jeweler::Tasks.new do |gem|
|
|
16
16
|
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
17
17
|
gem.name = "bicycle"
|
|
18
18
|
gem.homepage = "http://github.com/sleepingstu/bicycle"
|
|
19
19
|
gem.license = "MIT"
|
|
20
|
-
gem.summary = %
|
|
21
|
-
gem.description = %
|
|
20
|
+
gem.summary = %(Why walk when you can cycle)
|
|
21
|
+
gem.description = %(A convenience gem for cycling through a set of values, ported from the 'cycle' functionality found in Rails. It is independent of which framework you use so will run in Sinatra, Padrino or straight up Ruby itself.)
|
|
22
22
|
gem.email = "stuart.chinery@headlondon.com"
|
|
23
23
|
gem.authors = ["Stuart Chinery", "Dave Hrycyszyn"]
|
|
24
24
|
# dependencies defined in Gemfile
|
|
25
25
|
end
|
|
26
26
|
Jeweler::RubygemsDotOrgTasks.new
|
|
27
27
|
|
|
28
|
-
require
|
|
28
|
+
require "rake/testtask"
|
|
29
29
|
Rake::TestTask.new(:test) do |test|
|
|
30
|
-
test.libs <<
|
|
31
|
-
test.pattern =
|
|
30
|
+
test.libs << "lib" << "test"
|
|
31
|
+
test.pattern = "test/**/test_*.rb"
|
|
32
32
|
test.verbose = true
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
task :
|
|
35
|
+
task default: :test
|
|
36
36
|
|
|
37
|
-
require
|
|
38
|
-
YARD::Rake::YardocTask.new
|
|
37
|
+
require "yard"
|
|
38
|
+
YARD::Rake::YardocTask.new
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.4.0
|
data/bicycle.gemspec
CHANGED
|
@@ -2,23 +2,28 @@
|
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
|
-
|
|
5
|
+
# stub: bicycle 0.4.0 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
|
-
s.name = "bicycle"
|
|
9
|
-
s.version =
|
|
8
|
+
s.name = "bicycle".freeze
|
|
9
|
+
s.version = "0.4.0"
|
|
10
10
|
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
-
s.
|
|
13
|
-
s.
|
|
14
|
-
s.
|
|
15
|
-
s.
|
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
|
+
s.require_paths = ["lib".freeze]
|
|
13
|
+
s.authors = ["Stuart Chinery".freeze, "Dave Hrycyszyn".freeze]
|
|
14
|
+
s.date = "2018-04-04"
|
|
15
|
+
s.description = "A convenience gem for cycling through a set of values, ported from the 'cycle' functionality found in Rails. It is independent of which framework you use so will run in Sinatra, Padrino or straight up Ruby itself.".freeze
|
|
16
|
+
s.email = "stuart.chinery@headlondon.com".freeze
|
|
16
17
|
s.extra_rdoc_files = [
|
|
17
18
|
"LICENSE.txt",
|
|
18
19
|
"README.md"
|
|
19
20
|
]
|
|
20
21
|
s.files = [
|
|
21
22
|
".document",
|
|
23
|
+
".rubocop.yml",
|
|
24
|
+
".ruby-gemset",
|
|
25
|
+
".ruby-version",
|
|
26
|
+
".travis.yml",
|
|
22
27
|
"Gemfile",
|
|
23
28
|
"Gemfile.lock",
|
|
24
29
|
"LICENSE.txt",
|
|
@@ -27,34 +32,37 @@ Gem::Specification.new do |s|
|
|
|
27
32
|
"VERSION",
|
|
28
33
|
"bicycle.gemspec",
|
|
29
34
|
"lib/bicycle.rb",
|
|
35
|
+
"lib/bicycle/methods.rb",
|
|
30
36
|
"test/helper.rb",
|
|
31
37
|
"test/test_bicycle.rb"
|
|
32
38
|
]
|
|
33
|
-
s.homepage = "http://github.com/sleepingstu/bicycle"
|
|
34
|
-
s.licenses = ["MIT"]
|
|
35
|
-
s.
|
|
36
|
-
s.
|
|
37
|
-
s.summary = "Why walk when you can cycle"
|
|
39
|
+
s.homepage = "http://github.com/sleepingstu/bicycle".freeze
|
|
40
|
+
s.licenses = ["MIT".freeze]
|
|
41
|
+
s.rubygems_version = "2.6.13".freeze
|
|
42
|
+
s.summary = "Why walk when you can cycle".freeze
|
|
38
43
|
|
|
39
44
|
if s.respond_to? :specification_version then
|
|
40
|
-
s.specification_version =
|
|
45
|
+
s.specification_version = 4
|
|
41
46
|
|
|
42
47
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
43
|
-
s.add_development_dependency(%q<
|
|
44
|
-
s.add_development_dependency(%q<
|
|
45
|
-
s.add_development_dependency(%q<
|
|
46
|
-
s.add_development_dependency(%q<
|
|
48
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
|
49
|
+
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
|
50
|
+
s.add_development_dependency(%q<minitest>.freeze, [">= 0"])
|
|
51
|
+
s.add_development_dependency(%q<turn>.freeze, [">= 0"])
|
|
52
|
+
s.add_development_dependency(%q<yard>.freeze, [">= 0"])
|
|
47
53
|
else
|
|
48
|
-
s.add_dependency(%q<
|
|
49
|
-
s.add_dependency(%q<
|
|
50
|
-
s.add_dependency(%q<
|
|
51
|
-
s.add_dependency(%q<
|
|
54
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
|
55
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
|
56
|
+
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
|
57
|
+
s.add_dependency(%q<turn>.freeze, [">= 0"])
|
|
58
|
+
s.add_dependency(%q<yard>.freeze, [">= 0"])
|
|
52
59
|
end
|
|
53
60
|
else
|
|
54
|
-
s.add_dependency(%q<
|
|
55
|
-
s.add_dependency(%q<
|
|
56
|
-
s.add_dependency(%q<
|
|
57
|
-
s.add_dependency(%q<
|
|
61
|
+
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
|
62
|
+
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
|
63
|
+
s.add_dependency(%q<minitest>.freeze, [">= 0"])
|
|
64
|
+
s.add_dependency(%q<turn>.freeze, [">= 0"])
|
|
65
|
+
s.add_dependency(%q<yard>.freeze, [">= 0"])
|
|
58
66
|
end
|
|
59
67
|
end
|
|
60
68
|
|
data/lib/bicycle.rb
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bicycle
|
|
4
|
+
module Methods
|
|
5
|
+
# Creates a Cycle object whose _to_s_ method cycles through elements of an
|
|
6
|
+
# array every time it is called. This can be used for example, to alternate
|
|
7
|
+
# classes for table rows. You can use named cycles to allow nesting in loops.
|
|
8
|
+
# Passing a Hash as the last parameter with a <tt>:name</tt> key will create a
|
|
9
|
+
# named cycle. The default name for a cycle without a +:name+ key is
|
|
10
|
+
# <tt>"default"</tt>. You can manually reset a cycle by calling reset_cycle
|
|
11
|
+
# and passing the name of the cycle. The current cycle string can be obtained
|
|
12
|
+
# anytime using the current_cycle method.
|
|
13
|
+
#
|
|
14
|
+
def cycle(*values)
|
|
15
|
+
if values.last.instance_of? Hash
|
|
16
|
+
params = values.pop
|
|
17
|
+
name = params[:name]
|
|
18
|
+
else
|
|
19
|
+
name = "default"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
cycle = get_cycle(name)
|
|
23
|
+
cycle = set_cycle(name, Cycle.new(values)) unless cycle && cycle.values == values
|
|
24
|
+
cycle.to_s
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
# Returns the current cycle string after a cycle has been started. Useful
|
|
28
|
+
# for complex table highlighting or any other design need which requires
|
|
29
|
+
# the current cycle string in more than one place.
|
|
30
|
+
#
|
|
31
|
+
def current_cycle(name = "default")
|
|
32
|
+
cycle = get_cycle(name)
|
|
33
|
+
cycle&.current_value
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
# Resets a cycle so that it starts from the first element the next time
|
|
37
|
+
# it is called. Pass in +name+ to reset a named cycle.
|
|
38
|
+
#
|
|
39
|
+
def reset_cycle(name = "default")
|
|
40
|
+
cycle = get_cycle(name)
|
|
41
|
+
cycle&.reset
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
class Cycle #:nodoc:
|
|
45
|
+
attr_reader :values
|
|
46
|
+
|
|
47
|
+
def initialize(values)
|
|
48
|
+
@values = values
|
|
49
|
+
reset
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def reset
|
|
53
|
+
@index = 0
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def current_value
|
|
57
|
+
@values[previous_index].to_s
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def to_s
|
|
61
|
+
value = @values[@index].to_s
|
|
62
|
+
@index = next_index
|
|
63
|
+
value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
private
|
|
67
|
+
|
|
68
|
+
def next_index
|
|
69
|
+
step_index(1)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def previous_index
|
|
73
|
+
step_index(-1)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def step_index(num)
|
|
77
|
+
(@index + num) % @values.size
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
# The cycle helpers need to store the cycles in a place that is
|
|
84
|
+
# guaranteed to be reset every time a page is rendered, so it
|
|
85
|
+
# uses an instance variable of ActionView::Base.
|
|
86
|
+
def get_cycle(name)
|
|
87
|
+
@_cycles = {} unless defined?(@_cycles)
|
|
88
|
+
@_cycles[name]
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def set_cycle(name, cycle_object)
|
|
92
|
+
@_cycles = {} unless defined?(@_cycles)
|
|
93
|
+
@_cycles[name] = cycle_object
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
end
|
data/test/helper.rb
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rubygems"
|
|
4
|
+
require "bundler"
|
|
3
5
|
begin
|
|
4
6
|
Bundler.setup(:default, :development)
|
|
5
7
|
rescue Bundler::BundlerError => e
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
warn e.message
|
|
9
|
+
warn "Run `bundle install` to install missing gems"
|
|
8
10
|
exit e.status_code
|
|
9
11
|
end
|
|
10
12
|
|
|
11
|
-
require
|
|
13
|
+
require "minitest/autorun"
|
|
12
14
|
|
|
13
15
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
14
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),
|
|
15
|
-
require
|
|
16
|
-
begin; require
|
|
17
|
-
|
|
16
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
|
17
|
+
require "bicycle"
|
|
18
|
+
begin; require "turn/autorun"; rescue LoadError; end
|
|
18
19
|
class MiniTest::Unit::TestCase
|
|
19
|
-
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
MiniTest::Unit.autorun
|
|
22
|
+
MiniTest::Unit.autorun
|
data/test/test_bicycle.rb
CHANGED
|
@@ -1,107 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "helper"
|
|
2
4
|
include Bicycle
|
|
3
5
|
|
|
4
6
|
describe "When cycling" do
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
7
|
+
describe "with values" do
|
|
8
|
+
before do
|
|
9
|
+
@values = []
|
|
10
|
+
(0..3).each do |i|
|
|
11
|
+
@values[i] = cycle("Foo", "Bar", "Huh?")
|
|
12
|
+
end
|
|
13
|
+
end
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
it "should return a value in the cycle order" do
|
|
16
|
+
assert_equal "Foo", @values[0]
|
|
17
|
+
assert_equal "Bar", @values[1]
|
|
18
|
+
assert_equal "Huh?", @values[2]
|
|
19
|
+
assert_equal "Foo", @values[3]
|
|
20
|
+
end
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
describe "and with new values" do
|
|
23
|
+
before do
|
|
24
|
+
@values = []
|
|
25
|
+
(0..5).each do |i|
|
|
26
|
+
@values[i] = cycle("I", "just", "want", "to", "ride", name: "bikes")
|
|
27
|
+
end
|
|
28
|
+
end
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
30
|
+
it "should return a new value in the cycle order" do
|
|
31
|
+
assert_equal "I", @values[0]
|
|
32
|
+
assert_equal "just", @values[1]
|
|
33
|
+
assert_equal "want", @values[2]
|
|
34
|
+
assert_equal "to", @values[3]
|
|
35
|
+
assert_equal "ride", @values[4]
|
|
36
|
+
assert_equal "I", @values[0]
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
describe "with multiple instances in one loop" do
|
|
42
|
+
before do
|
|
43
|
+
@values = []
|
|
44
|
+
@sub_values = []
|
|
45
|
+
(0..3).each do |i|
|
|
46
|
+
@values[i] = cycle("Foo", "Bar", "Huh?")
|
|
45
47
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
value = []
|
|
49
|
+
(0..5).each do |j|
|
|
50
|
+
value[j] = cycle("I", "just", "want", "to", "ride", name: "bikes")
|
|
51
|
+
end
|
|
52
|
+
@sub_values[i] = value
|
|
51
53
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
54
|
+
reset_cycle("bikes")
|
|
55
|
+
end
|
|
56
|
+
end
|
|
55
57
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
it "should return a value from the first cycle order" do
|
|
59
|
+
assert_equal "Foo", @values[0]
|
|
60
|
+
assert_equal "Bar", @values[1]
|
|
61
|
+
assert_equal "Huh?", @values[2]
|
|
62
|
+
assert_equal "Foo", @values[3]
|
|
63
|
+
end
|
|
62
64
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
65
|
+
it "should return a value from the first bike cycle order" do
|
|
66
|
+
assert_equal "I", @sub_values[0][0]
|
|
67
|
+
assert_equal "just", @sub_values[0][1]
|
|
68
|
+
assert_equal "want", @sub_values[0][2]
|
|
69
|
+
assert_equal "to", @sub_values[0][3]
|
|
70
|
+
assert_equal "ride", @sub_values[0][4]
|
|
71
|
+
assert_equal "I", @sub_values[0][0]
|
|
72
|
+
end
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
it "should return a value from the second bike cycle order" do
|
|
75
|
+
assert_equal "I", @sub_values[1][0]
|
|
76
|
+
assert_equal "just", @sub_values[1][1]
|
|
77
|
+
assert_equal "want", @sub_values[1][2]
|
|
78
|
+
assert_equal "to", @sub_values[1][3]
|
|
79
|
+
assert_equal "ride", @sub_values[1][4]
|
|
80
|
+
assert_equal "I", @sub_values[1][0]
|
|
81
|
+
end
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
it "should return a value from the third bike cycle order" do
|
|
84
|
+
assert_equal "I", @sub_values[2][0]
|
|
85
|
+
assert_equal "just", @sub_values[2][1]
|
|
86
|
+
assert_equal "want", @sub_values[2][2]
|
|
87
|
+
assert_equal "to", @sub_values[2][3]
|
|
88
|
+
assert_equal "ride", @sub_values[2][4]
|
|
89
|
+
assert_equal "I", @sub_values[2][0]
|
|
90
|
+
end
|
|
91
|
+
end
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
describe "finding its current cycle" do
|
|
94
|
+
before do
|
|
95
|
+
@values = []
|
|
96
|
+
@current = []
|
|
97
|
+
(0..5).each do |i|
|
|
98
|
+
@values[i] = cycle("I", "just", "want", "to", "ride")
|
|
99
|
+
@current[i] = current_cycle
|
|
100
|
+
end
|
|
101
|
+
end
|
|
100
102
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
end
|
|
103
|
+
it "should match whats cycled" do
|
|
104
|
+
(0..5).each do |i|
|
|
105
|
+
assert_equal @values[i], @current[i]
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bicycle
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stuart Chinery
|
|
@@ -9,64 +9,78 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2018-04-04 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
|
-
name:
|
|
15
|
+
name: bundler
|
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
|
17
17
|
requirements:
|
|
18
|
-
- - "
|
|
18
|
+
- - ">="
|
|
19
19
|
- !ruby/object:Gem::Version
|
|
20
20
|
version: '0'
|
|
21
21
|
type: :development
|
|
22
22
|
prerelease: false
|
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
|
24
24
|
requirements:
|
|
25
|
-
- - "
|
|
25
|
+
- - ">="
|
|
26
26
|
- !ruby/object:Gem::Version
|
|
27
27
|
version: '0'
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
|
-
name:
|
|
29
|
+
name: jeweler
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
31
31
|
requirements:
|
|
32
|
-
- - "
|
|
32
|
+
- - ">="
|
|
33
33
|
- !ruby/object:Gem::Version
|
|
34
|
-
version: '0
|
|
34
|
+
version: '0'
|
|
35
35
|
type: :development
|
|
36
36
|
prerelease: false
|
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
|
38
38
|
requirements:
|
|
39
|
-
- - "
|
|
39
|
+
- - ">="
|
|
40
40
|
- !ruby/object:Gem::Version
|
|
41
|
-
version: '0
|
|
41
|
+
version: '0'
|
|
42
42
|
- !ruby/object:Gem::Dependency
|
|
43
|
-
name:
|
|
43
|
+
name: minitest
|
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
|
45
45
|
requirements:
|
|
46
|
-
- - "
|
|
46
|
+
- - ">="
|
|
47
47
|
- !ruby/object:Gem::Version
|
|
48
48
|
version: '0'
|
|
49
49
|
type: :development
|
|
50
50
|
prerelease: false
|
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
|
52
52
|
requirements:
|
|
53
|
-
- - "
|
|
53
|
+
- - ">="
|
|
54
54
|
- !ruby/object:Gem::Version
|
|
55
55
|
version: '0'
|
|
56
56
|
- !ruby/object:Gem::Dependency
|
|
57
|
-
name:
|
|
57
|
+
name: turn
|
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
|
59
59
|
requirements:
|
|
60
|
-
- - "
|
|
60
|
+
- - ">="
|
|
61
61
|
- !ruby/object:Gem::Version
|
|
62
|
-
version: '
|
|
62
|
+
version: '0'
|
|
63
63
|
type: :development
|
|
64
64
|
prerelease: false
|
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
|
67
|
-
- - "
|
|
67
|
+
- - ">="
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
|
-
version: '
|
|
69
|
+
version: '0'
|
|
70
|
+
- !ruby/object:Gem::Dependency
|
|
71
|
+
name: yard
|
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
|
73
|
+
requirements:
|
|
74
|
+
- - ">="
|
|
75
|
+
- !ruby/object:Gem::Version
|
|
76
|
+
version: '0'
|
|
77
|
+
type: :development
|
|
78
|
+
prerelease: false
|
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
80
|
+
requirements:
|
|
81
|
+
- - ">="
|
|
82
|
+
- !ruby/object:Gem::Version
|
|
83
|
+
version: '0'
|
|
70
84
|
description: A convenience gem for cycling through a set of values, ported from the
|
|
71
85
|
'cycle' functionality found in Rails. It is independent of which framework you use
|
|
72
86
|
so will run in Sinatra, Padrino or straight up Ruby itself.
|
|
@@ -78,6 +92,10 @@ extra_rdoc_files:
|
|
|
78
92
|
- README.md
|
|
79
93
|
files:
|
|
80
94
|
- ".document"
|
|
95
|
+
- ".rubocop.yml"
|
|
96
|
+
- ".ruby-gemset"
|
|
97
|
+
- ".ruby-version"
|
|
98
|
+
- ".travis.yml"
|
|
81
99
|
- Gemfile
|
|
82
100
|
- Gemfile.lock
|
|
83
101
|
- LICENSE.txt
|
|
@@ -86,6 +104,7 @@ files:
|
|
|
86
104
|
- VERSION
|
|
87
105
|
- bicycle.gemspec
|
|
88
106
|
- lib/bicycle.rb
|
|
107
|
+
- lib/bicycle/methods.rb
|
|
89
108
|
- test/helper.rb
|
|
90
109
|
- test/test_bicycle.rb
|
|
91
110
|
homepage: http://github.com/sleepingstu/bicycle
|
|
@@ -108,8 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
108
127
|
version: '0'
|
|
109
128
|
requirements: []
|
|
110
129
|
rubyforge_project:
|
|
111
|
-
rubygems_version: 2.6.
|
|
130
|
+
rubygems_version: 2.6.13
|
|
112
131
|
signing_key:
|
|
113
|
-
specification_version:
|
|
132
|
+
specification_version: 4
|
|
114
133
|
summary: Why walk when you can cycle
|
|
115
134
|
test_files: []
|