quote_unquote 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ *.gem
2
+ .bundle
3
+ *.swp
4
+ *.swo
5
+ Gemfile.lock
6
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in quote_unquote.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Junegunn Choi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown ADDED
@@ -0,0 +1,26 @@
1
+ # quote_unquote
2
+ Wraps (and unwraps) strings with quotes.
3
+
4
+ ## Installation
5
+
6
+ ```ruby
7
+ gem install quote_unquote
8
+ ```
9
+
10
+ ## Examples
11
+
12
+ ```ruby
13
+ require 'quote_unquote'
14
+
15
+ "hello".q # 'hello'
16
+ "hello".qq # "hello"
17
+
18
+ "'hello'".uq # hello
19
+ '"hello"'.uqq # hello
20
+ ```
21
+
22
+ ## Copyright
23
+
24
+ Copyright (c) 2011 Junegunn Choi. See LICENSE.txt for
25
+ further details.
26
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rake/testtask'
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'test'
6
+ test.pattern = 'test/**/test_*.rb'
7
+ test.verbose = true
8
+ end
9
+
@@ -0,0 +1,23 @@
1
+ module QuoteUnquote
2
+ module StringExtension
3
+ # Wraps the String with single quotes
4
+ def q
5
+ %['#{self}']
6
+ end
7
+
8
+ # Wraps the String with double quotes
9
+ def qq
10
+ %["#{self}"]
11
+ end
12
+
13
+ # Unwraps single quotes
14
+ def uq
15
+ self.gsub(/\A'|'\Z/, '')
16
+ end
17
+
18
+ # Unwraps double quotes
19
+ def uqq
20
+ self.gsub(/\A"|"\Z/, '')
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module QuoteUnquote
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,7 @@
1
+ require "quote_unquote/version"
2
+ require "quote_unquote/string_ext"
3
+
4
+ class String
5
+ include QuoteUnquote::StringExtension
6
+ end
7
+
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "quote_unquote/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "quote_unquote"
7
+ s.version = QuoteUnquote::VERSION
8
+ s.authors = ["Junegunn Choi"]
9
+ s.email = ["junegunn.c@gmail.com"]
10
+ s.homepage = "https://github.com/junegunn/quote_unquote"
11
+ s.summary = %q{Wraps and unwraps strings with quotes}
12
+ s.description = %q{Wraps and unwraps strings with quotes}
13
+
14
+ s.rubyforge_project = "quote_unquote"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
4
+ require 'quote_unquote'
5
+
6
+ class TestQuoteUnquote < Test::Unit::TestCase
7
+ def test_q
8
+ assert_equal %['hello'], "hello".q
9
+ assert_equal %['hello\nworld'], "hello\nworld".q
10
+ end
11
+
12
+ def test_qq
13
+ assert_equal %["hello"], "hello".qq
14
+ assert_equal %["hello\nworld"], "hello\nworld".qq
15
+ end
16
+
17
+ def test_uq
18
+ assert_equal %[hello], "'hello'".uq
19
+ assert_equal %[hello'\n'world], "'hello'\n'world'".uq
20
+ end
21
+
22
+ def test_uqq
23
+ assert_equal %[hello], '"hello"'.uqq
24
+ assert_equal %[hello"\n"world], "\"hello\"\n\"world\"".uqq
25
+ end
26
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quote_unquote
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Junegunn Choi
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-17 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: Wraps and unwraps strings with quotes
15
+ email:
16
+ - junegunn.c@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - Gemfile
23
+ - LICENSE.txt
24
+ - README.markdown
25
+ - Rakefile
26
+ - lib/quote_unquote.rb
27
+ - lib/quote_unquote/string_ext.rb
28
+ - lib/quote_unquote/version.rb
29
+ - quote_unquote.gemspec
30
+ - test/test_quote_unquote.rb
31
+ homepage: https://github.com/junegunn/quote_unquote
32
+ licenses: []
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ required_rubygems_version: !ruby/object:Gem::Requirement
44
+ none: false
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ requirements: []
50
+ rubyforge_project: quote_unquote
51
+ rubygems_version: 1.8.10
52
+ signing_key:
53
+ specification_version: 3
54
+ summary: Wraps and unwraps strings with quotes
55
+ test_files:
56
+ - test/test_quote_unquote.rb