punctuation_name 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: 684c3f5e13875e1a1d76b78ca8975d559a723728637135208c298af5882b73ad
4
- data.tar.gz: f65a627fca39f82c93bd5e25a9cbd2e00c03045bd0940d3c889db1991bdb5753
3
+ metadata.gz: 5e7b2b1922abd3559422a903362c06f5390b31b5d99802fc5a6d1e8ccc27fa24
4
+ data.tar.gz: e78a647d187a1cd9d722da7839a9dbee60e0ee324472dc20f8d84730ba78e3fb
5
5
  SHA512:
6
- metadata.gz: bb02cfe153b846d167a62bae21d2ab49df37947f947a564b1a6ccdb4732d0066302c3285f3c2c1cb2c1f4df583730b045189e79bb4c21d6355fb3be91efdc9cc
7
- data.tar.gz: c98fadd0960ac792566a9f7ff30c47a74e2942992dd1425c3d41264d04f641eb4ecd1748e539b3848b76858ea6ee0f191d23ff8004c4542265154825d58b98b8
6
+ metadata.gz: 178f1bd860503e47aaabbffde827ea663eed2c96dfef7de38fc957aa2ea4bc350da97497f29ab96af7679dec215e5416442e74ebb0d5a2bec196313364d914a7
7
+ data.tar.gz: 3940c99ecdf209376e1e5857c6992ecf2145cd43a0a240758ee5bb52bffb45177c5d7c7c5e67611983f330bacbe56aef61b8c504c0893d1a7a7944ddd9deb846
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## 1.1.0 (January 24, 2019)
2
+
3
+ IMPROVEMENTS:
4
+
5
+ * Move the code inside of a module namespace. ([@TGWolf][])
6
+ * Extend the strings class so that str.punctuation_name works. ([@TGWolf][])
7
+ * Update the documentation. ([@TGWolf][])
8
+
1
9
  ## 1.0.0 (January 24, 2019)
2
10
 
3
11
  * Initial Release ([@TGWolf][])
data/README.md CHANGED
@@ -33,9 +33,13 @@ Or install it yourself as:
33
33
  You can use the default built in dictionary which is UK/English.
34
34
 
35
35
  ```ruby
36
- p = PunctuationName.new
36
+ require 'punctuation_name'
37
37
 
38
- puts p.name('!')
38
+ puts PunctuationName::Punctuation.name('!')
39
+
40
+ # or
41
+
42
+ puts '!'.punctuation_name
39
43
  ```
40
44
 
41
45
  ### Extended Usage
@@ -43,9 +47,13 @@ You can use the default built in dictionary which is UK/English.
43
47
  You can also use the built-in US dictionary.
44
48
 
45
49
  ```ruby
46
- p = PunctuationName.new
50
+ require 'punctuation_name'
51
+
52
+ puts PunctuationName::Punctuation.name('!', 'us')
53
+
54
+ # or
47
55
 
48
- puts p.name('!', 'us')
56
+ puts '!'.punctuation_name('us')
49
57
  ```
50
58
 
51
59
  ### Advanced Usage
@@ -53,9 +61,15 @@ You can also use the built-in US dictionary.
53
61
  You can define your own dictionary, the below example just does a single item, but you can make the set as large as you need.
54
62
 
55
63
  ```
56
- p = PunctuationName.new
57
- p.custom('custom', { '!' => 'shouty marker' })
58
- puts p.name('!', 'custom')
64
+ require 'punctuation_name'
65
+
66
+ PunctuationName::Punctuation.custom('custom', { '!' => 'shouty marker' })
67
+
68
+ puts PunctuationName::Punctuation.name('!', 'custom')
69
+
70
+ # or
71
+
72
+ puts '!'.punctuation_name('custom')
59
73
  ```
60
74
 
61
75
  ## Return Value
data/exe/punctuation_name CHANGED
@@ -10,12 +10,10 @@ require 'punctuation_name'
10
10
  # -------------------------------------------------------------------------------- #
11
11
 
12
12
  def punctuation_name(options)
13
- pn = PunctuationName.new
14
-
15
13
  if options[:dictionary]
16
- puts pn.name(options[:punctuation], options[:dictionary])
14
+ puts PunctuationName::Punctuation.name(options[:punctuation], options[:dictionary])
17
15
  else
18
- puts pn.name(options[:punctuation])
16
+ puts PunctuationName::Punctuation.name(options[:punctuation])
19
17
  end
20
18
  end
21
19
 
@@ -1,31 +1,39 @@
1
- require 'punctuation_name/version'
2
- require 'punctuation_name/dicts/uk.rb'
3
- require 'punctuation_name/dicts/us.rb'
1
+ require_relative 'punctuation_name/version'
2
+ require_relative 'punctuation_name/strings'
3
+ require_relative 'punctuation_name/dicts/uk.rb'
4
+ require_relative 'punctuation_name/dicts/us.rb'
4
5
 
5
6
  #
6
7
  # Add docs
7
8
  #
8
- class PunctuationName
9
- def initialize
10
- @dict = {}
9
+ module PunctuationName
10
+ #
11
+ # To go here
12
+ #
13
+ class Punctuation
14
+ $dict = {}
11
15
 
12
- @dict['uk'] = UK_NAMES
13
- @dict['us'] = US_NAMES
14
- end
16
+ def self.setup
17
+ $dict['uk'] = UK_NAMES
18
+ $dict['us'] = US_NAMES
19
+ end
15
20
 
16
- def custom(name, dict)
17
- @dict[name] = dict
18
- end
21
+ def self.custom(name, dict)
22
+ $dict[name] = dict
23
+ end
19
24
 
20
- def name_from_dictionary(punctuation, dict)
21
- dict.key?(punctuation) ? dict[punctuation] : punctuation
22
- end
25
+ def self.name_from_dictionary(punctuation, dict)
26
+ dict.key?(punctuation) ? dict[punctuation] : punctuation
27
+ end
28
+
29
+ def self.name(punctuation, dict_name = 'uk')
30
+ setup
23
31
 
24
- def name(punctuation, dict_name = 'uk')
25
- dict_name = 'uk' if dict_name.empty?
32
+ dict_name = 'uk' if dict_name.empty?
26
33
 
27
- return punctuation unless @dict.key?(dict_name)
34
+ return punctuation unless $dict.key?(dict_name)
28
35
 
29
- name_from_dictionary(punctuation, @dict[dict_name])
36
+ name_from_dictionary(punctuation, $dict[dict_name])
37
+ end
30
38
  end
31
39
  end
@@ -1,4 +1,4 @@
1
- class PunctuationName
1
+ module PunctuationName
2
2
  UK_NAMES = { '!' => 'exclamation mark',
3
3
  '@' => 'at sign',
4
4
  '#' => 'hash',
@@ -1,4 +1,4 @@
1
- class PunctuationName
1
+ module PunctuationName
2
2
  US_NAMES = { '!' => 'exclamation mark',
3
3
  '@' => 'at sign',
4
4
  '#' => 'hash',
@@ -0,0 +1,12 @@
1
+ #
2
+ # Overload the string class
3
+ #
4
+ class String
5
+ def punctuation_name(dict = 'uk')
6
+ PunctuationName::Punctuation.name(self, dict)
7
+ end
8
+
9
+ def punctuation_name!(dict = 'uk')
10
+ replace punctuation_name(dict)
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
- class PunctuationName
2
- VERSION = '1.0.0'.freeze
1
+ module PunctuationName
2
+ VERSION = '1.1.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: punctuation_name
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Gurney aka Wolf
@@ -78,6 +78,7 @@ files:
78
78
  - lib/punctuation_name.rb
79
79
  - lib/punctuation_name/dicts/uk.rb
80
80
  - lib/punctuation_name/dicts/us.rb
81
+ - lib/punctuation_name/strings.rb
81
82
  - lib/punctuation_name/version.rb
82
83
  - punctuation_name.gemspec
83
84
  homepage: https://github.com/WolfSoftware/punctuation_name