vidibus-core_extensions 0.3.17 → 0.4.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/LICENSE +1 -1
- data/README.md +91 -0
- data/Rakefile +12 -31
- data/lib/vidibus-core_extensions.rb +1 -2
- data/lib/vidibus/core_extensions.rb +5 -5
- data/lib/vidibus/core_extensions/string.rb +13 -0
- data/lib/vidibus/core_extensions/version.rb +5 -0
- metadata +119 -101
- data/.bundle/config +0 -2
- data/.document +0 -5
- data/.rspec +0 -2
- data/Gemfile +0 -7
- data/Gemfile.lock +0 -22
- data/README.rdoc +0 -89
- data/VERSION +0 -1
- data/spec/spec_helper.rb +0 -11
- data/spec/vidibus/core_extensions/array_spec.rb +0 -199
- data/spec/vidibus/core_extensions/file_utils_spec.rb +0 -33
- data/spec/vidibus/core_extensions/hash_spec.rb +0 -115
- data/spec/vidibus/core_extensions/object_spec.rb +0 -23
- data/spec/vidibus/core_extensions/string_spec.rb +0 -144
- data/vidibus-core_extensions.gemspec +0 -77
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
# Vidibus::CoreExtensions [](http://travis-ci.org/vidibus/vidibus-core_extensions) [](http://stillmaintained.com/vidibus/vidibus-core_extensions)
|
2
|
+
|
3
|
+
This gem is part of the open source SOA framework Vidibus: http://vidibus.org
|
4
|
+
|
5
|
+
It provides some extensions to the ruby core.
|
6
|
+
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add `gem "vidibus-secure"` to your Gemfile. Then call `bundle install` on your console.
|
11
|
+
|
12
|
+
|
13
|
+
# Usage
|
14
|
+
|
15
|
+
## Array
|
16
|
+
|
17
|
+
### Array#flatten_once
|
18
|
+
|
19
|
+
Flattens first level of an array. Example:
|
20
|
+
```ruby
|
21
|
+
[1, [2, [3]]].flatten_once # => [1, 2, [3]]
|
22
|
+
```
|
23
|
+
|
24
|
+
### Array#merge
|
25
|
+
|
26
|
+
Merges given array with current one.
|
27
|
+
|
28
|
+
It will perform insertion of new items by three rules:
|
29
|
+
|
30
|
+
1. If the item's predecessor is present, insert item after it.
|
31
|
+
2. If the item's follower is present, insert item before it.
|
32
|
+
3. Insert item at end of list.
|
33
|
+
|
34
|
+
Examples:
|
35
|
+
|
36
|
+
```ruby
|
37
|
+
[].merge([1, 2]) # => [1, 2]
|
38
|
+
['a'].merge([1, 2]) # => ['a', 1, 2]
|
39
|
+
[1, 'a'].merge([1, 2]) # => [1, 2, 'a']
|
40
|
+
[1, 'a'].merge([3, 1, 2]) # => [3, 1, 2, 'a']
|
41
|
+
```
|
42
|
+
|
43
|
+
## Hash
|
44
|
+
|
45
|
+
### Hash#to_uri
|
46
|
+
|
47
|
+
Returns URL-encoded string of uri params. Examples:
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
{:some => :value, :another => "speciál"}.to_uri # => "some=value&another=speci%C3%A1l"
|
51
|
+
{:some => {:nested => :thing}}.to_uri # => "some[nested]=thing"
|
52
|
+
```
|
53
|
+
|
54
|
+
### Hash#only
|
55
|
+
|
56
|
+
Returns a copy of self including only the given keys. Example:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
{:name => "Rodrigo", :age => 21}.only(:name) # => {:name => "Rodrigo"}
|
60
|
+
```
|
61
|
+
|
62
|
+
### Hash#except
|
63
|
+
|
64
|
+
Returns a copy of self including all but the given keys. Example:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
{:name => "Rodrigo", :age = 21}.except(:name) # => {:age => 21}
|
68
|
+
```
|
69
|
+
|
70
|
+
## String
|
71
|
+
|
72
|
+
### String#latinize
|
73
|
+
|
74
|
+
Returns a string without exotic chars. Examples:
|
75
|
+
|
76
|
+
```ruby
|
77
|
+
"Hola señor, ¿cómo está?".latinize # => "Hola senor, como esta?"
|
78
|
+
"Ähre, wem Ähre gebührt.".latinize # => "AEhre, wem AEhre gebuehrt."
|
79
|
+
```
|
80
|
+
|
81
|
+
### String#permalink
|
82
|
+
|
83
|
+
Returns a string that may be used as permalink. Example:
|
84
|
+
|
85
|
+
```ruby
|
86
|
+
"Hola señor, ¿cómo está?".permalink # => "hola-senor-como-esta"
|
87
|
+
```
|
88
|
+
|
89
|
+
## Copyright
|
90
|
+
|
91
|
+
Copyright (c) 2010-2012 Andre Pankratz. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -1,36 +1,17 @@
|
|
1
|
-
|
2
|
-
require "rake"
|
3
|
-
require "rake/rdoctask"
|
4
|
-
require "rspec"
|
5
|
-
require "rspec/core/rake_task"
|
1
|
+
$:.unshift File.expand_path('../lib/', __FILE__)
|
6
2
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
gem.summary = %Q{Extends the ruby core.}
|
13
|
-
gem.description = %Q{Provides some extensions to the ruby core.}
|
14
|
-
gem.email = "andre@vidibus.com"
|
15
|
-
gem.homepage = "http://github.com/vidibus/vidibus-core_extensions"
|
16
|
-
gem.authors = ["Andre Pankratz"]
|
17
|
-
end
|
18
|
-
Jeweler::GemcutterTasks.new
|
19
|
-
rescue LoadError
|
20
|
-
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
-
end
|
3
|
+
require 'bundler'
|
4
|
+
require 'rdoc/task'
|
5
|
+
require 'rspec'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'vidibus/core_extensions/version'
|
22
8
|
|
23
|
-
|
24
|
-
t.pattern = "spec/**/*_spec.rb"
|
25
|
-
t.rcov = true
|
26
|
-
t.rcov_opts = ["--exclude", "^spec,/gems/"]
|
27
|
-
end
|
9
|
+
Bundler::GemHelper.install_tasks
|
28
10
|
|
29
11
|
Rake::RDocTask.new do |rdoc|
|
30
|
-
|
31
|
-
rdoc.
|
32
|
-
rdoc.
|
33
|
-
rdoc.rdoc_files.include(
|
34
|
-
rdoc.
|
35
|
-
rdoc.options << "--charset=utf-8"
|
12
|
+
rdoc.rdoc_dir = 'rdoc'
|
13
|
+
rdoc.title = "Vidibus::CoreExtensions #{Vidibus::CoreExtensions::VERSION}"
|
14
|
+
rdoc.rdoc_files.include('README*')
|
15
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
16
|
+
rdoc.options << '--charset=utf-8'
|
36
17
|
end
|
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
require "core_extensions"
|
1
|
+
require 'vidibus/core_extensions'
|
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'vidibus/core_extensions/object'
|
2
|
+
require 'vidibus/core_extensions/hash'
|
3
|
+
require 'vidibus/core_extensions/array'
|
4
|
+
require 'vidibus/core_extensions/string'
|
5
|
+
require 'vidibus/core_extensions/file_utils'
|
@@ -135,4 +135,17 @@ class String
|
|
135
135
|
return self unless params and params.any?
|
136
136
|
self + (self.match(/\?/) ? "&" : "?") + params.to_query
|
137
137
|
end
|
138
|
+
|
139
|
+
# Converts string into a naturally sortable string.
|
140
|
+
def sortable
|
141
|
+
matches = self.scan(/(\D+)?(\d+(?:[\.]?\d+)?)(\D+)?/)
|
142
|
+
return self.downcase.gsub(/\s/, '') if matches.none?
|
143
|
+
''.tap do |converted|
|
144
|
+
matches.each do |s1, i, s2|
|
145
|
+
converted << s1.downcase.gsub(/\s/, '') if s1
|
146
|
+
converted << '%030f' % i.to_f
|
147
|
+
converted << s2.downcase.gsub(/\s/, '') if s2
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
138
151
|
end
|
metadata
CHANGED
@@ -1,136 +1,154 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidibus-core_extensions
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 17
|
10
|
-
version: 0.3.17
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
13
|
-
-
|
7
|
+
authors:
|
8
|
+
- André Pankratz
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.0.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
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'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rdoc
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
24
63
|
name: rspec
|
25
|
-
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
26
65
|
none: false
|
27
|
-
requirements:
|
28
|
-
- -
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
|
31
|
-
segments:
|
32
|
-
- 0
|
33
|
-
version: "0"
|
34
|
-
requirement: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '2'
|
36
70
|
type: :development
|
37
71
|
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '2'
|
78
|
+
- !ruby/object:Gem::Dependency
|
38
79
|
name: rr
|
39
|
-
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
89
|
none: false
|
41
|
-
requirements:
|
42
|
-
- -
|
43
|
-
- !ruby/object:Gem::Version
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: simplecov
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
50
102
|
type: :development
|
51
103
|
prerelease: false
|
52
|
-
|
53
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
105
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
|
60
|
-
- 0
|
61
|
-
version: "0"
|
62
|
-
requirement: *id003
|
63
|
-
description: Provides some extensions to the ruby core.
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: Provides some extensions of the Ruby core
|
64
111
|
email: andre@vidibus.com
|
65
112
|
executables: []
|
66
|
-
|
67
113
|
extensions: []
|
68
|
-
|
69
|
-
|
70
|
-
- LICENSE
|
71
|
-
- README.rdoc
|
72
|
-
files:
|
73
|
-
- .bundle/config
|
74
|
-
- .document
|
75
|
-
- .rspec
|
76
|
-
- Gemfile
|
77
|
-
- Gemfile.lock
|
78
|
-
- LICENSE
|
79
|
-
- README.rdoc
|
80
|
-
- Rakefile
|
81
|
-
- VERSION
|
82
|
-
- lib/vidibus-core_extensions.rb
|
83
|
-
- lib/vidibus/core_extensions.rb
|
114
|
+
extra_rdoc_files: []
|
115
|
+
files:
|
84
116
|
- lib/vidibus/core_extensions/array.rb
|
85
117
|
- lib/vidibus/core_extensions/file_utils.rb
|
86
118
|
- lib/vidibus/core_extensions/hash.rb
|
87
119
|
- lib/vidibus/core_extensions/object.rb
|
88
120
|
- lib/vidibus/core_extensions/string.rb
|
89
|
-
-
|
90
|
-
-
|
91
|
-
-
|
92
|
-
-
|
93
|
-
-
|
94
|
-
-
|
95
|
-
|
96
|
-
has_rdoc: true
|
97
|
-
homepage: http://github.com/vidibus/vidibus-core_extensions
|
121
|
+
- lib/vidibus/core_extensions/version.rb
|
122
|
+
- lib/vidibus/core_extensions.rb
|
123
|
+
- lib/vidibus-core_extensions.rb
|
124
|
+
- LICENSE
|
125
|
+
- README.md
|
126
|
+
- Rakefile
|
127
|
+
homepage: https://github.com/vidibus/vidibus-core_extensions
|
98
128
|
licenses: []
|
99
|
-
|
100
129
|
post_install_message:
|
101
130
|
rdoc_options: []
|
102
|
-
|
103
|
-
require_paths:
|
131
|
+
require_paths:
|
104
132
|
- lib
|
105
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
134
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
135
|
+
requirements:
|
136
|
+
- - ! '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
segments:
|
112
140
|
- 0
|
113
|
-
|
114
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
hash: -4171315463273858690
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
143
|
none: false
|
116
|
-
requirements:
|
117
|
-
- -
|
118
|
-
- !ruby/object:Gem::Version
|
119
|
-
|
120
|
-
segments:
|
121
|
-
- 0
|
122
|
-
version: "0"
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: 1.3.6
|
123
148
|
requirements: []
|
124
|
-
|
125
149
|
rubyforge_project: vidibus-core_extensions
|
126
|
-
rubygems_version: 1.
|
150
|
+
rubygems_version: 1.8.24
|
127
151
|
signing_key:
|
128
152
|
specification_version: 3
|
129
|
-
summary:
|
130
|
-
test_files:
|
131
|
-
- spec/spec_helper.rb
|
132
|
-
- spec/vidibus/core_extensions/array_spec.rb
|
133
|
-
- spec/vidibus/core_extensions/file_utils_spec.rb
|
134
|
-
- spec/vidibus/core_extensions/hash_spec.rb
|
135
|
-
- spec/vidibus/core_extensions/object_spec.rb
|
136
|
-
- spec/vidibus/core_extensions/string_spec.rb
|
153
|
+
summary: Provides some extensions of the Ruby core
|
154
|
+
test_files: []
|
data/.bundle/config
DELETED
data/.document
DELETED
data/.rspec
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
diff-lcs (1.1.2)
|
5
|
-
relevance-rcov (0.9.2.1)
|
6
|
-
rr (1.0.2)
|
7
|
-
rspec (2.5.0)
|
8
|
-
rspec-core (~> 2.5.0)
|
9
|
-
rspec-expectations (~> 2.5.0)
|
10
|
-
rspec-mocks (~> 2.5.0)
|
11
|
-
rspec-core (2.5.1)
|
12
|
-
rspec-expectations (2.5.0)
|
13
|
-
diff-lcs (~> 1.1.2)
|
14
|
-
rspec-mocks (2.5.0)
|
15
|
-
|
16
|
-
PLATFORMS
|
17
|
-
ruby
|
18
|
-
|
19
|
-
DEPENDENCIES
|
20
|
-
relevance-rcov
|
21
|
-
rr
|
22
|
-
rspec
|
data/README.rdoc
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
= vidibus-core_extensions
|
2
|
-
|
3
|
-
This gem is part of the open source SOA framework Vidibus: http://vidibus.org
|
4
|
-
|
5
|
-
It provides some extensions to the ruby core.
|
6
|
-
|
7
|
-
|
8
|
-
== Installation
|
9
|
-
|
10
|
-
Add the dependency to the Gemfile of your application:
|
11
|
-
|
12
|
-
gem "vidibus-core_extensions"
|
13
|
-
|
14
|
-
Then call bundle install on your console.
|
15
|
-
|
16
|
-
|
17
|
-
= Usage
|
18
|
-
|
19
|
-
== Array
|
20
|
-
|
21
|
-
=== Array#flatten_once
|
22
|
-
|
23
|
-
Flattens first level of an array. Example:
|
24
|
-
|
25
|
-
[1, [2, [3]]].flatten_once # => [1, 2, [3]]
|
26
|
-
|
27
|
-
|
28
|
-
=== Array#merge
|
29
|
-
|
30
|
-
Merges given array with current one.
|
31
|
-
|
32
|
-
It will perform insertion of new items by three rules:
|
33
|
-
|
34
|
-
1. If the item's predecessor is present, insert item after it.
|
35
|
-
2. If the item's follower is present, insert item before it.
|
36
|
-
3. Insert item at end of list.
|
37
|
-
|
38
|
-
Examples:
|
39
|
-
|
40
|
-
[].merge([1, 2]) # => [1, 2]
|
41
|
-
['a'].merge([1, 2]) # => ['a', 1, 2]
|
42
|
-
[1, 'a'].merge([1, 2]) # => [1, 2, 'a']
|
43
|
-
[1, 'a'].merge([3, 1, 2]) # => [3, 1, 2, 'a']
|
44
|
-
|
45
|
-
|
46
|
-
== Hash
|
47
|
-
|
48
|
-
=== Hash#to_uri
|
49
|
-
|
50
|
-
Returns URL-encoded string of uri params. Examples:
|
51
|
-
|
52
|
-
{:some => :value, :another => "speciál"}.to_uri # => "some=value&another=speci%C3%A1l"
|
53
|
-
{:some => {:nested => :thing}}.to_uri # => "some[nested]=thing"
|
54
|
-
|
55
|
-
|
56
|
-
=== Hash#only
|
57
|
-
|
58
|
-
Returns a copy of self including only the given keys. Example:
|
59
|
-
|
60
|
-
{:name => "Rodrigo", :age => 21}.only(:name) # => {:name => "Rodrigo"}
|
61
|
-
|
62
|
-
|
63
|
-
=== Hash#except
|
64
|
-
|
65
|
-
Returns a copy of self including all but the given keys. Example:
|
66
|
-
|
67
|
-
{:name => "Rodrigo", :age = 21}.except(:name) # => {:age => 21}
|
68
|
-
|
69
|
-
|
70
|
-
== String
|
71
|
-
|
72
|
-
=== String#latinize
|
73
|
-
|
74
|
-
Returns a string without exotic chars. Examples:
|
75
|
-
|
76
|
-
"Hola señor, ¿cómo está?".latinize # => "Hola senor, como esta?"
|
77
|
-
"Ähre, wem Ähre gebührt.".latinize # => "AEhre, wem AEhre gebuehrt."
|
78
|
-
|
79
|
-
|
80
|
-
=== String#permalink
|
81
|
-
|
82
|
-
Returns a string that may be used as permalink. Example:
|
83
|
-
|
84
|
-
"Hola señor, ¿cómo está?".permalink # => "hola-senor-como-esta"
|
85
|
-
|
86
|
-
|
87
|
-
== Copyright
|
88
|
-
|
89
|
-
Copyright (c) 2010 Andre Pankratz. See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.3.17
|
data/spec/spec_helper.rb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), "..", "lib"))
|
3
|
-
|
4
|
-
require "rubygems"
|
5
|
-
require "rspec"
|
6
|
-
require "rr"
|
7
|
-
require "vidibus-core_extensions"
|
8
|
-
|
9
|
-
RSpec.configure do |config|
|
10
|
-
config.mock_with :rr
|
11
|
-
end
|
@@ -1,199 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Array" do
|
4
|
-
describe "#flatten_once" do
|
5
|
-
it "should return array" do
|
6
|
-
array = ['go', 'for', 'it']
|
7
|
-
array.flatten_once.should eql(['go', 'for', 'it'])
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should return a flattened array" do
|
11
|
-
array = ['go', ['for', 'it']]
|
12
|
-
array.flatten_once.should eql(['go', 'for', 'it'])
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should flatten first level only" do
|
16
|
-
array = ['go', ['for', ['it']]]
|
17
|
-
array.flatten_once.should eql(['go', 'for', ['it']])
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should accept array with mixed values" do
|
21
|
-
array = ["go", [1,2], { :it => "dude" }]
|
22
|
-
array.flatten_once.should eql(["go", 1, 2, { :it => "dude" }])
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#merge" do
|
27
|
-
it "should merge [] with [1,2]" do
|
28
|
-
[].merge([1,2]).should eql([1,2])
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should merge [a] with [1,2]" do
|
32
|
-
['a'].merge([1,2]).should eql(['a',1,2])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should merge [1,'a'] with [1,2]" do
|
36
|
-
[1,'a'].merge([1,2]).should eql([1,2,'a'])
|
37
|
-
end
|
38
|
-
|
39
|
-
it "should merge [1,'a'] with [3,1,2]" do
|
40
|
-
[1,'a'].merge([3,1,2]).should eql([3,1,2,'a'])
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should merge ['b',1,'a'] with [3,1,2]" do
|
44
|
-
['b',1,'a'].merge([3,1,2]).should eql(['b',3,1,2,'a'])
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should merge [2,'b',1,'a'] with [3,1,2]" do
|
48
|
-
[2,'b',1,'a'].merge([3,1,2]).should eql([2,'b',3,1,'a'])
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should merge [2,'b',1,'a'] with [3,1,2,4]" do
|
52
|
-
[2,'b',1,'a'].merge([3,1,2,4]).should eql([2,4,'b',3,1,'a'])
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should merge [2,'b',1,'a'] with [5,3,6,7,1,2,4]" do
|
56
|
-
[2,'b',1,'a'].merge([5,3,6,7,1,2,4]).should eql([2,4,'b',5,3,6,7,1,'a'])
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with :strict option" do
|
60
|
-
it "should merge [] with [1,2]" do
|
61
|
-
array = [1,2]
|
62
|
-
[].merge(array, :strict => true).should eql([])
|
63
|
-
array.should eql([1,2])
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should merge [1,'a'] with [3,1,2]" do
|
67
|
-
array = [3,1,2]
|
68
|
-
[1,'a'].merge(array, :strict => true).should eql([3,1,2,'a'])
|
69
|
-
array.should be_empty
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "#merge_nested" do
|
75
|
-
it "should merge [[]] with [[1,2]]" do
|
76
|
-
[[]].merge_nested([[1,2]]).should eql([[1,2]])
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should merge [[]] with [[1],[2]]" do
|
80
|
-
[[]].merge_nested([[1],[2]]).should eql([[1,2]])
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should merge [[],[]] with [[1],[2]]" do
|
84
|
-
[[],[]].merge_nested([[1],[2]]).should eql([[1],[2]])
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should merge [[1],[]] with [[1],[2]]" do
|
88
|
-
[[1],[]].merge_nested([[1],[2]]).should eql([[1],[2]])
|
89
|
-
end
|
90
|
-
|
91
|
-
it "should merge [[1],[2]] with [[1],[2]]" do
|
92
|
-
[[1],[2]].merge_nested([[1],[2]]).should eql([[1],[2]])
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should merge [[2],[1]] with [[1],[2]]" do
|
96
|
-
[[2],[1]].merge_nested([[1],[2]]).should eql([[2],[1]])
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should merge [[2]] with [[1],[2]]" do
|
100
|
-
[[2]].merge_nested([[1],[2]]).should eql([[2,1]])
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should merge [[2],[]] with [[1],[2]]" do
|
104
|
-
[[2],[]].merge_nested([[1],[2]]).should eql([[2,1],[]])
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should merge [[1,2,3]] with [[1,2],[3]]" do
|
108
|
-
[[1,2,3]].merge_nested([[1,2],[3]]).should eql([[1,2,3]])
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should merge [[1,2],[3]] with [[1],[2,3]]" do
|
112
|
-
[[1,2],[3]].merge_nested([[1],[2,3]]).should eql([[1,2],[3]])
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should keep source intact" do
|
116
|
-
source = [[1,2]]
|
117
|
-
[[1,2]].merge_nested(source)
|
118
|
-
source.should eql([[1,2]])
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
describe "#flatten_with_boundaries" do
|
123
|
-
it "should flatten [[1]]" do
|
124
|
-
[[1]].flatten_with_boundaries.should eql(["__a0",1,"__a0"])
|
125
|
-
end
|
126
|
-
|
127
|
-
it "should flatten [[1],2,[3]]" do
|
128
|
-
[[1],2,[3]].flatten_with_boundaries.should eql(["__a0",1,"__a0",2,"__a1",3,"__a1"])
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should flatten [1,[2],3]" do
|
132
|
-
[1,[2],3].flatten_with_boundaries.should eql([1,"__a0",2,"__a0",3])
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'should flatten [1,[2],3,4,[["x"]]]' do
|
136
|
-
[1,[2],3,4,[["x"]]].flatten_with_boundaries.should eql([1,"__a0",2,"__a0",3,4,"__a1",["x"],"__a1"])
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should handle [1,2]" do
|
140
|
-
[1,2].flatten_with_boundaries.should eql([1,2])
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe "#convert_boundaries" do
|
145
|
-
it 'should convert ["__a0",1,"__a0"]' do
|
146
|
-
["__a0",1,"__a0"].convert_boundaries.should eql([[1]])
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'should convert ["__a0",1,"__a0",2,"__a1",3,"__a1"]' do
|
150
|
-
["__a0",1,"__a0",2,"__a1",3,"__a1"].convert_boundaries.should eql([[1],2,[3]])
|
151
|
-
end
|
152
|
-
|
153
|
-
it 'should convert [1,"__a0",2,"__a0",3]' do
|
154
|
-
[1,"__a0",2,"__a0",3].convert_boundaries.should eql([1,[2],3])
|
155
|
-
end
|
156
|
-
|
157
|
-
it 'should convert [1,"__a0",2,"__a0",3,4,"__a1",["x"],"__a1"]' do
|
158
|
-
[1,"__a0",2,"__a0",3,4,"__a1",["x"],"__a1"].convert_boundaries.should eql([1,[2],3,4,[["x"]]])
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should convert [1,2]" do
|
162
|
-
[1,2].convert_boundaries.should eql([1,2])
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
describe "#sort_by_map" do
|
167
|
-
it "should sort the list of hashes by given order of attribute values" do
|
168
|
-
list = [{:n => "two"}, {:n => "one"}, {:n => "three"}]
|
169
|
-
map = ["one", "two", "three"]
|
170
|
-
list.sort_by_map(map, :n).should eql([{:n => "one"}, {:n => "two"}, {:n => "three"}])
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should sort the list of objects by given order of attribute values" do
|
174
|
-
list = []
|
175
|
-
list << OpenStruct.new(:n => "two")
|
176
|
-
list << OpenStruct.new(:n => "one")
|
177
|
-
list << OpenStruct.new(:n => "three")
|
178
|
-
map = ["one", "two", "three"]
|
179
|
-
ordered = list.sort_by_map(map, :n)
|
180
|
-
ordered[0].n.should eql("one")
|
181
|
-
ordered[1].n.should eql("two")
|
182
|
-
ordered[2].n.should eql("three")
|
183
|
-
end
|
184
|
-
|
185
|
-
it "should sort the list of values by given order" do
|
186
|
-
list = ["two", "one", "three"]
|
187
|
-
map = ["one", "two", "three"]
|
188
|
-
list.sort_by_map(map).should eql(["one", "two", "three"])
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
describe "#delete_rec" do
|
193
|
-
it "should remove a given item from self" do
|
194
|
-
list = ["one", "two", ["one"]]
|
195
|
-
list.delete_rec("one").should eql("one")
|
196
|
-
list.should eql(["two", []])
|
197
|
-
end
|
198
|
-
end
|
199
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "FileUtils" do
|
4
|
-
describe ".remove_dir_r" do
|
5
|
-
let(:tmpdir) { File.join(File.dirname(__FILE__), "..", "..", "tmp") }
|
6
|
-
before { FileUtils.mkdir_p("#{tmpdir}/some/test/dir")}
|
7
|
-
|
8
|
-
it "should remove the current directory and all its parents up to three levels deep" do
|
9
|
-
FileUtils.remove_dir_r("#{tmpdir}/some/test/dir")
|
10
|
-
File.exist?("#{tmpdir}/some").should be_false
|
11
|
-
File.exist?(tmpdir).should be_true
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should not remove parent directory unless it is emtpy" do
|
15
|
-
FileUtils.touch("#{tmpdir}/some/textfile.txt")
|
16
|
-
FileUtils.remove_dir_r("#{tmpdir}/some/test/dir")
|
17
|
-
File.exist?("#{tmpdir}/some").should be_true
|
18
|
-
end
|
19
|
-
|
20
|
-
it "should remove all child directories recursively" do
|
21
|
-
FileUtils.mkdir_p("#{tmpdir}/some/test/dir/with/some/children")
|
22
|
-
FileUtils.remove_dir_r("#{tmpdir}/some/test/dir")
|
23
|
-
File.exist?("#{tmpdir}/some").should be_false
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should remove parent directories up to provided depth only" do
|
27
|
-
FileUtils.remove_dir_r("#{tmpdir}/some/test/dir", 2)
|
28
|
-
File.exist?("#{tmpdir}/some").should be_true
|
29
|
-
end
|
30
|
-
|
31
|
-
after { FileUtils.remove_dir(tmpdir)}
|
32
|
-
end
|
33
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Hash" do
|
4
|
-
describe "#to_query" do
|
5
|
-
it "should join params with '&'" do
|
6
|
-
hash = {:some => "value", :another => "thing"}
|
7
|
-
parts = hash.to_query.split("&")
|
8
|
-
parts.sort.should eql(['another=thing', 'some=value'])
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should return items as urlencoded string" do
|
12
|
-
hash = {:another => "speciál"}
|
13
|
-
hash.to_query.should eql("another=speci%C3%A1l")
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should support multi-level hashes" do
|
17
|
-
hash = {:some => {:nested => :thing}}
|
18
|
-
hash.to_query.should eql("some%5Bnested%5D=thing")
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should support a namespace" do
|
22
|
-
hash = {:nested => :thing}
|
23
|
-
hash.to_query(:some).should eql("some%5Bnested%5D=thing")
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
describe "#only" do
|
28
|
-
it "should return a copy of self but including only the given keys" do
|
29
|
-
hash = {:name => "rodrigo", :age => 21}
|
30
|
-
hash.only(:name).should eql({:name => "rodrigo"})
|
31
|
-
end
|
32
|
-
|
33
|
-
it "should work with array as parameter" do
|
34
|
-
hash = {:name => "rodrigo", :age => 21}
|
35
|
-
hash.only([:name, :something]).should eql({:name => "rodrigo"})
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should work for nested hash" do
|
39
|
-
hash = {:name => "rodrigo", :girlfriends => ["Anna", "Maria"]}
|
40
|
-
hash.only(:name, :girlfriends).should eql({:name => "rodrigo", :girlfriends => ["Anna", "Maria"]})
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
describe "#except" do
|
45
|
-
it "should return a copy of self but including only the given keys" do
|
46
|
-
hash = {:name => "rodrigo", :age => 21}
|
47
|
-
hash.except(:name).should eql({:age => 21})
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should work with array as parameter" do
|
51
|
-
hash = {:name => "rodrigo", :age => 21}
|
52
|
-
hash.except([:name, :something]).should eql({:age => 21})
|
53
|
-
end
|
54
|
-
|
55
|
-
it "should work for nested hash" do
|
56
|
-
hash = {:name => "rodrigo", :girlfriends => ["Anna", "Maria"]}
|
57
|
-
hash.except(:name).should eql({:girlfriends => ["Anna", "Maria"]})
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe "#to_a_rec" do
|
62
|
-
it "should return an array" do
|
63
|
-
hash = {:some => "thing"}
|
64
|
-
hash.to_a_rec.should eql([[:some, "thing"]])
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should return an array from nested hashes" do
|
68
|
-
hash = {:some => {:nested => {:is => ["really", "groovy"]}}}
|
69
|
-
hash.to_a_rec.should eql([[:some, [[:nested, [[:is, ["really", "groovy"]]]]]]])
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should return an array from hashes within arrays" do
|
73
|
-
hash = {:some => [:nested, {:is => ["really", "groovy"]}]}
|
74
|
-
hash.to_a_rec.should eql([[:some, [:nested, [[:is, ["really", "groovy"]]]]]])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
describe "#keys?" do
|
79
|
-
let(:hash) { {:some => "say", :any => "thing"} }
|
80
|
-
|
81
|
-
it "should return true if all keys are given in hash" do
|
82
|
-
hash.keys?(:some, :any).should be_true
|
83
|
-
end
|
84
|
-
|
85
|
-
it "should return true if all keys are given in larger hash" do
|
86
|
-
hash.keys?(:any).should be_true
|
87
|
-
end
|
88
|
-
|
89
|
-
it "should return false if any of the given key misses in hash" do
|
90
|
-
hash.keys?(:any, :thing).should be_false
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
describe ".build" do
|
95
|
-
it "should return a hash" do
|
96
|
-
Hash.build.should eql(Hash.new)
|
97
|
-
end
|
98
|
-
|
99
|
-
it "should accept a hash" do
|
100
|
-
Hash.build({:do => :it}).should eql({:do => :it})
|
101
|
-
end
|
102
|
-
|
103
|
-
it "should accept an array" do
|
104
|
-
Hash.build([:do, :it]).should eql({:do => :it})
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should accept an array and flatten it once" do
|
108
|
-
Hash.build([:do, [:it]]).should eql({:do => :it})
|
109
|
-
end
|
110
|
-
|
111
|
-
it "should not accept a multi-level array" do
|
112
|
-
expect {Hash.build([:do, [:it, [:now]]])}.to raise_error(ArgumentError, "odd number of arguments for Hash")
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe "Object" do
|
4
|
-
describe "#try!" do
|
5
|
-
let(:dog) do
|
6
|
-
Struct.new("Dog", :out) unless defined?(Struct::Dog)
|
7
|
-
Struct::Dog.new(true)
|
8
|
-
end
|
9
|
-
|
10
|
-
it "should return defined method" do
|
11
|
-
dog.try!(:out).should be_true
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should return nil when calling undefined method" do
|
15
|
-
dog.try!(:food).should be_nil
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should re-raise exceptions" do
|
19
|
-
stub(dog).bark { raise("wuff") }
|
20
|
-
expect {dog.try!(:bark)}.to raise_exception("wuff")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,144 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
require "spec_helper"
|
3
|
-
|
4
|
-
describe "String" do
|
5
|
-
describe "::LATIN_MAP" do
|
6
|
-
it "should contain a Hash map" do
|
7
|
-
String::LATIN_MAP.should be_a(Hash)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe "#latinize" do
|
12
|
-
it "should convert diacritics" do
|
13
|
-
"ÀÁÂÃÄÅ Ç Ð ÈÉÊË ÌÍÎÏ Ñ ÒÓÔÕÖØ ÙÚÛÜ Ý àáâãäå ç èéêë ìíîï ñ òóôõöø ùúûü ý".latinize.should
|
14
|
-
eql("AAAAAEA C D EEEE IIII N OOOOOEO UUUUE Y aaaaaea c eeee iiii n oooooeo uuuue y")
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should convert ligatures" do
|
18
|
-
"Æ".latinize.should eql("AE")
|
19
|
-
"ÆǼ æǽ Œ œ".latinize.should eql("AEAE aeae OE oe")
|
20
|
-
end
|
21
|
-
|
22
|
-
it "should keep some regular chars" do
|
23
|
-
".,|?!:;\"'=+-_".latinize.should eql(".,|?!:;\"'=+-_")
|
24
|
-
end
|
25
|
-
|
26
|
-
it "should replace exotic chars by whitespace" do
|
27
|
-
"~÷≥≤˛`ˀð".latinize.should eql(" ")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should normalize white space" do
|
31
|
-
"Hola señor, ¿cómo está?".latinize.should eql("Hola senor, como esta?")
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "#permalink" do
|
36
|
-
it "should call #latinize" do
|
37
|
-
string = "hey"
|
38
|
-
mock(string).latinize { string }
|
39
|
-
string.permalink.should eql(string)
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should return lower chars only" do
|
43
|
-
"HeLlo".permalink.should eql("hello")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should turn whitespace into dashes" do
|
47
|
-
"hey joe".permalink.should eql("hey-joe")
|
48
|
-
end
|
49
|
-
|
50
|
-
it "should turn special chars into dashes" do
|
51
|
-
"hi~there".permalink.should eql("hi-there")
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should not begin with dashes" do
|
55
|
-
">duh".permalink.should eql("duh")
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should not end with dashes" do
|
59
|
-
"hi!".permalink.should eql("hi")
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should convert multiple adjacent special chars into a single dash" do
|
63
|
-
"Hola señor, ¿cómo está?".permalink.should eql("hola-senor-como-esta")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe "#%" do
|
68
|
-
it "should allow reqular printf behaviour" do
|
69
|
-
string = "%s, %s" % ["Masao", "Mutoh"]
|
70
|
-
string.should eql("Masao, Mutoh")
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should accept named arguments" do
|
74
|
-
string = "%{firstname}, %{familyname}" % {:firstname => "Masao", :familyname => "Mutoh"}
|
75
|
-
string.should eql("Masao, Mutoh")
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe "#snip" do
|
80
|
-
it "should truncate string to given length while preserving words" do
|
81
|
-
"O Brother, Where Art Thou?".snip(13).should eql("O Brother, Where…")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "should return whole string if it fits in given length" do
|
85
|
-
"O Brother, Where Art Thou?".snip(100).should eql("O Brother, Where Art Thou?")
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should return whole string if it equals length" do
|
89
|
-
"O Brother, Where Art Thou?".snip(26).should eql("O Brother, Where Art Thou?")
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should strip white space between words" do
|
93
|
-
"O Brother, Where Art Thou?".snip(11).should eql("O Brother,…")
|
94
|
-
end
|
95
|
-
|
96
|
-
it "should strip trailing white space" do
|
97
|
-
"O Brother, Where Art Thou? ".snip(26).should eql("O Brother, Where Art Thou?")
|
98
|
-
end
|
99
|
-
|
100
|
-
it "should strip leading white space" do
|
101
|
-
" O Brother, Where Art Thou?".snip(26).should eql("O Brother, Where Art Thou?")
|
102
|
-
end
|
103
|
-
|
104
|
-
it "should handle content with backets" do
|
105
|
-
"O Brother (Or Sister), Where Art Thou?".snip(20).should eql("O Brother (Or Sister…")
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe "#strip_tags" do
|
110
|
-
it "should remove all tags from string" do
|
111
|
-
"<p>Think<br />different</p>".strip_tags.should eql("Thinkdifferent")
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should even remove chars that aren't tags but look like ones" do
|
115
|
-
"small < large > small".strip_tags.should eql("small small")
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#strip_tags!" do
|
120
|
-
it "should strip tags on self" do
|
121
|
-
string = "<p>Think<br />different</p>"
|
122
|
-
string.strip_tags!
|
123
|
-
string.should eql("Thinkdifferent")
|
124
|
-
end
|
125
|
-
end
|
126
|
-
|
127
|
-
describe "#with_params" do
|
128
|
-
it "should return the current string unless params are given" do
|
129
|
-
"http://vidibus.org".with_params.should eql("http://vidibus.org")
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should return the current string if an empty hash is given" do
|
133
|
-
"http://vidibus.org".with_params({}).should eql("http://vidibus.org")
|
134
|
-
end
|
135
|
-
|
136
|
-
it "should return the current string with params as query" do
|
137
|
-
"http://vidibus.org".with_params(:awesome => "yes").should eql("http://vidibus.org?awesome=yes")
|
138
|
-
end
|
139
|
-
|
140
|
-
it "should append params to existing query" do
|
141
|
-
"http://vidibus.org?opensource=true".with_params(:awesome => "yes").should eql("http://vidibus.org?opensource=true&awesome=yes")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{vidibus-core_extensions}
|
8
|
-
s.version = "0.3.17"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Andre Pankratz"]
|
12
|
-
s.date = %q{2011-02-25}
|
13
|
-
s.description = %q{Provides some extensions to the ruby core.}
|
14
|
-
s.email = %q{andre@vidibus.com}
|
15
|
-
s.extra_rdoc_files = [
|
16
|
-
"LICENSE",
|
17
|
-
"README.rdoc"
|
18
|
-
]
|
19
|
-
s.files = [
|
20
|
-
".bundle/config",
|
21
|
-
".document",
|
22
|
-
".rspec",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"lib/vidibus-core_extensions.rb",
|
30
|
-
"lib/vidibus/core_extensions.rb",
|
31
|
-
"lib/vidibus/core_extensions/array.rb",
|
32
|
-
"lib/vidibus/core_extensions/file_utils.rb",
|
33
|
-
"lib/vidibus/core_extensions/hash.rb",
|
34
|
-
"lib/vidibus/core_extensions/object.rb",
|
35
|
-
"lib/vidibus/core_extensions/string.rb",
|
36
|
-
"spec/spec_helper.rb",
|
37
|
-
"spec/vidibus/core_extensions/array_spec.rb",
|
38
|
-
"spec/vidibus/core_extensions/file_utils_spec.rb",
|
39
|
-
"spec/vidibus/core_extensions/hash_spec.rb",
|
40
|
-
"spec/vidibus/core_extensions/object_spec.rb",
|
41
|
-
"spec/vidibus/core_extensions/string_spec.rb",
|
42
|
-
"vidibus-core_extensions.gemspec"
|
43
|
-
]
|
44
|
-
s.homepage = %q{http://github.com/vidibus/vidibus-core_extensions}
|
45
|
-
s.require_paths = ["lib"]
|
46
|
-
s.rubyforge_project = %q{vidibus-core_extensions}
|
47
|
-
s.rubygems_version = %q{1.3.7}
|
48
|
-
s.summary = %q{Extends the ruby core.}
|
49
|
-
s.test_files = [
|
50
|
-
"spec/spec_helper.rb",
|
51
|
-
"spec/vidibus/core_extensions/array_spec.rb",
|
52
|
-
"spec/vidibus/core_extensions/file_utils_spec.rb",
|
53
|
-
"spec/vidibus/core_extensions/hash_spec.rb",
|
54
|
-
"spec/vidibus/core_extensions/object_spec.rb",
|
55
|
-
"spec/vidibus/core_extensions/string_spec.rb"
|
56
|
-
]
|
57
|
-
|
58
|
-
if s.respond_to? :specification_version then
|
59
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
60
|
-
s.specification_version = 3
|
61
|
-
|
62
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
63
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
64
|
-
s.add_development_dependency(%q<rr>, [">= 0"])
|
65
|
-
s.add_development_dependency(%q<relevance-rcov>, [">= 0"])
|
66
|
-
else
|
67
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
68
|
-
s.add_dependency(%q<rr>, [">= 0"])
|
69
|
-
s.add_dependency(%q<relevance-rcov>, [">= 0"])
|
70
|
-
end
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
73
|
-
s.add_dependency(%q<rr>, [">= 0"])
|
74
|
-
s.add_dependency(%q<relevance-rcov>, [">= 0"])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|