pilcrow 1.0.0
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/Gemfile +15 -0
- data/History.txt +3 -0
- data/Rakefile +18 -0
- data/bin/pilcrow +9 -0
- data/lib/pilcrow.rb +37 -0
- data/lib/pilcrow/version.rb +5 -0
- data/pilcrow.gemspec +19 -0
- data/vendor/icu4j-53_1.jar +0 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8108b88e41a63586b6e00894405b8792cf304e94
|
4
|
+
data.tar.gz: 5d6384c13a831952711112909bd9d4f0b0fd7064
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7041cb2642e83450e2b51940ab46add7ab7193e5a12254e1fc2592f0a57d6af7abdeaeeff0f4fd60ff0cbca324d2b285d2384dd6520a62855bebd2c25b293bed
|
7
|
+
data.tar.gz: f1f5d0bc6aa74ad46ecffca150a6a00f0cd9a0c0a4694a4f000e4db2ca3817bf65c9f63ba499343ee14fa54f57e3fff1614078d9553d7dcacb8b2110d0fd7630
|
data/Gemfile
ADDED
data/History.txt
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
4
|
+
|
5
|
+
require 'bundler'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
require 'rubygems/package_task'
|
8
|
+
|
9
|
+
require './lib/pilcrow'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
|
15
|
+
desc 'Run specs'
|
16
|
+
RSpec::Core::RakeTask.new do |t|
|
17
|
+
t.pattern = './spec/**/*_spec.rb'
|
18
|
+
end
|
data/bin/pilcrow
ADDED
data/lib/pilcrow.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
require File.expand_path('../../vendor/icu4j-53_1.jar', __FILE__)
|
4
|
+
|
5
|
+
java_import 'com.ibm.icu.util.ULocale'
|
6
|
+
java_import 'com.ibm.icu.text.BreakIterator'
|
7
|
+
|
8
|
+
module Pilcrow
|
9
|
+
class << self
|
10
|
+
|
11
|
+
def process(text, locale)
|
12
|
+
insert_markers(segment_text(text, locale))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def segment_text(text, locale)
|
18
|
+
brkiter = BreakIterator.getWordInstance(ULocale.new(locale))
|
19
|
+
brkiter.setText(text)
|
20
|
+
start = brkiter.first
|
21
|
+
segments = []
|
22
|
+
|
23
|
+
until (stop = brkiter.next) == BreakIterator::DONE
|
24
|
+
segments << text[start...stop]
|
25
|
+
start = stop
|
26
|
+
end
|
27
|
+
|
28
|
+
segments
|
29
|
+
end
|
30
|
+
|
31
|
+
def insert_markers(segments)
|
32
|
+
# pilcrow character: http://en.wikipedia.org/wiki/Pilcrow
|
33
|
+
segments.join("\u00B6")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
data/pilcrow.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
2
|
+
require 'pilcrow/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "pilcrow"
|
6
|
+
s.version = ::Pilcrow::VERSION
|
7
|
+
s.authors = ["Cameron Dutro"]
|
8
|
+
s.email = ["camertron@gmail.com"]
|
9
|
+
s.homepage = "http://github.com/camertron"
|
10
|
+
|
11
|
+
s.description = s.summary = "Automatically inserts non-with spaces between words in text from STDIN"
|
12
|
+
|
13
|
+
s.platform = Gem::Platform::RUBY
|
14
|
+
s.has_rdoc = true
|
15
|
+
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.files = Dir["{lib,spec,vendor}/**/*", "Gemfile", "History.txt", "README.md", "Rakefile", "pilcrow.gemspec"]
|
18
|
+
s.executables << 'pilcrow'
|
19
|
+
end
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pilcrow
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Dutro
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Automatically inserts non-with spaces between words in text from STDIN
|
14
|
+
email:
|
15
|
+
- camertron@gmail.com
|
16
|
+
executables:
|
17
|
+
- pilcrow
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- lib/pilcrow.rb
|
22
|
+
- lib/pilcrow/version.rb
|
23
|
+
- vendor/icu4j-53_1.jar
|
24
|
+
- Gemfile
|
25
|
+
- History.txt
|
26
|
+
- Rakefile
|
27
|
+
- pilcrow.gemspec
|
28
|
+
- bin/pilcrow
|
29
|
+
homepage: http://github.com/camertron
|
30
|
+
licenses: []
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.1.9
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Automatically inserts non-with spaces between words in text from STDIN
|
52
|
+
test_files: []
|