string-pad 0.0.1 → 0.0.2
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 +7 -0
- data/.gitignore +50 -0
- data/Gemfile +1 -11
- data/Gemfile.lock +6 -9
- data/README.rdoc +13 -0
- data/Rakefile +2 -35
- data/lib/string/pad.rb +29 -1
- data/spec/string-pad_spec.rb +5 -1
- data/string-pad.gemspec +19 -0
- metadata +31 -48
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ae43afb46dbf7f008f34c20c0bef5f2adcbf1cbd
|
4
|
+
data.tar.gz: 6a3f08cbe3c05a14e81c24ec737211f35a114d82
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 86dc21f45ea748c9d2e3bdb289e11c5cfdb1c6e47c8546c2b03409fb88808473e41c49e4228080d916795ed960418074b15779ad7f45ca16d007037695f2401f
|
7
|
+
data.tar.gz: ffbcbc8827ea86562c8db84fe2e46ac83876d16ad8ec2eaa5a90a2afac82f485d0f1267bbb277dd6fed01d841cdaaeb22bca861ff0bf393f43f8f55273370b83
|
data/.gitignore
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# rcov generated
|
2
|
+
coverage
|
3
|
+
coverage.data
|
4
|
+
|
5
|
+
# rdoc generated
|
6
|
+
rdoc
|
7
|
+
|
8
|
+
# yard generated
|
9
|
+
doc
|
10
|
+
.yardoc
|
11
|
+
|
12
|
+
# bundler
|
13
|
+
.bundle
|
14
|
+
vendor/bundle
|
15
|
+
|
16
|
+
# jeweler generated
|
17
|
+
pkg
|
18
|
+
|
19
|
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
|
20
|
+
#
|
21
|
+
# * Create a file at ~/.gitignore
|
22
|
+
# * Include files you want ignored
|
23
|
+
# * Run: git config --global core.excludesfile ~/.gitignore
|
24
|
+
#
|
25
|
+
# After doing this, these files will be ignored in all your git projects,
|
26
|
+
# saving you from having to 'pollute' every project you touch with them
|
27
|
+
#
|
28
|
+
# Not sure what to needs to be ignored for particular editors/OSes? Here's some ideas to get you started. (Remember, remove the leading # of the line)
|
29
|
+
#
|
30
|
+
# For MacOS:
|
31
|
+
#
|
32
|
+
#.DS_Store
|
33
|
+
|
34
|
+
# For TextMate
|
35
|
+
#*.tmproj
|
36
|
+
#tmtags
|
37
|
+
|
38
|
+
# For emacs:
|
39
|
+
#*~
|
40
|
+
#\#*
|
41
|
+
#.\#*
|
42
|
+
|
43
|
+
# For vim:
|
44
|
+
#*.swp
|
45
|
+
|
46
|
+
# For redcar:
|
47
|
+
#.redcar
|
48
|
+
|
49
|
+
# For rubinius:
|
50
|
+
#*.rbc
|
data/Gemfile
CHANGED
@@ -1,13 +1,3 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
5
2
|
|
6
|
-
|
7
|
-
# Include everything needed to run rake, tests, features, etc.
|
8
|
-
group :development do
|
9
|
-
gem "rspec", "~> 2.8.0"
|
10
|
-
gem "rdoc", "~> 3.12"
|
11
|
-
gem "bundler", "~> 1.0.0"
|
12
|
-
gem "jeweler", "~> 1.8.3"
|
13
|
-
end
|
3
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
string-pad (0.0.2)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
4
9
|
diff-lcs (1.1.3)
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.8.3)
|
7
|
-
bundler (~> 1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rake
|
10
|
-
rdoc
|
11
10
|
json (1.6.5)
|
12
|
-
rake (0.9.2.2)
|
13
11
|
rdoc (3.12)
|
14
12
|
json (~> 1.4)
|
15
13
|
rspec (2.8.0)
|
@@ -25,7 +23,6 @@ PLATFORMS
|
|
25
23
|
ruby
|
26
24
|
|
27
25
|
DEPENDENCIES
|
28
|
-
bundler (~> 1.0.0)
|
29
|
-
jeweler (~> 1.8.3)
|
30
26
|
rdoc (~> 3.12)
|
31
27
|
rspec (~> 2.8.0)
|
28
|
+
string-pad!
|
data/README.rdoc
CHANGED
@@ -4,6 +4,19 @@ Creates a new string by concatenating enough leading zero-width pad characters t
|
|
4
4
|
|
5
5
|
Useful when tweeting identical text repeatedly.
|
6
6
|
|
7
|
+
== Synopsis
|
8
|
+
|
9
|
+
require 'string/pad'
|
10
|
+
|
11
|
+
str = 'PENTAX!'.pad(140)
|
12
|
+
|
13
|
+
str # => PENTAX!
|
14
|
+
str.split(//).size # 140
|
15
|
+
|
16
|
+
== Installation
|
17
|
+
|
18
|
+
gem install string-pad
|
19
|
+
|
7
20
|
== Contributing to string-pad
|
8
21
|
|
9
22
|
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
data/Rakefile
CHANGED
@@ -1,29 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
1
|
+
#!/usr/bin/env rake
|
12
2
|
require 'rake'
|
13
|
-
|
14
|
-
require 'jeweler'
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "string-pad"
|
18
|
-
gem.homepage = "http://github.com/youpy/string-pad"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{A Ruby library to padding a string}
|
21
|
-
gem.description = %Q{Creates a new string by concatenating enough leading zero-width pad characters to an original string to achieve a specified total length.}
|
22
|
-
gem.email = "youpy@buycheapviagraonlinenow.com"
|
23
|
-
gem.authors = ["youpy"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
3
|
+
require "bundler/gem_tasks"
|
27
4
|
|
28
5
|
require 'rspec/core'
|
29
6
|
require 'rspec/core/rake_task'
|
@@ -32,13 +9,3 @@ RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
32
9
|
end
|
33
10
|
|
34
11
|
task :default => :spec
|
35
|
-
|
36
|
-
require 'rdoc/task'
|
37
|
-
Rake::RDocTask.new do |rdoc|
|
38
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
39
|
-
|
40
|
-
rdoc.rdoc_dir = 'rdoc'
|
41
|
-
rdoc.title = "string-pad #{version}"
|
42
|
-
rdoc.rdoc_files.include('README*')
|
43
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
44
|
-
end
|
data/lib/string/pad.rb
CHANGED
@@ -5,9 +5,37 @@ if RUBY_VERSION =~ /^1\.8/
|
|
5
5
|
end
|
6
6
|
|
7
7
|
class String
|
8
|
+
ZERO_WIDTH_CHARS = [
|
9
|
+
0x200b,
|
10
|
+
0x200c,
|
11
|
+
0x200d,
|
12
|
+
0x200e,
|
13
|
+
0x200f,
|
14
|
+
0x202a,
|
15
|
+
0x202b,
|
16
|
+
0x202c,
|
17
|
+
0x202d,
|
18
|
+
0x202e,
|
19
|
+
0x2060,
|
20
|
+
0x2061,
|
21
|
+
0x2062,
|
22
|
+
0x2063,
|
23
|
+
0x2064,
|
24
|
+
0x2066,
|
25
|
+
0x2067,
|
26
|
+
0x2068,
|
27
|
+
0x2069,
|
28
|
+
0x206a,
|
29
|
+
0x206b,
|
30
|
+
0x206c,
|
31
|
+
0x206d,
|
32
|
+
0x206e,
|
33
|
+
0x206f
|
34
|
+
]
|
35
|
+
|
8
36
|
def pad(size)
|
9
37
|
orig_size = split(//).size
|
10
|
-
padding = (0...(size - orig_size)).to_a.map {
|
38
|
+
padding = (0...(size - orig_size)).to_a.map { ZERO_WIDTH_CHARS.sort_by { rand }.first }.pack('U*')
|
11
39
|
padding + self
|
12
40
|
end
|
13
41
|
end
|
data/spec/string-pad_spec.rb
CHANGED
@@ -7,10 +7,14 @@ describe 'String#pad' do
|
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should pad' do
|
10
|
+
regexp_str = String::ZERO_WIDTH_CHARS.map do |c|
|
11
|
+
[c].pack('U')
|
12
|
+
end.join('')
|
13
|
+
|
10
14
|
size(subject.pad(30)).should eql(30)
|
11
15
|
|
12
16
|
# http://www.metareal.org/2007/11/18/ruby-needs-unicode-regular-expressions/
|
13
|
-
size(subject.pad(30).gsub(/#{"[#{
|
17
|
+
size(subject.pad(30).gsub(/#{"[#{regexp_str}]"}/u, '')).should eql(13)
|
14
18
|
end
|
15
19
|
|
16
20
|
it 'should not pad if original size is longer than padding size' do
|
data/string-pad.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["youpy"]
|
5
|
+
gem.email = ["youpy@buycheapviagraonlinenow.com"]
|
6
|
+
gem.description = "Creates a new string by concatenating enough leading zero-width pad characters to an original string to achieve a specified total length."
|
7
|
+
gem.summary = "Creates a new string by concatenating enough leading zero-width pad characters to an original string to achieve a specified total length."
|
8
|
+
gem.homepage = "http://github.com/youpy/string-pad"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split("\n")
|
11
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
12
|
+
gem.name = "string-pad"
|
13
|
+
gem.require_paths = ["lib"]
|
14
|
+
gem.version = "0.0.2"
|
15
|
+
gem.license = 'MIT'
|
16
|
+
|
17
|
+
gem.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
18
|
+
gem.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
19
|
+
end
|
metadata
CHANGED
@@ -1,71 +1,54 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: string-pad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- youpy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2016-03-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: 2.8.0
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
- !ruby/object:Gem::Dependency
|
26
|
-
name: rdoc
|
27
|
-
requirement: &70354856923240 !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
29
23
|
requirements:
|
30
|
-
- - ~>
|
24
|
+
- - "~>"
|
31
25
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
33
|
-
type: :development
|
34
|
-
prerelease: false
|
35
|
-
version_requirements: *70354856923240
|
26
|
+
version: 2.8.0
|
36
27
|
- !ruby/object:Gem::Dependency
|
37
|
-
name:
|
38
|
-
requirement:
|
39
|
-
none: false
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
40
30
|
requirements:
|
41
|
-
- - ~>
|
31
|
+
- - "~>"
|
42
32
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
33
|
+
version: '3.12'
|
44
34
|
type: :development
|
45
35
|
prerelease: false
|
46
|
-
version_requirements:
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: jeweler
|
49
|
-
requirement: &70354856935880 !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
|
-
- - ~>
|
38
|
+
- - "~>"
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
type: :development
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: *70354856935880
|
40
|
+
version: '3.12'
|
58
41
|
description: Creates a new string by concatenating enough leading zero-width pad characters
|
59
42
|
to an original string to achieve a specified total length.
|
60
|
-
email:
|
43
|
+
email:
|
44
|
+
- youpy@buycheapviagraonlinenow.com
|
61
45
|
executables: []
|
62
46
|
extensions: []
|
63
|
-
extra_rdoc_files:
|
64
|
-
- LICENSE.txt
|
65
|
-
- README.rdoc
|
47
|
+
extra_rdoc_files: []
|
66
48
|
files:
|
67
|
-
- .document
|
68
|
-
- .
|
49
|
+
- ".document"
|
50
|
+
- ".gitignore"
|
51
|
+
- ".rspec"
|
69
52
|
- Gemfile
|
70
53
|
- Gemfile.lock
|
71
54
|
- LICENSE.txt
|
@@ -74,32 +57,32 @@ files:
|
|
74
57
|
- lib/string/pad.rb
|
75
58
|
- spec/spec_helper.rb
|
76
59
|
- spec/string-pad_spec.rb
|
60
|
+
- string-pad.gemspec
|
77
61
|
homepage: http://github.com/youpy/string-pad
|
78
62
|
licenses:
|
79
63
|
- MIT
|
64
|
+
metadata: {}
|
80
65
|
post_install_message:
|
81
66
|
rdoc_options: []
|
82
67
|
require_paths:
|
83
68
|
- lib
|
84
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
70
|
requirements:
|
87
|
-
- -
|
71
|
+
- - ">="
|
88
72
|
- !ruby/object:Gem::Version
|
89
73
|
version: '0'
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
hash: 2621184752924516486
|
93
74
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
-
none: false
|
95
75
|
requirements:
|
96
|
-
- -
|
76
|
+
- - ">="
|
97
77
|
- !ruby/object:Gem::Version
|
98
78
|
version: '0'
|
99
79
|
requirements: []
|
100
80
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
81
|
+
rubygems_version: 2.2.0.rc.1
|
102
82
|
signing_key:
|
103
|
-
specification_version:
|
104
|
-
summary:
|
105
|
-
|
83
|
+
specification_version: 4
|
84
|
+
summary: Creates a new string by concatenating enough leading zero-width pad characters
|
85
|
+
to an original string to achieve a specified total length.
|
86
|
+
test_files:
|
87
|
+
- spec/spec_helper.rb
|
88
|
+
- spec/string-pad_spec.rb
|