fat_core 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.
@@ -0,0 +1,128 @@
1
+ require 'spec_helper'
2
+
3
+ describe String do
4
+ before do
5
+ #23456789012345678901234567890123456789012345678901234567890123456789|
6
+ @getty = "\
7
+ Four score and seven years ago our fathers brought forth on this conti\
8
+ nent a new nation, conceived in liberty, and dedicated to the proposit\
9
+ ion that all men are created equal. Now we are engaged in a great civ\
10
+ il war, testing whether that nation, or any nation, so conceived and s\
11
+ o dedicated, can long endure. We are met on a great battle-field of th\
12
+ at war. We have come to dedicate a portion of that field, as a final r\
13
+ esting place for those who here gave their lives that that nation migh\
14
+ t live. It is altogether fitting and proper that we should do this. B\
15
+ ut, in a larger sense, we can not dedicate, we can not consecrate, we \
16
+ can not hallow this ground. The brave men, living and dead, who strugg\
17
+ led here, have consecrated it, far above our poor power to add or detr\
18
+ act. The world will little note, nor long remember what we say here, b\
19
+ ut it can never forget what they did here. It is for us the living, ra\
20
+ ther, to be dedicated here to the unfinished work which they who fough\
21
+ t here have thus far so nobly advanced. It is rather for us to be here\
22
+ dedicated to the great task remaining before us--that from these hono\
23
+ red dead we take increased devotion to that cause for which they gave \
24
+ the last full measure of devotion--that we here highly resolve that th\
25
+ ese dead shall not have died in vain--that this nation, under God, sha\
26
+ ll have a new birth of freedom--and that government of the people, by \
27
+ the people, for the people, shall not perish from the earth."
28
+ ##123456789012345678901234567890123456789012345678901234567890123456789|
29
+ # @getty = "\
30
+ # Four score and seven years ago our fathers brought forth on this conti\
31
+ # nent a new nation, conceived in liberty, and dedicated to th\
32
+ # e proposition that all men are created equal. Now we are en\
33
+ # gaged in a great civil war, testing whether that nation, or \
34
+ # any nation, so conceived and so dedicated, can long endure. \
35
+ # We are met on a great battle-field of that war. We have come\
36
+ # to dedicate a portion of that field, as a final resting pla\
37
+ # ce for those who here gave their lives that that nation migh\
38
+ # t live. It is altogether fitting and proper that we should d\
39
+ # o this. But, in a larger sense, we can not dedicate, we can\
40
+ # not consecrate, we can not hallow this ground. The brave me\
41
+ # n, living and dead, who struggled here, have consecrated it,\
42
+ # far above our poor power to add or detract. The world will \
43
+ # little note, nor long remember what we say here, but it can \
44
+ # never forget what they did here. It is for us the living, ra\
45
+ # ther, to be dedicated here to the unfinished work which they\
46
+ # who fought here have thus far so nobly advanced. It is rath\
47
+ # er for us to be here dedicated to the great task remaining b\
48
+ # efore us--that from these honored dead we take increased dev\
49
+ # otion to that cause for which they gave the last full measur\
50
+ # e of devotion--that we here highly resolve that these dead s\
51
+ # hall not have died in vain--that this nation, under God, sha\
52
+ # ll have a new birth of freedom--and that government of the p\
53
+ # eople, by the people, for the people, shall not perish from \
54
+ # the earth."
55
+ ##123456789012345678901234567890123456789012345678901234567890123456789|
56
+ end
57
+
58
+ it "should wrap a short string" do
59
+ "hello, world".wrap.should == "hello, world"
60
+ end
61
+
62
+ it "should wrap a long string" do
63
+ @getty.wrap.split("\n").each {|l| l.length.should <= 70}
64
+ end
65
+
66
+ it "should wrap a long string with a hangining indent" do
67
+ @getty.wrap(70, 10).split("\n").each {|l| l.length.should <= 70}
68
+ @getty.wrap(70, 10).split("\n")[1..-1].each do |l|
69
+ l.should match(/^ /)
70
+ end
71
+ second_line = ' ' * 10 + 'nent a new nation'
72
+ third_line = ' ' * 10 + 'e proposition'
73
+ twenty_fourth_line = ' ' * 10 + 'eople, by the people, for the people'
74
+ @getty.wrap(70, 10).split("\n")[1].should match(/^#{second_line}/)
75
+ @getty.wrap(70, 10).split("\n")[2].should match(/^#{third_line}/)
76
+ @getty.wrap(70, 10).split("\n")[23].should match(/^#{twenty_fourth_line}/)
77
+ end
78
+
79
+ it "should be able to quote special TeX characters" do
80
+ "$10,000".tex_quote.should eq("\\$10,000")
81
+ "would~~have".tex_quote.should eq("would\\textasciitilde{}\\textasciitilde{}have")
82
+ "<hello>".tex_quote.should eq("\\textless{}hello\\textgreater{}")
83
+ "{hello}".tex_quote.should eq("\\{hello\\}")
84
+ end
85
+
86
+ it "should be able to fuzzy match with another string" do
87
+ "Hello, world".fuzzy_match('or').should be_true
88
+ "Hello, world".fuzzy_match('ox').should be_false
89
+ end
90
+
91
+ it "should be able to fuzzy match with another string containing re" do
92
+ "Hello, world".matches_with('/or/').should be_true
93
+ "Hello, world".matches_with('/ox/').should be_false
94
+ end
95
+
96
+ it "should be able to fuzzy match space-separated parts" do
97
+ "Hello world".fuzzy_match('hel or').should be_true
98
+ "Hello, world".fuzzy_match('hel ox').should be_false
99
+ end
100
+
101
+ it "should be able to fuzzy match colon-separated parts" do
102
+ "Hello:world".fuzzy_match('hel:or').should be_true
103
+ "Hello:world".fuzzy_match('hel:ox').should be_false
104
+ end
105
+
106
+ it "should be able to fuzzy match colon-separated parts" do
107
+ "Hello:world".fuzzy_match('hel:or').should be_true
108
+ "Hello:world".fuzzy_match('hel:ox').should be_false
109
+ end
110
+
111
+ it "should return the matched text" do
112
+ "Hello:world".fuzzy_match('hel').should eq('Hel')
113
+ "Hello:world".fuzzy_match('hel:or').should eq('Hello:wor')
114
+ "Hello:world".matches_with('/^h.*r/').should eq('Hello:wor')
115
+ end
116
+
117
+ it "should ignore periods, commas, and apostrophes when matching" do
118
+ "St. Luke's".fuzzy_match('st lukes').should eq('St Lukes')
119
+ "St Lukes".fuzzy_match('st. luke\'s').should eq('St Lukes')
120
+ "St Lukes, Inc.".fuzzy_match('st luke inc').should eq('St Lukes Inc')
121
+ end
122
+
123
+ it "should be able to properly capitalize a string as a title" do
124
+ expect("the cat in the hat".entitle).to eq('The Cat in the Hat')
125
+ expect("dr".entitle).to eq('Dr')
126
+ expect("cr".entitle).to eq('Cr')
127
+ end
128
+ end
@@ -0,0 +1,23 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'fat_core'
5
+ require 'byebug'
6
+
7
+ # This file was generated by the `rspec --init` command. Conventionally, all
8
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
9
+ # Require this file using `require "spec_helper"` to ensure that it is only
10
+ # loaded once.
11
+ #
12
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
13
+ RSpec.configure do |config|
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+
18
+ # Run specs in random order to surface order dependencies. If you find an
19
+ # order dependency and want to debug it, you can fix the order by providing
20
+ # the seed, which is printed after each run.
21
+ # --seed 1234
22
+ config.order = 'random'
23
+ end
metadata ADDED
@@ -0,0 +1,178 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fat_core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Daniel E. Doherty
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rcodetools
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: byebug
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: erubis
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Write a longer description. Optional.
112
+ email:
113
+ - ded-law@ddoherty.net
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".yardopts"
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - fat_core.gemspec
126
+ - lib/fat_core.rb
127
+ - lib/fat_core/array.rb
128
+ - lib/fat_core/date.rb
129
+ - lib/fat_core/enumerable.rb
130
+ - lib/fat_core/hash.rb
131
+ - lib/fat_core/kernel.rb
132
+ - lib/fat_core/latex_eruby.rb
133
+ - lib/fat_core/nil.rb
134
+ - lib/fat_core/numeric.rb
135
+ - lib/fat_core/period.rb
136
+ - lib/fat_core/range.rb
137
+ - lib/fat_core/string.rb
138
+ - lib/fat_core/symbol.rb
139
+ - lib/fat_core/version.rb
140
+ - spec/lib/date_spec.rb
141
+ - spec/lib/kernel_spec.rb
142
+ - spec/lib/numeric_spec.rb
143
+ - spec/lib/period_spec.rb
144
+ - spec/lib/range_spec.rb
145
+ - spec/lib/string_spec.rb
146
+ - spec/spec_helper.rb
147
+ homepage: ''
148
+ licenses:
149
+ - MIT
150
+ metadata: {}
151
+ post_install_message:
152
+ rdoc_options: []
153
+ require_paths:
154
+ - lib
155
+ required_ruby_version: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ required_rubygems_version: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
165
+ requirements: []
166
+ rubyforge_project:
167
+ rubygems_version: 2.2.2
168
+ signing_key:
169
+ specification_version: 4
170
+ summary: fat_core provides some useful core extensions
171
+ test_files:
172
+ - spec/lib/date_spec.rb
173
+ - spec/lib/kernel_spec.rb
174
+ - spec/lib/numeric_spec.rb
175
+ - spec/lib/period_spec.rb
176
+ - spec/lib/range_spec.rb
177
+ - spec/lib/string_spec.rb
178
+ - spec/spec_helper.rb