hoodie 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8239c5f1758d3b1410a3fff7cf54a0cfd1da5f72
4
- data.tar.gz: ba500bccbbb541fb088a03306c9c1bbc7b975cc0
3
+ metadata.gz: f676e87cf9a6241c2607f7eead7c60e992723742
4
+ data.tar.gz: c74b9f4fd735a31eb9aa29faca59e91f3b514182
5
5
  SHA512:
6
- metadata.gz: 1a604c03ae6205db87d7efa9d47e12f922ea2dc8140ab95694c944feaf0ae81945e4b20c16616414288f1517818300c9616c452b8678e1fa59af7e6fc32d6521
7
- data.tar.gz: 59fdb057c73eafd26b40b8878299f28a7fc0834f0f3e83bc472b07c2a1dd7633186c2da1258c7152d0d53034c83c26f7e8c51fe0740d38fb6743a6109d9e952f
6
+ metadata.gz: c1132afa221a4facb28f9a76228f81e2da35702972c53ee7f5dd17fc7899f6a0b88ccf953ae6a73676b3eeec8d5d41175d9e2c8aa1a8d26da59f629a83b2f5ba
7
+ data.tar.gz: 41139176977147cbc12b9759ac869d3bc48b35f669db9f050e75485746d7bfeebcf317e821e5f571555e603ef9fcce2fb7d38da89981ee95ef5500210d6eeb30
@@ -26,21 +26,24 @@ module Hoodie
26
26
  # and uncountable words are kept in inflections.rb.
27
27
  #
28
28
  module Inflections
29
-
30
29
  # Convert input to UpperCamelCase. Will also convert '/' to '::' which is
31
30
  # useful for converting paths to namespaces.
32
31
  #
33
32
  # @param [String] input
33
+ #
34
34
  # @return [String]
35
+ #
35
36
  def self.camelize(input)
36
- input.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:\A|_)(.)/) { $1.upcase }
37
+ input.gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:\A|_)(.)/) {$1.upcase}
37
38
  end
38
39
 
39
40
  # Convert input to underscored, lowercase string. Changes '::' to '/' to
40
41
  # convert namespaces to paths.
41
42
  #
42
43
  # @param [String] input
44
+ #
43
45
  # @return [String]
46
+ #
44
47
  def self.underscore(input)
45
48
  word = input.gsub(/::/, '/')
46
49
  underscorize(word)
@@ -49,7 +52,9 @@ module Hoodie
49
52
  # Convert input underscores to dashes.
50
53
  #
51
54
  # @param [String] input
55
+ #
52
56
  # @return [String]
57
+ #
53
58
  def self.dasherize(input)
54
59
  input.tr('_', '-')
55
60
  end
@@ -57,7 +62,9 @@ module Hoodie
57
62
  # Return unscoped constant name.
58
63
  #
59
64
  # @param [String] input
65
+ #
60
66
  # @return [String]
67
+ #
61
68
  def self.demodulize(input)
62
69
  input.split('::').last
63
70
  end
@@ -65,7 +72,9 @@ module Hoodie
65
72
  # Creates a foreign key name
66
73
  #
67
74
  # @param [String] input
75
+ #
68
76
  # @return [String]
77
+ #
69
78
  def self.foreign_key(input)
70
79
  "#{underscorize(demodulize(input))}_id"
71
80
  end
@@ -75,7 +84,9 @@ module Hoodie
75
84
  # caller is igored.
76
85
  #
77
86
  # @param [String] input
87
+ #
78
88
  # @return [Class, Module]
89
+ #
79
90
  def self.constantize(input)
80
91
  names = input.split('::')
81
92
  names.shift if names.first.empty?
@@ -94,7 +105,9 @@ module Hoodie
94
105
  # Convert a number into an ordinal string.
95
106
  #
96
107
  # @param [Fixnum] number
108
+ #
97
109
  # @return [String]
110
+ #
98
111
  def self.ordinalize(number)
99
112
  abs_value = number.abs
100
113
 
@@ -112,7 +125,9 @@ module Hoodie
112
125
  # Convert input word string to plural
113
126
  #
114
127
  # @param [String] word
128
+ #
115
129
  # @return [String]
130
+ #
116
131
  def self.pluralize(word)
117
132
  return word if uncountable?(word)
118
133
  inflections.plurals.apply_to(word)
@@ -121,7 +136,9 @@ module Hoodie
121
136
  # Convert word to singular
122
137
  #
123
138
  # @param [String] word
139
+ #
124
140
  # @return [String]
141
+ #
125
142
  def self.singularize(word)
126
143
  return word if uncountable?(word)
127
144
  inflections.singulars.apply_to(word)
@@ -130,7 +147,9 @@ module Hoodie
130
147
  # Humanize string.
131
148
  #
132
149
  # @param [String] input
150
+ #
133
151
  # @return [String]
152
+ #
134
153
  def self.humanize(input)
135
154
  result = inflections.humans.apply_to(input)
136
155
  result.gsub!(/_id\z/, "")
@@ -142,7 +161,9 @@ module Hoodie
142
161
  # Tabelize input string.
143
162
  #
144
163
  # @param [String] input
164
+ #
145
165
  # @return [String]
166
+ #
146
167
  def self.tableize(input)
147
168
  pluralize(underscore(input).gsub('/', '_'))
148
169
  end
@@ -151,7 +172,9 @@ module Hoodie
151
172
  # names to models.
152
173
  #
153
174
  # @param [String] input
175
+ #
154
176
  # @return [String]
177
+ #
155
178
  def self.classify(table_name)
156
179
  camelize(singularize(table_name.sub(/.*\./, '')))
157
180
  end
@@ -159,9 +182,12 @@ module Hoodie
159
182
  # Create a snake case string with an optional namespace prepended.
160
183
  #
161
184
  # @param [String] input
185
+ #
162
186
  # @param [String] namespace
187
+ #
163
188
  # @return [String]
164
- def snakeify(input, namespace = nil)
189
+ #
190
+ def self.snakeify(input, namespace = nil)
165
191
  input = input.dup
166
192
  input.sub!(/^#{namespace}(\:\:)?/, '') if namespace
167
193
  input.gsub!(/[A-Z]/) {|s| "_" + s}
@@ -173,7 +199,9 @@ module Hoodie
173
199
  # Test if word is uncountable.
174
200
  #
175
201
  # @param [String] word
202
+ #
176
203
  # @return [Boolean] true, if word is uncountable
204
+ #
177
205
  def self.uncountable?(word)
178
206
  word.empty? || inflections.uncountables.include?(word.downcase)
179
207
  end
@@ -181,7 +209,9 @@ module Hoodie
181
209
  # Convert input to underscored, lowercase string
182
210
  #
183
211
  # @param [String] input
212
+ #
184
213
  # @return [String]
214
+ #
185
215
  def self.underscorize(word)
186
216
  word.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
187
217
  word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
@@ -191,9 +221,10 @@ module Hoodie
191
221
  end
192
222
  private_class_method :underscorize
193
223
 
194
- # Yields a singleton instance of Inflecto::Inflections.
224
+ # Yields a singleton instance of Garcon::Inflections.
225
+ #
226
+ # @return [Garcon::Inflections]
195
227
  #
196
- # @return [Inflections::Inflections]
197
228
  def self.inflections
198
229
  instance = Inflections.instance
199
230
  block_given? ? yield(instance) : instance
@@ -201,6 +232,6 @@ module Hoodie
201
232
  end
202
233
  end
203
234
 
204
- require 'hoodie/inflections/rules_collection'
205
- require 'hoodie/inflections/inflections'
206
- require 'hoodie/inflections/defaults'
235
+ require_relative 'inflections/rules_collection'
236
+ require_relative 'inflections/inflections'
237
+ require_relative 'inflections/defaults'
@@ -31,9 +31,10 @@ module Hoodie
31
31
 
32
32
  # Initializes a new disked backed stash hash cache store.
33
33
  #
34
- # @param path [String] location for stash store cache.
34
+ # @param [String] path
35
+ # Location for stash store cache.
35
36
  #
36
- # @return nothing.
37
+ # @return [DiskStore]
37
38
  #
38
39
  def initialize(store = file_store)
39
40
  @store = store
@@ -117,7 +118,11 @@ module Hoodie
117
118
  write_cache_file(key, Marshal.dump(value))
118
119
  end
119
120
 
120
- # returns path to cache file with 'key'
121
+ # Returns path to cache file with 'key'
122
+ #
123
+ # @return [String]
124
+ # Path to cache file.
125
+ #
121
126
  def cache_file(key)
122
127
  File.join(store, key.to_s + '.cache')
123
128
  end
@@ -48,8 +48,8 @@ module Hoodie
48
48
  module Konstruktor
49
49
  def takes(*names)
50
50
  attr_reader *names
51
- include Konstruktor::Constructor(*names)
52
- extend Konstruktor::Let
51
+ include Hoodie::Constructor(*names)
52
+ extend Hoodie::Let
53
53
  end
54
54
  end
55
55
 
@@ -29,11 +29,11 @@
29
29
  # )
30
30
  #
31
31
  # def initialize
32
- # @state_machine = StateMachine.new(STATE_TRANSITIONS, :awaiting_foo)
32
+ # @machine = Machine.new(STATE_TRANSITIONS, :awaiting_foo)
33
33
  # end
34
34
  #
35
35
  # def handle_event(event)
36
- # action = @state_machine.send_input(event)
36
+ # action = @machine.send_input(event)
37
37
  # send(action) unless action.nil?
38
38
  # end
39
39
  #
@@ -80,4 +80,3 @@ module Hoodie
80
80
  end
81
81
  end
82
82
  end
83
-
@@ -18,5 +18,5 @@
18
18
  #
19
19
 
20
20
  module Hoodie
21
- VERSION = '1.0.2'
21
+ VERSION = '1.0.3'
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hoodie
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Harding
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-04-23 00:00:00.000000000 Z
11
+ date: 2015-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake