headingify 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46b07b6c0913390f5e8e0d9b977ce499df45adb1
4
- data.tar.gz: 1b9f9823622578038a93d367bd40735ca3e33467
3
+ metadata.gz: 19c230f8069815d774ce08c44c8ce9fae9a8e5f9
4
+ data.tar.gz: 9f57a53a7b61750b719ff9c709bb9e9eade595bf
5
5
  SHA512:
6
- metadata.gz: 91a60d1388ba154dead5f07eac78da6bec1786648aafa207da1710238204b4f895366248fc6db1893c7f4a68ff43889f956f714a105ea6a7f7b0735468ae8461
7
- data.tar.gz: 6b1852d5fa94bcffe0c0789fbf3dd29a4c5290d971bebf4423a5421de6da2d496f5444ffa804e7b1af5f6b619ddf351949ddc353eee38b526fb0f12938a82814
6
+ metadata.gz: 738d7bf6f2fa74a28f0a6a60fde36b026eb3c38e52c1448d0daf45ea09ece2922d55d49c3badcc83f2d5af80f1f4bc35fff152f1ad4e08286a097f60747f3c4e
7
+ data.tar.gz: ac8b0bd78765728901be8fb2d6a01f36b1c8cd94d6513f69a6ccc785451f96895d64762764647af043add06c6bb1a576a8bb1716265c9c80cc616fd6951dc561
data/README.rdoc CHANGED
@@ -14,7 +14,7 @@ The latest version of Headingify can be installed with RubyGems:
14
14
 
15
15
  Add this line to your application's Gemfile:
16
16
 
17
- gem 'headingify'
17
+ gem 'headingify', '~> 1.2.0'
18
18
 
19
19
  == Usage
20
20
 
@@ -33,6 +33,32 @@ Headingify works on the String class, and can also be used in code:
33
33
  s = "a simple string, including the preposition 'with'.".headingify
34
34
  title = "folding of the \%CheY\% protein."; title.headingify!
35
35
 
36
+ To check if a String has already been headingified:
37
+
38
+ % s.headingify; s.headingified?
39
+ > true
40
+
41
+ This is beneficial when a String may be headingified twice, where the initial String contained escaped content:
42
+
43
+ s = "using the \%PI\% constant to access the Float variable".headingify
44
+ > "Using the PI Constant to Access the Float Variable"
45
+
46
+ # without safety (note the word "Pi" changes in case)
47
+ s.headingify
48
+ > "Using the Pi Constant to Access the Float Variable"
49
+
50
+ # with safety (nothing is changed, if previously headingified)
51
+ s.headingify! unless s.headingified?
52
+ > nil
53
+
54
+ # ...or more easily
55
+ s.headingify_safe # or #headingify_safe! for replacement
56
+ > nil
57
+
58
+ # ...and we still have our initial String, ta-da!
59
+ puts s
60
+ > "Using the PI Constant to Access the Float Variable"
61
+
36
62
  == License
37
63
 
38
64
  Headingify is released under the MIT license:
@@ -1,6 +1,9 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  class String
4
+ attr_accessor :headingified
5
+ alias_method :headingified?, :headingified
6
+
4
7
  def headingify
5
8
  #
6
9
  # built to syntactically supercede String.[titlecase|titleize]
@@ -68,10 +71,27 @@ class String
68
71
  end
69
72
  end
70
73
 
71
- working.join(" ")
74
+ result = working.join(" ")
75
+ result.headingified = true
76
+
77
+ return result
72
78
  end
73
79
 
74
80
  def headingify!
75
81
  replace self.headingify
82
+ self.headingified = true
83
+ return self
84
+ end
85
+
86
+ def headingify_safe
87
+ return self.headingify unless self.headingified?; nil
88
+ end
89
+
90
+ def headingify_safe!
91
+ unless self.headingified?
92
+ replace self.headingify
93
+ self.headingified = true
94
+ return self
95
+ end
76
96
  end
77
97
  end
@@ -1,8 +1,8 @@
1
1
  module Headingify
2
2
  TITLE = "Ruby String.headingify Core Extension"
3
- VERSION = "1.1.2"
4
- UPDATE = "2014-11-19"
5
- REVISION = "41"
3
+ VERSION = "1.2.0"
4
+ UPDATE = "2014-12-29"
5
+ REVISION = "42"
6
6
  USAGE = "headingify \"string\" | \"an \\%ESCAPED\\% string\""
7
7
  EXAMPLE_INPUT = "\"garlic is as \\%GOOD\\% as ten mothers\""
8
8
  EXAMPLE_OUTPUT = "Garlic Is as GOOD as Ten Mothers"
@@ -1,7 +1,7 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Headingify do
4
- it "should return the input String as a proper title (in code)" do
4
+ it "should return the input String as a proper title" do
5
5
  input = ["i'm dale, but you have to call me dragon.",
6
6
  "i swear, i'm so pissed off at my mom.",
7
7
  "as soon as she's of age, i'm putting her in a home.",
@@ -26,8 +26,18 @@ describe Headingify do
26
26
  "This Is a QuIcK Test",
27
27
  "PI"]
28
28
 
29
+ # test regular headingify and positive safety correlation
29
30
  input.each_with_index do |s, i|
30
31
  expect(s.headingify).to eq(output[i])
32
+ expect(s.headingify.headingified?).to be true
33
+ expect(s.headingify.headingify_safe).to be nil
34
+ end
35
+
36
+ # test safe headingify
37
+ input.each_with_index do |s, i|
38
+ expect(s.headingify_safe).to eq(output[i])
39
+ expect(s.headingify_safe.headingified?).to be true
40
+ expect(s.headingify_safe.headingify_safe).to be nil
31
41
  end
32
42
  end
33
43
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headingify
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Calo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-19 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec