forkforge 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3ff9ee5d5d58ff6c4a259b0aaf1900b307b30616
4
+ data.tar.gz: bfb466819451fce408579478a81047f237d143d5
5
+ SHA512:
6
+ metadata.gz: c496fe9c1bb31dc685d9f47ae73c0b6a07887b9e8f5ea03adf0b8cef97f99ba753fc78b4a5d3dcd84703d4fd962effba1c94afaf566139fab4c1a0820db10521
7
+ data.tar.gz: ee40c0532c6ff130bac05839feeda4535aab0611d62de6db510d07ff910ed927e757d552902f77d5e6fc91fa2a4095e6926c2ff721d1201eb312bfb20fc2523c
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .project
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ data/
13
+ lib/bundler/man
14
+ pkg
15
+ rdoc
16
+ spec/reports
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.0
data/.yardopts ADDED
@@ -0,0 +1,3 @@
1
+ --private
2
+ --markup markdown
3
+ --hide-void-return
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in forkforge.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alexei Matyushkin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,67 @@
1
+ # ![logo](https://raw.githubusercontent.com/mudasobwa/forkforge/master/media/ff-64.png) ForkForge Unicode Library
2
+
3
+ [![Build Status](https://travis-ci.org/mudasobwa/forkforge.png)](https://travis-ci.org/mudasobwa/forkforge)
4
+ [![Gemnasium](https://gemnasium.com/mudasobwa/forkforge.png?travis)](https://gemnasium.com/mudasobwa/forkforge)
5
+ [![Stories in Ready](https://badge.waffle.io/mudasobwa/forkforge.png?label=ready)](http://waffle.io/mudasobwa/forkforge)
6
+
7
+ **Status:** Minimum viable product
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ Easy UTF-8 strings manipulation.
14
+
15
+ Up-/down-casing:
16
+
17
+ ```ruby
18
+ require 'forgkforge'
19
+ require 'forgkforge/knife/string'
20
+
21
+ 'istanbul'.uppercase
22
+ #⇒ ISTANBUL
23
+ 'istanbul'.uppercase 'tr'
24
+ #⇒ İSTANBUL
25
+ Forkforge::UnicodeData::code_points.math 'abc'
26
+ #⇒ Instance of CodePoints, a hash
27
+ "#{Forkforge::UnicodeData::code_points.math 'abc'}"
28
+ #⇒ 𝐚𝐛𝐜𝑎𝑏𝑐𝒂𝒃𝒄𝒶𝒷𝒸𝓪𝓫𝓬𝔞𝔟𝔠𝕒𝕓𝕔𝖆𝖇𝖈𝖺𝖻𝖼𝗮𝗯𝗰𝘢𝘣𝘤𝙖𝙗𝙘𝚊𝚋𝚌
29
+ (Forkforge::UnicodeData::code_points.math.franktur.bold 'abc').to_s
30
+ #⇒ 𝖆𝖇𝖈
31
+ "#{Forkforge::UnicodeData::code_points.franktur_math_bold 'abc'}"
32
+ #⇒ 𝖆𝖇𝖈
33
+ '1'.compose_circle
34
+ #⇒ ①
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Installation
40
+
41
+ Add this line to your application's Gemfile:
42
+
43
+ gem 'forkforge'
44
+
45
+ And then execute:
46
+
47
+ $ bundle
48
+
49
+ Or install it yourself as:
50
+
51
+ $ gem install forkforge
52
+
53
+ ## Usage
54
+
55
+ ### Working features:
56
+
57
+ * uppercase
58
+ * lowercase
59
+ * titlecase
60
+
61
+ ## Contributing
62
+
63
+ 1. Fork it ( http://github.com/mudasobwa/forkforge/fork )
64
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
65
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
66
+ 4. Push to the branch (`git push origin my-new-feature`)
67
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,22 @@
1
+ require 'bundler/setup'
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+
6
+ desc 'Tests'
7
+ RSpec::Core::RakeTask.new(:spec) do |spec|
8
+ spec.rspec_opts = '-Ispec'
9
+ # spec.rcov = true
10
+ end
11
+
12
+ require 'cucumber/rake/task'
13
+ desc 'Cucumber'
14
+ Cucumber::Rake::Task.new(:features)
15
+
16
+ task :default => [:features, :spec]
17
+
18
+ require 'yard'
19
+ desc 'YARD'
20
+ YARD::Rake::YardocTask.new(:yard) do |t|
21
+ t.files = ['**/*.rb', 'features/**/*.feature', 'features/**/*.rb']
22
+ end
@@ -0,0 +1,5 @@
1
+ # config/cucumber.yml
2
+ ##YAML Template
3
+ ---
4
+ html_report: --format progress --format html --out=features_report.html
5
+ punct: --tags @punctuation
@@ -0,0 +1,226 @@
1
+ # encoding: utf-8
2
+
3
+ ###############################################################################
4
+ #### GIVEN
5
+ ###############################################################################
6
+
7
+ Given(/^we have no local copy of the "(.*?)" file$/) do |f|
8
+ @f = f
9
+ end
10
+
11
+ Given(/^we have a string "(.*?)"$/) do |input|
12
+ @input = input
13
+ end
14
+
15
+ Given(/^we have a cyrillic string "(.*?)"$/) do |input|
16
+ @input = input
17
+ end
18
+
19
+ Given(/^we have a pattern "(.*?)"$/) do |pattern|
20
+ @pattern = pattern
21
+ end
22
+
23
+ Given(/^we have a pattern looking like a tag$/) do
24
+ @pattern = /<.*?>/
25
+ end
26
+
27
+ Given(/^we have a symbol "(.*?)"$/) do |symbol|
28
+ @input = symbol
29
+ end
30
+
31
+ Given(/^we have a symbol with codebase "(.*?)"$/) do |cb|
32
+ @input = cb.to_i(16)
33
+ end
34
+
35
+ ###############################################################################
36
+ ##### WHEN
37
+ ###############################################################################
38
+
39
+ When(/^we call "(.*?)" method on Forkforge::Unicode$/) do |method|
40
+ @output = Forkforge::Unicode::send method.to_sym, @input
41
+ end
42
+
43
+ When(/^we ask to print known conditions$/) do
44
+ @output = Forkforge::SpecialCasing.all_condition_list.map { |k, v|
45
+ v.map { |vv|
46
+ vv[:condition_list]
47
+ }
48
+ }.flatten.uniq
49
+ end
50
+
51
+ When(/^the string is upcased with language set to "(.*?)"$/) do |lang|
52
+ @output = Forkforge::Unicode::uppercase @input, lang
53
+ end
54
+
55
+ When(/^the string is downcased with language set to "(.*?)"$/) do |lang|
56
+ @output = Forkforge::Unicode::lowercase @input, lang
57
+ end
58
+
59
+ When(/^the string is upcased$/) do
60
+ @output = Forkforge::Unicode::uppercase @input
61
+ end
62
+
63
+ When(/^we decompose it$/) do
64
+ @output = Forkforge::Unicode::decompose @input
65
+ end
66
+
67
+ When(/^we decompose it with circle tag only$/) do
68
+ @output = Forkforge::Unicode::decompose @input, :circle
69
+ end
70
+
71
+ When(/^the string is downcased$/) do
72
+ @output = Forkforge::Unicode::lowercase @input
73
+ end
74
+
75
+ When(/^the string is titlecased$/) do
76
+ @output = Forkforge::Unicode::titlecase @input
77
+ end
78
+
79
+ When(/^we call all_character_decomposition_mapping on Forkforge::UnicodeData$/) do
80
+ @output = Forkforge::UnicodeData::all_character_decomposition_mapping
81
+ end
82
+
83
+ When(/^we call "(.*?)" method on Forkforge::Letter$/) do |method|
84
+ @output = Forkforge::Letter::send :"#{method}"
85
+ end
86
+
87
+ When(/^we call uppercase_code_point on Forkforge::Letter$/) do
88
+ @output = Forkforge::Letter::uppercase_code_point
89
+ end
90
+
91
+ When(/^we call "(.*?)" method on Forkforge::Mark$/) do |method|
92
+ @output = Forkforge::Mark::send :"#{method}"
93
+ end
94
+
95
+ When(/^we call "(.*?)" method on Forkforge::Number$/) do |method|
96
+ @output = Forkforge::Number::send :"#{method}"
97
+ end
98
+
99
+ When(/^we call "(.*?)" method on Forkforge::Punctuation$/) do |method|
100
+ @output = Forkforge::Punctuation::send :"#{method}"
101
+ end
102
+
103
+ When(/^we call "(.*?)" method on Forkforge::Symbol$/) do |method|
104
+ @output = Forkforge::Symbol::send :"#{method}"
105
+ end
106
+
107
+ When(/^we call "(.*?)" method on Forkforge::Separator$/) do |method|
108
+ @output = Forkforge::Separator::send :"#{method}"
109
+ end
110
+
111
+ When(/^we call "(.*?)" method on Forkforge::Other$/) do |method|
112
+ @output = Forkforge::Other::send :"#{method}"
113
+ end
114
+
115
+ When(/^lookup using all_character_name is done with this pattern$/) do
116
+ @output = Forkforge::UnicodeData::all_character_name Regexp.new @pattern
117
+ end
118
+
119
+ When(/^lookup is done with this pattern$/) do
120
+ @output = Forkforge::Unicode::lookup Regexp.new @pattern, Regexp::IGNORECASE
121
+ end
122
+
123
+ When(/^result is filtered to show tags$/) do
124
+ @output = Forkforge::TaggedCharacterName::ALL
125
+ end
126
+
127
+ When(/^result is filtered to show tagged characters$/) do
128
+ @output = Forkforge::TaggedCharacterName::CHARACTERS
129
+ end
130
+
131
+ When(/^result is set to response from "(.*?)" function call$/) do |method|
132
+ @output = Forkforge::TaggedCharacterName::send :"#{method}"
133
+ end
134
+
135
+ When(/^we retrieve it’s info$/) do
136
+ @output = Forkforge::UnicodeData::info(@input)[:character_name]
137
+ end
138
+
139
+ When(/^we add custom decomposition rule$/) do
140
+ @pending # Will be implemented after core is done
141
+ end
142
+
143
+ When(/^we construct Tag object against it$/) do
144
+ @output = Forkforge::CharacterDecompositionMapping::Tag.new @input
145
+ end
146
+
147
+ When(/^we compose input to "(.*?)"$/) do |tag|
148
+ @output = (Forkforge::Unicode::compose @input, "#{tag}").values.join(',')
149
+ end
150
+
151
+ When(/^we widify input$/) do
152
+ @output = Forkforge::Unicode::wide @input
153
+ end
154
+
155
+ When(/^we circlefy input$/) do
156
+ @output = Forkforge::Unicode::circle @input
157
+ end
158
+
159
+ When(/^we call "(.*?)" method on Forkforge::CodePoints for "(.*?)"$/) do |method, sym|
160
+ @output = Forkforge::UnicodeData::code_points.send(method.to_sym, sym)
161
+ end
162
+
163
+ When(/^the string is directly widefied$/) do
164
+ @output = @input.compose_wide
165
+ end
166
+
167
+ When(/^the string is directly upcased$/) do
168
+ @output = @input.upcase
169
+ end
170
+
171
+ ###############################################################################
172
+ ##### THEN
173
+ ###############################################################################
174
+
175
+ Then(/^the file is got from www.unicode.org\/Public\/5.1.0\/ucd\/UnicodeData.txt is printed out$/) do
176
+ @hash = Forkforge::UnicodeData.send :hash # just here for testing purposes, method is private
177
+ puts @hash.take 2
178
+ end
179
+
180
+ Then(/^the result is "(.*?)"$/) do |result|
181
+ expect(@output).to eq(result)
182
+ end
183
+
184
+ Then(/^the result to string is "(.*?)"$/) do |result|
185
+ expect(@output.to_s).to eq(result)
186
+ end
187
+
188
+ Then(/^the result count equals to (\d+)$/) do |count|
189
+ expect(@output.count).to eq(count.to_i)
190
+ end
191
+
192
+ Then(/^the first item equals to "(.*?)"$/) do |string|
193
+ expect(@output[0]).to eq(string)
194
+ end
195
+
196
+ Then(/^the first item’s value equals to "(.*?)"$/) do |string|
197
+ expect(@output.values[0]).to eq(string)
198
+ end
199
+
200
+ Then(/^the result’s first element nested count is "(.*?)"$/) do |count|
201
+ expect(@output.values[0].count).to eq(count.to_i)
202
+ end
203
+
204
+ Then(/^we print first (\d+) results$/) do |count|
205
+ puts @output.take count.to_i
206
+ end
207
+
208
+ Then(/^we print results$/) do
209
+ puts @output
210
+ end
211
+
212
+ Then(/^we print a result count$/) do
213
+ puts @output.count
214
+ end
215
+
216
+ Then(/^both sym and tag have correct values$/) do
217
+ expect(@output.tag).to eq('<font>')
218
+ expect(@output.sym).to eq(:font)
219
+ expect(@output.valid?).to eq(true)
220
+ end
221
+
222
+ Then(/^both sym and tag have nil values$/) do
223
+ expect(@output.tag).to eq(nil)
224
+ expect(@output.sym).to eq(nil)
225
+ expect(@output.valid?).to eq(false)
226
+ end
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+
3
+ require 'bundler/setup'
4
+ require 'forkforge'
5
+ require 'forkforge/knife/string'
6
+ require 'rspec/expectations'
7
+
8
+ MAX_SCENARIOS = 10
9
+ scenario_times = {}
10
+
11
+ Around() do |scenario, block|
12
+ start = Time.now
13
+ block.call
14
+ scenario_times["#{scenario.feature.file}::#{scenario.name}"] = Time.now - start
15
+ end
16
+
17
+ at_exit do
18
+ max_scenarios = scenario_times.size > MAX_SCENARIOS ? MAX_SCENARIOS : scenario_times.size
19
+ puts '—'*20 + " top #{max_scenarios} slowest " + '—'*20
20
+ sorted_times = scenario_times.sort { |a, b| b[1] <=> a[1] }
21
+ sorted_times[0..max_scenarios - 1].each do |key, value|
22
+ puts "#{value.round(2)} #{key}"
23
+ end
24
+ end