to_sssi 0.1.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.
- data/README.md +10 -0
- data/Rakefile +75 -0
- data/lib/to_sssi.rb +36 -0
- metadata +75 -0
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "rake/gempackagetask"
|
3
|
+
require "rake/rdoctask"
|
4
|
+
|
5
|
+
require "spec"
|
6
|
+
require "spec/rake/spectask"
|
7
|
+
Spec::Rake::SpecTask.new do |t|
|
8
|
+
t.spec_opts = %w(--format specdoc --colour)
|
9
|
+
t.libs = ["spec"]
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
task :default => ["spec"]
|
14
|
+
|
15
|
+
# This builds the actual gem. For details of what all these options
|
16
|
+
# mean, and other ones you can add, check the documentation here:
|
17
|
+
#
|
18
|
+
# http://rubygems.org/read/chapter/20
|
19
|
+
#
|
20
|
+
spec = Gem::Specification.new do |s|
|
21
|
+
|
22
|
+
# Change these as appropriate
|
23
|
+
s.name = "to_sssi"
|
24
|
+
s.version = "0.1.0"
|
25
|
+
s.summary = "Convert Ruby objects into SSSI variables."
|
26
|
+
s.author = "Patrick Sinclair"
|
27
|
+
s.email = "patrick.sinclair@bbc.co.uk"
|
28
|
+
# s.homepage = "http://www.bbc.co.uk"
|
29
|
+
|
30
|
+
s.has_rdoc = true
|
31
|
+
# s.extra_rdoc_files = %w(README.md)
|
32
|
+
# s.rdoc_options = %w(--main README.md)
|
33
|
+
|
34
|
+
# Add any extra files to include in the gem (like your README)
|
35
|
+
s.files = %w(Rakefile README.md) + Dir.glob("{spec,lib/**/*}")
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
|
38
|
+
# If you want to depend on other gems, add them here, along with any
|
39
|
+
# relevant versions
|
40
|
+
# s.add_dependency("some_other_gem", "~> 0.1.0")
|
41
|
+
|
42
|
+
# If your tests use any gems, include them here
|
43
|
+
s.add_development_dependency("rspec")
|
44
|
+
end
|
45
|
+
|
46
|
+
# This task actually builds the gem. We also regenerate a static
|
47
|
+
# .gemspec file, which is useful if something (i.e. GitHub) will
|
48
|
+
# be automatically building a gem for this project. If you're not
|
49
|
+
# using GitHub, edit as appropriate.
|
50
|
+
#
|
51
|
+
# To publish your gem online, install the 'gemcutter' gem; Read more
|
52
|
+
# about that here: http://gemcutter.org/pages/gem_docs
|
53
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
54
|
+
pkg.gem_spec = spec
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Build the gemspec file #{spec.name}.gemspec"
|
58
|
+
task :gemspec do
|
59
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
60
|
+
File.open(file, "w") {|f| f << spec.to_ruby }
|
61
|
+
end
|
62
|
+
|
63
|
+
task :package => :gemspec
|
64
|
+
|
65
|
+
# Generate documentation
|
66
|
+
Rake::RDocTask.new do |rd|
|
67
|
+
|
68
|
+
rd.rdoc_files.include("lib/**/*.rb")
|
69
|
+
rd.rdoc_dir = "rdoc"
|
70
|
+
end
|
71
|
+
|
72
|
+
desc 'Clear out RDoc and generated packages'
|
73
|
+
task :clean => [:clobber_rdoc, :clobber_package] do
|
74
|
+
rm "#{spec.name}.gemspec"
|
75
|
+
end
|
data/lib/to_sssi.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
class NilClass
|
2
|
+
def to_sssi
|
3
|
+
end
|
4
|
+
end
|
5
|
+
|
6
|
+
class String
|
7
|
+
def to_sssi
|
8
|
+
escaped = self.gsub('$', '\$')
|
9
|
+
escaped.gsub!('"', '\"')
|
10
|
+
escaped.gsub!(/[‘’]/, "'")
|
11
|
+
escaped
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class TrueClass
|
16
|
+
def to_sssi
|
17
|
+
1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class FalseClass
|
22
|
+
def to_sssi
|
23
|
+
0
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Hash
|
28
|
+
def to_sssi
|
29
|
+
self.sort.to_a.map do |key, val|
|
30
|
+
value = (val.kind_of?(String) or
|
31
|
+
val.kind_of?(TrueClass) ||
|
32
|
+
val.kind_of?(FalseClass)) ? val.to_sssi : val
|
33
|
+
%[<!--#set var="#{key}" value="#{value}" -->]
|
34
|
+
end.join("\n")
|
35
|
+
end
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: to_sssi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Patrick Sinclair
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-05-04 00:00:00 +01:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
version: "0"
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
32
|
+
description:
|
33
|
+
email: patrick.sinclair@bbc.co.uk
|
34
|
+
executables: []
|
35
|
+
|
36
|
+
extensions: []
|
37
|
+
|
38
|
+
extra_rdoc_files: []
|
39
|
+
|
40
|
+
files:
|
41
|
+
- Rakefile
|
42
|
+
- README.md
|
43
|
+
- lib/to_sssi.rb
|
44
|
+
has_rdoc: true
|
45
|
+
homepage:
|
46
|
+
licenses: []
|
47
|
+
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
segments:
|
65
|
+
- 0
|
66
|
+
version: "0"
|
67
|
+
requirements: []
|
68
|
+
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 1.3.6
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Convert Ruby objects into SSSI variables.
|
74
|
+
test_files: []
|
75
|
+
|