rujitsu 0.2.5 → 0.3
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/CHANGELOG +4 -0
- data/Manifest +2 -1
- data/README.rdoc +10 -0
- data/Rakefile +1 -1
- data/lib/rujitsu.rb +1 -0
- data/lib/rujitsu/object.rb +7 -0
- data/rujitsu.gemspec +4 -4
- data/spec/object_spec.rb +27 -0
- metadata +6 -3
data/CHANGELOG
CHANGED
data/Manifest
CHANGED
@@ -8,11 +8,12 @@ lib/rujitsu/fixnum.rb
|
|
8
8
|
lib/rujitsu/grammar.rb
|
9
9
|
lib/rujitsu/inspect.rb
|
10
10
|
lib/rujitsu/numeric.rb
|
11
|
+
lib/rujitsu/object.rb
|
11
12
|
lib/rujitsu/range.rb
|
12
13
|
lib/rujitsu/string.rb
|
13
|
-
rujitsu.gemspec
|
14
14
|
spec/fixnum_spec.rb
|
15
15
|
spec/numeric_spec.rb
|
16
|
+
spec/object_spec.rb
|
16
17
|
spec/range_spec.rb
|
17
18
|
spec/spec.opts
|
18
19
|
spec/spec_helper.rb
|
data/README.rdoc
CHANGED
@@ -49,6 +49,16 @@ The String class has an extension that strips out URL-unfriendly characters.
|
|
49
49
|
The String class has an extension that truncates it to a customisable length with a customisable suffix.
|
50
50
|
|
51
51
|
"this is a string".truncate(:length => 15) # => "this is a st..."
|
52
|
+
|
53
|
+
=== Testing for inclusion within a container
|
54
|
+
|
55
|
+
As Rubyists we are all familiar with using include? to test if our variable is one of a number of values.
|
56
|
+
|
57
|
+
if ['hello', 'world'].include?(@my_value) ...
|
58
|
+
|
59
|
+
However, it doesn't read correctly. Rujitsu allows you to write the following as it reads much more like English.
|
60
|
+
|
61
|
+
if @my_value.in? ['hello', 'world'] ...
|
52
62
|
|
53
63
|
=== Grammar
|
54
64
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('rujitsu', '0.
|
5
|
+
Echoe.new('rujitsu', '0.3') do | config |
|
6
6
|
config.description = 'Various helper methods to smooth over Ruby development'
|
7
7
|
config.url = 'http://github.com/rahoub/rujitsu'
|
8
8
|
config.author = 'Brightbox Systems Ltd'
|
data/lib/rujitsu.rb
CHANGED
@@ -0,0 +1,7 @@
|
|
1
|
+
class Object
|
2
|
+
# return true if this object is within the given container
|
3
|
+
# if the supplied container does not respond to include? then an equality test is used instead
|
4
|
+
def in? container
|
5
|
+
container.respond_to?(:include?) ? container.include?(self) : container == self
|
6
|
+
end
|
7
|
+
end
|
data/rujitsu.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{rujitsu}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Brightbox Systems Ltd"]
|
9
|
-
s.date = %q{2009-11-
|
9
|
+
s.date = %q{2009-11-30}
|
10
10
|
s.description = %q{Various helper methods to smooth over Ruby development}
|
11
11
|
s.email = %q{hello@brightbox.co.uk}
|
12
|
-
s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/rujitsu.rb", "lib/rujitsu/all.rb", "lib/rujitsu/fixnum.rb", "lib/rujitsu/grammar.rb", "lib/rujitsu/inspect.rb", "lib/rujitsu/numeric.rb", "lib/rujitsu/range.rb", "lib/rujitsu/string.rb", "tasks/rspec.rake"]
|
13
|
-
s.files = ["CHANGELOG", "Manifest", "README.rdoc", "Rakefile", "lib/rujitsu.rb", "lib/rujitsu/all.rb", "lib/rujitsu/fixnum.rb", "lib/rujitsu/grammar.rb", "lib/rujitsu/inspect.rb", "lib/rujitsu/numeric.rb", "lib/rujitsu/
|
12
|
+
s.extra_rdoc_files = ["CHANGELOG", "README.rdoc", "lib/rujitsu.rb", "lib/rujitsu/all.rb", "lib/rujitsu/fixnum.rb", "lib/rujitsu/grammar.rb", "lib/rujitsu/inspect.rb", "lib/rujitsu/numeric.rb", "lib/rujitsu/object.rb", "lib/rujitsu/range.rb", "lib/rujitsu/string.rb", "tasks/rspec.rake"]
|
13
|
+
s.files = ["CHANGELOG", "Manifest", "README.rdoc", "Rakefile", "lib/rujitsu.rb", "lib/rujitsu/all.rb", "lib/rujitsu/fixnum.rb", "lib/rujitsu/grammar.rb", "lib/rujitsu/inspect.rb", "lib/rujitsu/numeric.rb", "lib/rujitsu/object.rb", "lib/rujitsu/range.rb", "lib/rujitsu/string.rb", "spec/fixnum_spec.rb", "spec/numeric_spec.rb", "spec/object_spec.rb", "spec/range_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/string_spec.rb", "tasks/rspec.rake", "rujitsu.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/rahoub/rujitsu}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Rujitsu", "--main", "README.rdoc"]
|
16
16
|
s.require_paths = ["lib"]
|
data/spec/object_spec.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__) + "/spec_helper")
|
2
|
+
|
3
|
+
describe Object do
|
4
|
+
describe "testing membership of a container" do
|
5
|
+
it "should report whether it is in an array of objects" do
|
6
|
+
@object = Object.new
|
7
|
+
@positive = [@object, Object.new, Object.new]
|
8
|
+
@negative = [Object.new, Object.new, Object.new]
|
9
|
+
|
10
|
+
@object.in?(@positive).should be_true
|
11
|
+
@object.in?(@negative).should be_false
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should report whether it is equal if given a non-container" do
|
15
|
+
@object = Object.new
|
16
|
+
@another = Object.new
|
17
|
+
|
18
|
+
@object.in?(@object).should be_true
|
19
|
+
@object.in?(@another).should be_false
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should not be a member of nil" do
|
23
|
+
@object = Object.new
|
24
|
+
@object.in?(nil).should be_false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rujitsu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brightbox Systems Ltd
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-30 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,6 +28,7 @@ extra_rdoc_files:
|
|
28
28
|
- lib/rujitsu/grammar.rb
|
29
29
|
- lib/rujitsu/inspect.rb
|
30
30
|
- lib/rujitsu/numeric.rb
|
31
|
+
- lib/rujitsu/object.rb
|
31
32
|
- lib/rujitsu/range.rb
|
32
33
|
- lib/rujitsu/string.rb
|
33
34
|
- tasks/rspec.rake
|
@@ -42,16 +43,18 @@ files:
|
|
42
43
|
- lib/rujitsu/grammar.rb
|
43
44
|
- lib/rujitsu/inspect.rb
|
44
45
|
- lib/rujitsu/numeric.rb
|
46
|
+
- lib/rujitsu/object.rb
|
45
47
|
- lib/rujitsu/range.rb
|
46
48
|
- lib/rujitsu/string.rb
|
47
|
-
- rujitsu.gemspec
|
48
49
|
- spec/fixnum_spec.rb
|
49
50
|
- spec/numeric_spec.rb
|
51
|
+
- spec/object_spec.rb
|
50
52
|
- spec/range_spec.rb
|
51
53
|
- spec/spec.opts
|
52
54
|
- spec/spec_helper.rb
|
53
55
|
- spec/string_spec.rb
|
54
56
|
- tasks/rspec.rake
|
57
|
+
- rujitsu.gemspec
|
55
58
|
has_rdoc: true
|
56
59
|
homepage: http://github.com/rahoub/rujitsu
|
57
60
|
licenses: []
|