sep 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,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ script: "bundle exec rake spec"
3
+ notifications:
4
+ email:
5
+ recipients:
6
+ - dan.richert@gmail.com
7
+ on_success: never
8
+ on_failure: always
9
+ rvm:
10
+ - 1.9.3-p448
11
+ - 2.0.0-p247
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in sep.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Dan Richert
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.
@@ -0,0 +1,52 @@
1
+ # Sep
2
+ [![Build Status](https://travis-ci.org/drichert/sep.png?branch=master)](https://travis-ci.org/drichert/sep)
3
+
4
+ Separates strings, parses punctuation and spacing
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem "sep"
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install sep
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ text = ' "I doubt, therefore I think, therefore I am."'
24
+
25
+ # Separate text
26
+ sep = Sep.load(text)
27
+
28
+ sep.words_data
29
+ #=> [
30
+ #=> { punc_pre: '"', word: "I", punc_post: "", space_post: " " },
31
+ #=> { punc_pre: "", word: "doubt", punc_post: ",", space_post: " " },
32
+ #=> { punc_pre: "", word: "therefore", punc_post: "", space_post: " " },
33
+ #=> { punc_pre: "", word: "I", punc_post: "", space_post: " " },
34
+ #=> { punc_pre: "", word: "think", punc_post: "," space_post: " " },
35
+ #=> { punc_pre: "", word: "therefore", punc_post: "", space_post: " " },
36
+ #=> { punc_pre: "", word: "I", punc_post: "", space_post: " " },
37
+ #=> { punc_pre: "", word: "am", punc_post: '."', space_post: "" }
38
+ #=> ]
39
+
40
+ sep.text #=> '"I doubt, therefore I think, therefore I am."'
41
+ sep.words #=> ["I", "doubt", "therefore", "I", "think", "therefore", "I", "am"]
42
+ sep.leading_space #=> " "
43
+ sep.space #=> [" ", " ", " ", " ", " ", " ", " ", " ", ""]
44
+ ```
45
+
46
+ ## Contributing
47
+
48
+ 1. Fork it
49
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
50
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
51
+ 4. Push to the branch (`git push origin my-new-feature`)
52
+ 5. Create new Pull Request
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new("spec")
5
+ task(default: :spec)
@@ -0,0 +1,8 @@
1
+ require "sep/version"
2
+ require "sep/separator"
3
+
4
+ module Sep
5
+ def self.load(text)
6
+ Separator.new(text)
7
+ end
8
+ end
@@ -0,0 +1,38 @@
1
+ module Sep
2
+ class Separator
3
+ attr_reader :original_text, :words_data
4
+
5
+ ANALYSIS = /([[:punct:]\s]*)(\w+)([[:punct:]]*)(\s*)/
6
+
7
+ # text - String text to separate
8
+ def initialize(text)
9
+ @original_text = text
10
+
11
+ analyze
12
+ end
13
+
14
+ def leading_space
15
+ original_text.match(/(\s*)/).captures[0]
16
+ end
17
+
18
+ def whitespace
19
+ [leading_space] + words_data.map {|wd| wd[:space_post] }
20
+ end
21
+
22
+ private
23
+
24
+ def scanned_text
25
+ original_text.scan(ANALYSIS)
26
+ end
27
+
28
+ def analyze
29
+ @words_data ||= scanned_text.map do |word_data|
30
+ { punc_pre: word_data[0],
31
+ word: word_data[1],
32
+ punc_post: word_data[2],
33
+ space_post: word_data[3]
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Sep
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sep/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "sep"
8
+ gem.version = Sep::VERSION
9
+ gem.authors = ["Dan Richert"]
10
+ gem.email = ["dan.richert@gmail.com"]
11
+ gem.description = %q{Separates strings and puts them back together}
12
+ gem.summary = %q{Separate and reassemble strings based on whitespace}
13
+ gem.homepage = "https://github.com/drichert/sep"
14
+
15
+ gem.add_dependency("rake")
16
+
17
+ gem.add_development_dependency("rspec")
18
+
19
+ gem.files = `git ls-files`.split($/)
20
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
21
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
22
+ gem.require_paths = ["lib"]
23
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe Sep do
4
+ describe ".load" do
5
+ subject { Sep.load(RSpec::Sep.text) }
6
+
7
+ it { should be_a(Sep::Separator) }
8
+ end
9
+ end
@@ -0,0 +1,57 @@
1
+ require "spec_helper"
2
+
3
+ describe Sep::Separator do
4
+ let(:text) { RSpec::Sep.text }
5
+
6
+ let(:sep) { described_class.new(text) }
7
+
8
+ describe "#original_text" do
9
+ subject { sep.original_text }
10
+
11
+ it { should be_a(String) }
12
+ end
13
+
14
+ describe "#words_data" do
15
+ let(:words) { described_class.new(text).words_data }
16
+
17
+ subject { words }
18
+
19
+ it { should be_an(Array) }
20
+
21
+ describe "element" do
22
+ subject { words.first }
23
+
24
+ it { should be_a(Hash) }
25
+
26
+ describe "keys" do
27
+ specify ":punc_pre, :word, :punc_post, :space_post" do
28
+ # Convoluted example description parsing
29
+ keys = example.metadata[:description_args][0]
30
+ .split(/, :|:/)
31
+ .reject(&:empty?)
32
+
33
+ subject.keys.should include(*keys.map(&:to_sym))
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ describe "#words" do
40
+ end
41
+
42
+ describe "#leading_space" do
43
+ subject { described_class.new(text).leading_space }
44
+
45
+ it { should == "\n\n" }
46
+ end
47
+
48
+ describe "#whitespace" do
49
+ let(:whitespace) { described_class.new(text).whitespace }
50
+
51
+ describe "0..4" do
52
+ subject { whitespace.slice(0..4) }
53
+
54
+ it { should match_array(["\n\n", " ", " ", " ", "\n\n\n"]) }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ require "rspec"
2
+ require "bundler/setup"
3
+
4
+ require "sep"
5
+
6
+ module RSpec::Sep
7
+ def self.text
8
+ path = File.expand_path("../support/text", __FILE__)
9
+
10
+ File.read(path)
11
+ end
12
+ end
13
+
14
+ RSpec.configure do |c|
15
+ c.treat_symbols_as_metadata_keys_with_true_values = true
16
+ c.color_enabled = true
17
+ end
@@ -0,0 +1,23 @@
1
+
2
+
3
+ THE MEANING OF ALCHEMY
4
+
5
+
6
+ The Aim of Alchemy.
7
+
8
+ § =1.= Alchemy is generally understood to have been that art whose end
9
+ was the transmutation of the so-called base metals into gold by means of
10
+ an ill-defined something called the Philosopher’s Stone; but even from a
11
+ purely physical standpoint, this is a somewhat superficial view. Alchemy
12
+ was both a philosophy and an experimental science, and the transmutation
13
+ of the metals was its end only in that this would give the final proof
14
+ of the alchemistic hypotheses; in other words, Alchemy, considered from
15
+ the physical standpoint, was the attempt to demonstrate experimentally
16
+ on the material plane the validity of a certain philosophical view of
17
+ the Cosmos. We see the genuine scientific spirit in the saying of one of
18
+ the alchemists: “Would to God . . . all men might become adepts in our
19
+ Art--for then gold, the great idol of mankind, would lose its value, and
20
+ we should prize it only for its scientific teaching.”[6] Unfortunately,
21
+ however, not many alchemists came up to this ideal; and for the majority
22
+ of them, Alchemy did mean merely the possibility of making gold cheaply
23
+ and gaining untold wealth.
metadata ADDED
@@ -0,0 +1,96 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sep
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dan Richert
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-08-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
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
+ description: Separates strings and puts them back together
47
+ email:
48
+ - dan.richert@gmail.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .travis.yml
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - lib/sep.rb
60
+ - lib/sep/separator.rb
61
+ - lib/sep/version.rb
62
+ - sep.gemspec
63
+ - spec/sep_spec.rb
64
+ - spec/separator_spec.rb
65
+ - spec/spec_helper.rb
66
+ - spec/support/text
67
+ homepage: https://github.com/drichert/sep
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.23
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Separate and reassemble strings based on whitespace
91
+ test_files:
92
+ - spec/sep_spec.rb
93
+ - spec/separator_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/support/text
96
+ has_rdoc: