inflect 0.3.0 → 0.3.1

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: fc4e321d2369326f998bf8b688106b8e559a4dde
4
- data.tar.gz: 64906cd1b3ec23e8b30557813ed61b57ea7cfcbc
3
+ metadata.gz: a73b18d5f60f6b926520a1a75de38f31839f0c8f
4
+ data.tar.gz: 3852033aa6ac1ae9f0da1fda3beb121ce4aa32a2
5
5
  SHA512:
6
- metadata.gz: 5ede50fc483b8cafea83a2ed1220deabc2f7235af2a81c862334212cd8183978e2f7e0af380b5efa8b1ba971aca5602474687a7f4bdabcf143ae20905b4fdaf1
7
- data.tar.gz: ffb68bcf35ace2b363c46e0ca6befe380fa739c9b74e6c5d2db5389e41b0a9c6fd5362cd78297314b3e6741fa7502a34c9d5c8b7fec0e3b06076805bd0b20407
6
+ metadata.gz: 7b8a497ca9bbd6a8662e844141c608e520ba593e2ce3d3fb9547fd1756a813f857241f9252ce0848ab009f75c568f332c939b4d1fbb01b3eda38a57e71d79642
7
+ data.tar.gz: dd51e8ee21e0996b5cb65c0e96f4b6c90ddfb55c39f50c4c6b2bfc32f4154af58073bedf8d0b1ffd9cc4ba83f5e89cdd33c846517c404cae0c2c6ee14126998d
data/README.md CHANGED
@@ -28,7 +28,11 @@ Or install it yourself as:
28
28
 
29
29
  Generate your Service:
30
30
 
31
- $ inflect generate:service weather
31
+ $ inflect generate:service Weather
32
+
33
+ IMPORTANT: service name must be in CamelCase, example:
34
+
35
+ $ inflect generate:service MyWeatherService
32
36
 
33
37
  Implement at least the WeatherService#handle method:
34
38
 
@@ -1,19 +1,28 @@
1
- require "thor"
1
+ require 'thor'
2
+ require 'pry'
3
+
4
+ require 'inflect/inflector'
2
5
 
3
6
  # Service Generator Class.
4
7
  class ServiceGenerator < Thor::Group
5
8
  include Thor::Actions
6
9
 
10
+ # Include Inflector for string management utils such
11
+ # as camelize.
12
+ using Inflect::Inflector
13
+
7
14
  # Defines the templates path.
8
15
  def self.source_root
9
16
  File.join(File.dirname(__FILE__), 'templates')
10
17
  end
11
18
 
19
+ # The parameter name in CamelCase.
12
20
  argument :name
21
+
13
22
  # Responsible to generate the named service inside lib/services path
14
23
  # of working directory.
15
24
  def generate
16
- template('service.tt', "lib/services/#{name}_service.rb")
25
+ template('service.tt', "lib/services/#{name.underscore}_service.rb")
17
26
  end
18
27
  end
19
28
 
@@ -1,4 +1,4 @@
1
- class <%=name.capitalize%>Service < Inflect::AbstractService
1
+ class <%= name %>Service < Inflect::AbstractService
2
2
  # A WORDS Array constant with the key words of the Service.
3
3
  # @example Array for New York Times service
4
4
  # words = %W[ NEWS TODAY NEW\ YORK\ TIMES]
@@ -5,9 +5,26 @@ module Inflect
5
5
  refine String do
6
6
  SNAKE_SEPARATOR = '_'
7
7
 
8
- def camelize
8
+ def camelize!
9
9
  self.split(SNAKE_SEPARATOR).map(&:capitalize!).join
10
10
  end
11
+
12
+ def camelize
13
+ word = self.dup
14
+ word.camelize!
15
+ end
16
+
17
+ def underscore!
18
+ self.gsub!(/(?<=[a-z])[A-Z]/) do |char|
19
+ char = SNAKE_SEPARATOR + char
20
+ end
21
+ self.downcase!
22
+ end
23
+
24
+ def underscore
25
+ word = self.dup
26
+ word.underscore!
27
+ end
11
28
  end
12
29
  end
13
30
  end
@@ -1,3 +1,3 @@
1
1
  module Inflect
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inflect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Santiago Figueiras
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-19 00:00:00.000000000 Z
12
+ date: 2016-03-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler