submarine 0.0.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/submarine/configuration.rb +5 -5
- data/lib/submarine/submarine.rb +6 -6
- metadata +55 -56
- checksums.yaml +0 -7
@@ -1,7 +1,7 @@
|
|
1
1
|
class Submarine::Configuration
|
2
2
|
|
3
3
|
# Acceptable accessors.
|
4
|
-
attr_accessor :format_key, :
|
4
|
+
attr_accessor :format_key, :left_delimiter, :right_delimiter, :substitutions
|
5
5
|
|
6
6
|
# Constructs a new Configuration instance.
|
7
7
|
# Merges passed in options hash, sets instance variables.
|
@@ -17,8 +17,8 @@ class Submarine::Configuration
|
|
17
17
|
def self.defaults
|
18
18
|
{
|
19
19
|
format_key: :text, # The key representing the string to be formatted
|
20
|
-
|
21
|
-
|
20
|
+
left_delimiter: '[[', # The left-side matching string, ie: '[[name]]'
|
21
|
+
right_delimiter: ']]', # The right-side matching string, ie: '[[name]]'
|
22
22
|
substitutions: {} # Optional global default substitutions
|
23
23
|
}
|
24
24
|
end
|
@@ -35,8 +35,8 @@ private
|
|
35
35
|
#
|
36
36
|
def set_instance_variables options
|
37
37
|
@format_key = options[:format_key].to_sym
|
38
|
-
@
|
39
|
-
@
|
38
|
+
@left_delimiter = options[:left_delimiter].to_s
|
39
|
+
@right_delimiter = options[:right_delimiter].to_s
|
40
40
|
@substitutions = options[:substitutions]
|
41
41
|
end
|
42
42
|
|
data/lib/submarine/submarine.rb
CHANGED
@@ -41,7 +41,7 @@ class Submarine
|
|
41
41
|
#
|
42
42
|
# Example:
|
43
43
|
# >> Submarine.config
|
44
|
-
# => #<Submarine::Configuration @format_key=:text, @
|
44
|
+
# => #<Submarine::Configuration @format_key=:text, @left_delimiter="[[", @right_delimiter="]]", @substitutions={}>
|
45
45
|
#
|
46
46
|
def config
|
47
47
|
@config ||= Configuration.new
|
@@ -55,13 +55,13 @@ class Submarine
|
|
55
55
|
# # config/initializers/submarine.rb <-- if you're using Rails, say
|
56
56
|
# Submarine.configure do |config|
|
57
57
|
# config.format_key = :copy
|
58
|
-
# config.
|
59
|
-
# config.
|
58
|
+
# config.left_delimiter = '<^'
|
59
|
+
# config.right_delimiter = '^>'
|
60
60
|
# config.substitutions = {company: 'Submarine Inc, Co'}
|
61
61
|
# end
|
62
62
|
#
|
63
63
|
# >> Submarine.config
|
64
|
-
# => #<Submarine::Configuration @format_key=:copy, @
|
64
|
+
# => #<Submarine::Configuration @format_key=:copy, @left_delimiter="<^", @right_delimiter="^>", @substitutions={company: 'Submarine Inc, Co'}>
|
65
65
|
#
|
66
66
|
def configure
|
67
67
|
yield config
|
@@ -101,7 +101,7 @@ private
|
|
101
101
|
# => "[[name]]"
|
102
102
|
#
|
103
103
|
def match key
|
104
|
-
"#{config.
|
104
|
+
"#{config.left_delimiter}#{key}#{config.right_delimiter}"
|
105
105
|
end
|
106
106
|
|
107
107
|
# Returns the replacement for gsub with passed in key.
|
@@ -119,7 +119,7 @@ private
|
|
119
119
|
# Example:
|
120
120
|
# >> sub = Submarine.new(text: 'Hello, my name is [[name]].', name: 'Joe')
|
121
121
|
# >> sub.send(:config)
|
122
|
-
# => #<Submarine::Configuration @format_key=:text, @
|
122
|
+
# => #<Submarine::Configuration @format_key=:text, @left_delimiter="[[", @right_delimiter="]]", @substitutions={}>
|
123
123
|
#
|
124
124
|
def config
|
125
125
|
self.class.config
|
metadata
CHANGED
@@ -1,90 +1,89 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: submarine
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 1.0.0
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Caleb K Matthiesen
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
date: 2014-10-11 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
14
16
|
name: facets
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 2.9.3
|
20
|
-
type: :runtime
|
21
17
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
26
23
|
version: 2.9.3
|
27
|
-
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
28
27
|
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.3'
|
34
|
-
type: :development
|
35
28
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 5.4.2
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "10.3"
|
48
35
|
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: minitest
|
49
39
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
54
45
|
version: 5.4.2
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
55
48
|
description: A lightweight string formatter.
|
56
49
|
email: c@calebkm.com
|
57
50
|
executables: []
|
51
|
+
|
58
52
|
extensions: []
|
53
|
+
|
59
54
|
extra_rdoc_files: []
|
60
|
-
|
55
|
+
|
56
|
+
files:
|
61
57
|
- lib/submarine.rb
|
62
|
-
- lib/submarine/configuration.rb
|
63
58
|
- lib/submarine/exceptions.rb
|
59
|
+
- lib/submarine/configuration.rb
|
64
60
|
- lib/submarine/submarine.rb
|
65
61
|
homepage: http://www.submarine-gem.org
|
66
|
-
licenses:
|
62
|
+
licenses:
|
67
63
|
- MIT
|
68
|
-
metadata: {}
|
69
64
|
post_install_message:
|
70
65
|
rdoc_options: []
|
71
|
-
|
66
|
+
|
67
|
+
require_paths:
|
72
68
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
-
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
75
72
|
- - ">="
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
-
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: "0"
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
80
78
|
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version:
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: "0"
|
83
81
|
requirements: []
|
82
|
+
|
84
83
|
rubyforge_project:
|
85
|
-
rubygems_version:
|
84
|
+
rubygems_version: 1.8.25
|
86
85
|
signing_key:
|
87
|
-
specification_version:
|
86
|
+
specification_version: 3
|
88
87
|
summary: Deep sea string substitution.
|
89
88
|
test_files: []
|
90
|
-
|
89
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 35a13bbaed8ceffacdcd6e3f96916dca97245ad0
|
4
|
-
data.tar.gz: 22222a0a7ac87624c64afc8fd100e3c222fb0710
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: faeb1a6de9fc7b1264b3dc067e7e936a1084e37c17d42ee2120452a2cd9a33c7a0415763b887fd06740fdd3a3b6e4ef58e5d46ecc38000dfd5cba9b0b1ceb89d
|
7
|
-
data.tar.gz: 8998375b0f98303823a2ad9aace1645c690357d2f3dbcbe38cd18dbf7b5deee85d7a8d85e8693d2a4ff0e4e393861d0d6c270eaf0fe5be5d9a6b61caafcda514
|