-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 11be9a0
Showing
13 changed files
with
217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
== 0.0.1 2009-01-23 | ||
|
||
* 1 major enhancement: | ||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
History.txt | ||
Manifest.txt | ||
PostInstall.txt | ||
README.rdoc | ||
Rakefile | ||
lib/string_tokenizer.rb | ||
script/console | ||
script/destroy | ||
script/generate | ||
spec/spec.opts | ||
spec/spec_helper.rb | ||
spec/string_tokenizer_spec.rb | ||
tasks/rspec.rake |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
For more information on string_tokenizer, see http://string_tokenizer.rubyforge.org | ||
|
||
NOTE: Change this information in PostInstall.txt | ||
You can also delete it if you don't want it. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
= string_tokenizer | ||
|
||
* FIX (url) | ||
|
||
== DESCRIPTION: | ||
|
||
FIX (describe your package) | ||
|
||
== FEATURES/PROBLEMS: | ||
|
||
* FIX (list of features or problems) | ||
|
||
== SYNOPSIS: | ||
|
||
FIX (code sample of usage) | ||
|
||
== REQUIREMENTS: | ||
|
||
* FIX (list of requirements) | ||
|
||
== INSTALL: | ||
|
||
* FIX (sudo gem install, anything else) | ||
|
||
== LICENSE: | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2009 FIXME full name | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f } | ||
require File.dirname(__FILE__) + '/lib/string_templater' | ||
|
||
# Generate all the Rake tasks | ||
# Run 'rake -T' to see list of generated tasks (from gem root directory) | ||
$hoe = Hoe.new('string_templater', StringTemplater::VERSION) do |p| | ||
p.developer('FIXME full name', 'FIXME email') | ||
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n") | ||
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required | ||
p.rubyforge_name = p.name # TODO this is default value | ||
# p.extra_deps = [ | ||
# ['activesupport','>= 2.0.2'], | ||
# ] | ||
p.extra_dev_deps = [ | ||
['newgem', ">= #{::Newgem::VERSION}"] | ||
] | ||
|
||
p.clean_globs |= %w[**/.DS_Store tmp *.log] | ||
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}" | ||
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc') | ||
p.rsync_args = '-av --delete --ignore-errors' | ||
end | ||
|
||
require 'newgem/tasks' # load /tasks/*.rake | ||
Dir['tasks/**/*.rake'].each { |t| load t } | ||
|
||
# TODO - want other tests/tasks run by default? Add them to the list | ||
# task :default => [:spec, :features] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
$:.unshift(File.dirname(__FILE__)) unless | ||
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__))) | ||
|
||
module StringTemplater | ||
VERSION = '0.0.1' | ||
def tokenize(context) | ||
self.gsub(/\$[^ ]*/) { |match| | ||
context[match[1..-1].to_sym] | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env ruby | ||
# File: script/console | ||
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb' | ||
|
||
libs = " -r irb/completion" | ||
# Perhaps use a console_lib to store any extra methods I may want available in the cosole | ||
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}" | ||
libs << " -r #{File.dirname(__FILE__) + '/../lib/string_tokenizer.rb'}" | ||
puts "Loading string_tokenizer gem" | ||
exec "#{irb} #{libs} --simple-prompt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
begin | ||
require 'rubigen' | ||
rescue LoadError | ||
require 'rubygems' | ||
require 'rubigen' | ||
end | ||
require 'rubigen/scripts/destroy' | ||
|
||
ARGV.shift if ['--help', '-h'].include?(ARGV[0]) | ||
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] | ||
RubiGen::Scripts::Destroy.new.run(ARGV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/usr/bin/env ruby | ||
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..')) | ||
|
||
begin | ||
require 'rubigen' | ||
rescue LoadError | ||
require 'rubygems' | ||
require 'rubigen' | ||
end | ||
require 'rubigen/scripts/generate' | ||
|
||
ARGV.shift if ['--help', '-h'].include?(ARGV[0]) | ||
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit] | ||
RubiGen::Scripts::Generate.new.run(ARGV) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
--colour |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
begin | ||
require 'spec' | ||
rescue LoadError | ||
require 'rubygems' | ||
gem 'rspec' | ||
require 'spec' | ||
end | ||
|
||
$:.unshift(File.dirname(__FILE__) + '/../lib') | ||
require 'string_templater' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
require File.dirname(__FILE__) + '/spec_helper.rb' | ||
|
||
describe StringTemplater do | ||
def tokenize(string, context = {}) | ||
string.extend(StringTemplater).tokenize(context) | ||
end | ||
context "with no tokens" do | ||
it "returns blank string if string is blank" do | ||
tokenize("").should == "" | ||
end | ||
it "returns string unchanged" do | ||
tokenize("hello, world").should == "hello, world" | ||
end | ||
end | ||
context "with one token" do | ||
it "replaces token with empty string if no value in context" do | ||
tokenize("$name").should == "" | ||
end | ||
it "replaces token with value from context" do | ||
tokenize("$name", :name => 'corey').should == 'corey' | ||
end | ||
it "leaves rest of string unchanged" do | ||
tokenize("my name is $name", :name => 'corey').should == 'my name is corey' | ||
end | ||
end | ||
context "with two tokens" do | ||
it "replaces each token with the value from the context" do | ||
tokenize("$name loves $food", :name => 'corey', :food => 'bacon').should == | ||
"corey loves bacon" | ||
end | ||
it "replaces with blank string the tokens that have no value in context" do | ||
tokenize("$name loves $food1 and $food2", :name => 'corey').should == | ||
"corey loves and " | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
begin | ||
require 'spec' | ||
rescue LoadError | ||
require 'rubygems' | ||
require 'spec' | ||
end | ||
begin | ||
require 'spec/rake/spectask' | ||
rescue LoadError | ||
puts <<-EOS | ||
To use rspec for testing you must install rspec gem: | ||
gem install rspec | ||
EOS | ||
exit(0) | ||
end | ||
|
||
desc "Run the specs under spec/models" | ||
Spec::Rake::SpecTask.new do |t| | ||
t.spec_opts = ['--options', "spec/spec.opts"] | ||
t.spec_files = FileList['spec/**/*_spec.rb'] | ||
end |