padrino-support 0.16.0.pre4 → 0.16.0

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
  SHA256:
3
- metadata.gz: 4ba7cc454018e6e5420beac5070d92fbc74cba209fb0e275505bdacdfd481bee
4
- data.tar.gz: f6d0af71b97a90ee991d27a4597acdfabe23c17b094257724ae23e14b8fc6bf3
3
+ metadata.gz: 59a80f867b03be39e12377b2ce6d3559c20b3108b926f3dbb05592a7bffb23af
4
+ data.tar.gz: 74d3a220b6a2b402089a5207cae2e8b4c53a2f326941ba6b3845b1da20e0a25c
5
5
  SHA512:
6
- metadata.gz: ada14d2a7c15d9444f8dca867ca17e241600cf9735e67fbaf8419b7c8083715d5ee5801e97d906e877f3ef513f687ca4b78c1c4177e75a244d9c89cdd7747d7b
7
- data.tar.gz: 618f62e709476c1dcd30d76e7684255dd75b17c9bf79ff95661286ab377fdc9b2ce2f60cf65eb161e33ef4cd1cc9a1d83e3a5998c14fcc716db2b41d725dc217
6
+ metadata.gz: a2d7bfe9f8f11786e6b81c5a436c213e9b54c02be401975f284d9f900ea6d1fae753d7c50bc878fca58e929f78254191840457c7c05b4374964f55a0820ffa04
7
+ data.tar.gz: 38ce9e649ee47193caef5c697e9c187f4b1f5309c930f8cf29c093ed0282c4759d536bcba14b859267e102a6bf94f7bf53565392db53136dea0149d096297c27
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')
1
+ require_relative '../gem_rake_helper'
@@ -17,23 +17,23 @@ class String
17
17
  # Returns colors integer mapping
18
18
  def self.colors
19
19
  @_colors ||= {
20
- :default => 9,
21
- :black => 30,
22
- :red => 31,
23
- :green => 32,
24
- :yellow => 33,
25
- :blue => 34,
26
- :magenta => 35,
27
- :cyan => 36,
28
- :white => 37
20
+ default: 9,
21
+ black: 30,
22
+ red: 31,
23
+ green: 32,
24
+ yellow: 33,
25
+ blue: 34,
26
+ magenta: 35,
27
+ cyan: 36,
28
+ white: 37
29
29
  }
30
30
  end
31
31
 
32
32
  # Returns modes integer mapping
33
33
  def self.modes
34
34
  @_modes ||= {
35
- :default => 0,
36
- :bold => 1
35
+ default: 0,
36
+ bold: 1
37
37
  }
38
38
  end
39
39
 
@@ -44,7 +44,7 @@ class String
44
44
  define_method(color) do |target, mode_name = :default|
45
45
  mode = modes[mode_name] || modes[:default]
46
46
  "\e[#{mode};#{value}m" << target << "\e[0m"
47
- end
47
+ end
48
48
  end
49
49
  end
50
50
  end
@@ -1,10 +1,11 @@
1
1
  # frozen-string-literal: true
2
+
2
3
  ##
3
4
  # This module is based on Sequel 5.4.0
4
5
  # sequel-5.4.0/lib/sequel/model/default_inflections.rb
5
6
  #
6
7
  module Padrino
7
- # Proc that is instance evaled to create the default inflections for both the
8
+ # Proc that is instance executed to create the default inflections for both the
8
9
  # model inflector and the inflector extension.
9
10
  DEFAULT_INFLECTIONS_PROC = proc do
10
11
  plural(/$/, 's')
@@ -45,6 +46,6 @@ module Padrino
45
46
  irregular('quiz', 'quizzes')
46
47
  irregular('testis', 'testes')
47
48
 
48
- uncountable(%w(equipment information rice money species series fish sheep news))
49
+ uncountable(%w[equipment information rice money species series fish sheep news])
49
50
  end
50
51
  end
@@ -2,16 +2,17 @@
2
2
  # FileSet helper method for iterating and interacting with files inside a directory
3
3
  #
4
4
  module FileSet
5
- extend self
5
+ module_function
6
+
6
7
  ##
7
8
  # Iterates over every file in the glob pattern and yields to a block
8
9
  # Returns the list of files matching the glob pattern
9
10
  # FileSet.glob('padrino-core/application/*.rb', __FILE__) { |file| load file }
10
11
  #
11
- def glob(glob_pattern, file_path=nil)
12
+ def glob(glob_pattern, file_path = nil, &block)
12
13
  glob_pattern = File.join(File.dirname(file_path), glob_pattern) if file_path
13
14
  file_list = Dir.glob(glob_pattern).sort
14
- file_list.each{ |file| yield(file) }
15
+ file_list.each(&block)
15
16
  file_list
16
17
  end
17
18
 
@@ -19,7 +20,7 @@ module FileSet
19
20
  # Requires each file matched in the glob pattern into the application
20
21
  # FileSet.glob_require('padrino-core/application/*.rb', __FILE__)
21
22
  #
22
- def glob_require(glob_pattern, file_path=nil)
23
+ def glob_require(glob_pattern, file_path = nil)
23
24
  glob(glob_pattern, file_path) { |f| require f }
24
25
  end
25
26
  end
@@ -22,18 +22,18 @@ module Padrino
22
22
  # pluralization and singularization rules that is runs. This guarantees that your rules run before any of the rules that may
23
23
  # already have been loaded.
24
24
  module Inflections
25
- CAMELIZE_CONVERT_REGEXP = /(^|_)(.)/.freeze
26
- CAMELIZE_MODULE_REGEXP = /\/(.?)/.freeze
25
+ CAMELIZE_CONVERT_REGEXP = /(^|_)(.)/
26
+ CAMELIZE_MODULE_REGEXP = %r{/(.?)}
27
27
  DASH = '-'.freeze
28
- DEMODULIZE_CONVERT_REGEXP = /^.*::/.freeze
29
- EMPTY_STRING= ''.freeze
28
+ DEMODULIZE_CONVERT_REGEXP = /^.*::/
29
+ EMPTY_STRING = ''.freeze
30
30
  SLASH = '/'.freeze
31
- VALID_CONSTANT_NAME_REGEXP = /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/.freeze
31
+ VALID_CONSTANT_NAME_REGEXP = /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/
32
32
  UNDERSCORE = '_'.freeze
33
- UNDERSCORE_CONVERT_REGEXP1 = /([A-Z]+)([A-Z][a-z])/.freeze
34
- UNDERSCORE_CONVERT_REGEXP2 = /([a-z\d])([A-Z])/.freeze
33
+ UNDERSCORE_CONVERT_REGEXP1 = /([A-Z]+)([A-Z][a-z])/
34
+ UNDERSCORE_CONVERT_REGEXP2 = /([a-z\d])([A-Z])/
35
35
  UNDERSCORE_CONVERT_REPLACE = '\1_\2'.freeze
36
- UNDERSCORE_MODULE_REGEXP = /::/.freeze
36
+ UNDERSCORE_MODULE_REGEXP = /::/
37
37
 
38
38
  @plurals, @singulars, @uncountables = [], [], []
39
39
 
@@ -70,8 +70,8 @@ module Padrino
70
70
  # irregular 'octopus', 'octopi'
71
71
  # irregular 'person', 'people'
72
72
  def self.irregular(singular, plural)
73
- plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), '\1' + plural[1..-1])
74
- singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), '\1' + singular[1..-1])
73
+ plural(Regexp.new("(#{singular[0, 1]})#{singular[1..]}$", 'i'), "\\1#{plural[1..]}")
74
+ singular(Regexp.new("(#{plural[0, 1]})#{plural[1..]}$", 'i'), "\\1#{singular[1..]}")
75
75
  end
76
76
 
77
77
  # Specifies a new pluralization rule and its replacement. The rule can either be a string or a regular expression.
@@ -87,7 +87,7 @@ module Padrino
87
87
  # The replacement should always be a string that may include references to the matched data from the rule.
88
88
  #
89
89
  # Example:
90
- # singular(/([^aeiouy]|qu)ies$/i, '\1y')
90
+ # singular(/([^aeiouy]|qu)ies$/i, '\1y')
91
91
  def self.singular(rule, replacement)
92
92
  @singulars.insert(0, [rule, replacement])
93
93
  end
@@ -104,76 +104,79 @@ module Padrino
104
104
 
105
105
  instance_eval(&DEFAULT_INFLECTIONS_PROC)
106
106
 
107
- extend self
107
+ module_function
108
108
 
109
109
  # Convert the given string to CamelCase. Will also convert '/' to '::' which is useful for converting paths to namespaces.
110
- def camelize(s)
111
- s = s.to_s
112
- return s.camelize if s.respond_to?(:camelize)
113
- s = s.gsub(CAMELIZE_MODULE_REGEXP){|x| "::#{x[-1..-1].upcase unless x == SLASH}"}.gsub(CAMELIZE_CONVERT_REGEXP){|x| x[-1..-1].upcase}
114
- s
110
+ def camelize(str)
111
+ str = str.to_s
112
+ return str.camelize if str.respond_to?(:camelize)
113
+ str.gsub(CAMELIZE_MODULE_REGEXP) { |x| "::#{x[-1..].upcase unless x == SLASH}" }.gsub(CAMELIZE_CONVERT_REGEXP) { |x| x[-1..].upcase }
115
114
  end
116
115
 
117
116
  # Tries to find a declared constant with the name specified
118
117
  # in the string. It raises a NameError when the name is not in CamelCase
119
118
  # or is not initialized.
120
- def constantize(s)
121
- s = s.to_s
122
- return s.constantize if s.respond_to?(:constantize)
123
- raise(NameError, "#{s.inspect} is not a valid constant name!") unless m = VALID_CONSTANT_NAME_REGEXP.match(s)
119
+ def constantize(str)
120
+ str = str.to_s
121
+ return str.constantize if str.respond_to?(:constantize)
122
+ raise(NameError, "#{str.inspect} is not a valid constant name!") unless (m = VALID_CONSTANT_NAME_REGEXP.match(str))
124
123
  Object.module_eval("::#{m[1]}", __FILE__, __LINE__)
125
124
  end
126
125
 
127
126
  # Removes the module part from the expression in the string
128
- def demodulize(s)
129
- s = s.to_s
130
- return s.demodulize if s.respond_to?(:demodulize)
131
- s.gsub(DEMODULIZE_CONVERT_REGEXP, EMPTY_STRING)
127
+ def demodulize(str)
128
+ str = str.to_s
129
+ return str.demodulize if str.respond_to?(:demodulize)
130
+ str.gsub(DEMODULIZE_CONVERT_REGEXP, EMPTY_STRING)
132
131
  end
133
132
 
134
133
  # Returns the plural form of the word in the string.
135
- def pluralize(s)
136
- s = s.to_s
137
- return s.pluralize if s.respond_to?(:pluralize)
138
- result = s.dup
139
- Inflections.plurals.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
134
+ def pluralize(str)
135
+ str = str.to_s
136
+ return str.pluralize if str.respond_to?(:pluralize)
137
+ result = str.dup
138
+ Inflections.plurals.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } unless Inflections.uncountables.include?(str.downcase)
140
139
  result
141
140
  end
142
141
 
143
142
  # The reverse of pluralize, returns the singular form of a word in a string.
144
- def singularize(s)
145
- s = s.to_s
146
- return s.singularize if s.respond_to?(:singularize)
147
- result = s.dup
148
- Inflections.singulars.each{|(rule, replacement)| break if result.gsub!(rule, replacement)} unless Inflections.uncountables.include?(s.downcase)
143
+ def singularize(str)
144
+ str = str.to_s
145
+ return str.singularize if str.respond_to?(:singularize)
146
+ result = str.dup
147
+ Inflections.singulars.each { |(rule, replacement)| break if result.gsub!(rule, replacement) } unless Inflections.uncountables.include?(str.downcase)
149
148
  result
150
149
  end
151
150
 
152
151
  # The reverse of camelize. Makes an underscored form from the expression in the string.
153
152
  # Also changes '::' to '/' to convert namespaces to paths.
154
- def underscore(s)
155
- s = s.to_s
156
- return s.underscore if s.respond_to?(:underscore)
157
- s.gsub(UNDERSCORE_MODULE_REGEXP, SLASH).gsub(UNDERSCORE_CONVERT_REGEXP1, UNDERSCORE_CONVERT_REPLACE).
158
- gsub(UNDERSCORE_CONVERT_REGEXP2, UNDERSCORE_CONVERT_REPLACE).tr(DASH, UNDERSCORE).downcase
153
+ def underscore(str)
154
+ str = str.to_s
155
+ return str.underscore if str.respond_to?(:underscore)
156
+
157
+ str.gsub(UNDERSCORE_MODULE_REGEXP, SLASH)
158
+ .gsub(UNDERSCORE_CONVERT_REGEXP1, UNDERSCORE_CONVERT_REPLACE)
159
+ .gsub(UNDERSCORE_CONVERT_REGEXP2, UNDERSCORE_CONVERT_REPLACE)
160
+ .tr(DASH, UNDERSCORE)
161
+ .downcase
159
162
  end
160
163
 
161
164
  ##
162
165
  # Capitalizes the first word, turns underscores into spaces, and strips a trailing '_id' if present.
163
166
  #
164
- def humanize(s)
165
- s = s.to_s
166
- return s.humanize if s.respond_to?(:humanize)
167
- s.gsub(/_id$/, '').tr('_', ' ').capitalize
167
+ def humanize(str)
168
+ str = str.to_s
169
+ return str.humanize if str.respond_to?(:humanize)
170
+ str.gsub(/_id$/, '').tr('_', ' ').capitalize
168
171
  end
169
172
 
170
173
  ##
171
174
  # Create a class name from a plural table name like Rails does for table names to models.
172
175
  #
173
- def classify(s)
174
- s = s.to_s
175
- return s.classify if s.respond_to?(:classify)
176
- camelize(singularize(s.sub(/.*\./, '')))
176
+ def classify(str)
177
+ str = str.to_s
178
+ return str.classify if str.respond_to?(:classify)
179
+ camelize(singularize(str.sub(/.*\./, '')))
177
180
  end
178
181
  end
179
182
  end
@@ -2,32 +2,32 @@ require 'cgi'
2
2
 
3
3
  module Padrino
4
4
  module Utils
5
- extend self
5
+ module_function
6
6
 
7
7
  ##
8
8
  # Builds an URI query from a Hash or any Object.
9
9
  #
10
10
  # Examples (~ marks here that output is actually escaped by CGI):
11
11
  #
12
- # Utils.build_uri_query(:a => 1, :b => 2) #=> "a=1&b=2"
13
- # Utils.build_uri_query(:a => [1, 2]) #=> ~"a[]=1&a[]=2"
14
- # Utils.build_uri_query([1, 2], 'namespace') #=> ~"namespace[]=1&namespace[]=2"
15
- # Utils.build_uri_query(:a => { :d => 2 }, :b => 3) #=> ~"a[d]=2&b=3"
12
+ # Utils.build_uri_query(a: 1, b: 2) # => 'a=1&b=2'
13
+ # Utils.build_uri_query(a: [1, 2]) # => ~'a[]=1&a[]=2'
14
+ # Utils.build_uri_query([1, 2], 'namespace') # => ~'namespace[]=1&namespace[]=2'
15
+ # Utils.build_uri_query(a: { d: 2 }, b: 3) # => ~'a[d]=2&b=3'
16
16
  #
17
17
  def build_uri_query(object, namespace = nil)
18
18
  case object
19
19
  when Hash
20
20
  object.map do |key, value|
21
- next if value == {} || value == []
21
+ next if [{}, []].include?(value)
22
22
  build_uri_query(value, namespace ? "#{namespace}[#{key}]" : key)
23
23
  end.compact.join('&')
24
24
  when Array
25
- fail ArgumentError, 'namespace is missing' unless namespace
25
+ raise ArgumentError, 'namespace is missing' unless namespace
26
26
  (object.empty? ? [''] : object).map do |value|
27
27
  build_uri_query(value, "#{namespace}[]")
28
28
  end.join('&')
29
29
  else
30
- fail ArgumentError, 'namespace is missing' unless namespace
30
+ raise ArgumentError, 'namespace is missing' unless namespace
31
31
  "#{CGI.escape(namespace.to_s)}=#{CGI.escape(object.to_s)}"
32
32
  end
33
33
  end
@@ -38,7 +38,7 @@ module Padrino
38
38
  def deep_dup(object)
39
39
  case object
40
40
  when Array
41
- object.map{ |value| deep_dup(value) }
41
+ object.map { |value| deep_dup(value) }
42
42
  when Hash
43
43
  object.each_with_object(object.dup.clear) do |(key, value), new_hash|
44
44
  new_hash[deep_dup(key)] = deep_dup(value)
@@ -5,7 +5,7 @@ require 'padrino-support/core_ext/string/colorize'
5
5
  require 'padrino-support/file_set'
6
6
  require 'padrino-support/utils'
7
7
 
8
- if ENV["AS_VERSION"]
8
+ if ENV['AS_VERSION']
9
9
  # require ActiveSupport features for tests or legacy projects
10
10
  require 'active_support/core_ext/string/output_safety' # SafeBuffer and html_safe
11
11
  require 'active_support/core_ext/object/blank' # present?
@@ -27,7 +27,7 @@ end
27
27
  #
28
28
  if defined?(I18n) && !defined?(PADRINO_I18N_LOCALE)
29
29
  PADRINO_I18N_LOCALE = true
30
- I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-support/locale/*.yml"]
30
+ I18n.load_path += Dir["#{__dir__}/padrino-support/locale/*.yml"]
31
31
  end
32
32
 
33
33
  ##
@@ -35,5 +35,5 @@ end
35
35
  # In reloader for accessing class_name Foo._orig_klass_name
36
36
  #
37
37
  class Module
38
- alias :_orig_klass_name :name
38
+ alias _orig_klass_name name
39
39
  end
@@ -1,25 +1,25 @@
1
1
  #!/usr/bin/env gem build
2
2
  # encoding: utf-8
3
3
 
4
- require File.expand_path("../../padrino-core/lib/padrino-core/version.rb", __FILE__)
4
+ require File.expand_path('../padrino-core/lib/padrino-core/version.rb', __dir__)
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = "padrino-support"
8
- s.authors = ["Padrino Team", "Nathan Esquenazi", "Davide D'Agostino", "Arthur Chiu", "Igor Bochkariov"]
9
- s.email = "padrinorb@gmail.com"
10
- s.summary = "Support for padrino"
11
- s.homepage = "http://www.padrinorb.com"
12
- s.description = "A number of support methods and extensions for Padrino framework"
13
- s.required_ruby_version = ">= 2.7.8"
14
- s.required_rubygems_version = ">= 1.3.6"
7
+ s.name = 'padrino-support'
8
+ s.authors = ['Padrino Team', 'Nathan Esquenazi', "Davide D'Agostino", 'Arthur Chiu', 'Igor Bochkariov']
9
+ s.email = 'padrinorb@gmail.com'
10
+ s.summary = 'Support for padrino'
11
+ s.homepage = 'http://www.padrinorb.com'
12
+ s.description = 'A number of support methods and extensions for Padrino framework'
13
+ s.required_ruby_version = '>= 2.7.8'
14
+ s.required_rubygems_version = '>= 1.3.6'
15
15
  s.version = Padrino.version
16
- s.date = Time.now.strftime("%Y-%m-%d")
17
- s.license = "MIT"
16
+ s.date = Time.now.strftime('%Y-%m-%d')
17
+ s.license = 'MIT'
18
18
 
19
- s.extra_rdoc_files = Dir["*.rdoc"]
19
+ s.extra_rdoc_files = Dir['*.rdoc']
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
- s.require_paths = ["lib"]
24
- s.rdoc_options = ["--charset=UTF-8"]
22
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
23
+ s.require_paths = ['lib']
24
+ s.rdoc_options = ['--charset=UTF-8']
25
25
  end
data/test/helper.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  ENV['RACK_ENV'] = 'test'
2
- PADRINO_ROOT = File.dirname(__FILE__) unless defined?(PADRINO_ROOT)
2
+ PADRINO_ROOT = __dir__ unless defined?(PADRINO_ROOT)
3
3
 
4
4
  require 'minitest/autorun'
5
5
  require 'minitest/pride'
@@ -1,31 +1,31 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
1
+ require_relative 'helper'
2
2
 
3
- describe "String#colorize" do
4
- it "should colorize text correctly" do
5
- assert_equal "\e[0;34mHello world\e[0m", "Hello world".colorize(:blue)
6
- assert_equal "\e[0;30mHello world\e[0m", "Hello world".colorize(:black)
7
- assert_equal "\e[0;31mHello world\e[0m", "Hello world".colorize(:red)
8
- assert_equal "\e[0;32mHello world\e[0m", "Hello world".colorize(:green)
9
- assert_equal "\e[0;33mHello world\e[0m", "Hello world".colorize(:yellow)
10
- assert_equal "\e[0;34mHello world\e[0m", "Hello world".colorize(:blue)
11
- assert_equal "\e[0;35mHello world\e[0m", "Hello world".colorize(:magenta)
12
- assert_equal "\e[0;36mHello world\e[0m", "Hello world".colorize(:cyan)
13
- assert_equal "\e[0;37mHello world\e[0m", "Hello world".colorize(:white)
3
+ describe 'String#colorize' do
4
+ it 'should colorize text correctly' do
5
+ assert_equal "\e[0;34mHello world\e[0m", 'Hello world'.colorize(:blue)
6
+ assert_equal "\e[0;30mHello world\e[0m", 'Hello world'.colorize(:black)
7
+ assert_equal "\e[0;31mHello world\e[0m", 'Hello world'.colorize(:red)
8
+ assert_equal "\e[0;32mHello world\e[0m", 'Hello world'.colorize(:green)
9
+ assert_equal "\e[0;33mHello world\e[0m", 'Hello world'.colorize(:yellow)
10
+ assert_equal "\e[0;34mHello world\e[0m", 'Hello world'.colorize(:blue)
11
+ assert_equal "\e[0;35mHello world\e[0m", 'Hello world'.colorize(:magenta)
12
+ assert_equal "\e[0;36mHello world\e[0m", 'Hello world'.colorize(:cyan)
13
+ assert_equal "\e[0;37mHello world\e[0m", 'Hello world'.colorize(:white)
14
14
  end
15
15
 
16
- it "should colorize text when using color name method" do
17
- assert_equal "\e[0;30mHello world\e[0m", String::Colorizer.black("Hello world")
18
- assert_equal "\e[0;31mHello world\e[0m", String::Colorizer.red("Hello world")
19
- assert_equal "\e[0;32mHello world\e[0m", String::Colorizer.green("Hello world")
20
- assert_equal "\e[0;33mHello world\e[0m", String::Colorizer.yellow("Hello world")
21
- assert_equal "\e[0;34mHello world\e[0m", String::Colorizer.blue("Hello world")
22
- assert_equal "\e[0;35mHello world\e[0m", String::Colorizer.magenta("Hello world")
23
- assert_equal "\e[0;36mHello world\e[0m", String::Colorizer.cyan("Hello world")
24
- assert_equal "\e[0;37mHello world\e[0m", String::Colorizer.white("Hello world")
16
+ it 'should colorize text when using color name method' do
17
+ assert_equal "\e[0;30mHello world\e[0m", String::Colorizer.black('Hello world')
18
+ assert_equal "\e[0;31mHello world\e[0m", String::Colorizer.red('Hello world')
19
+ assert_equal "\e[0;32mHello world\e[0m", String::Colorizer.green('Hello world')
20
+ assert_equal "\e[0;33mHello world\e[0m", String::Colorizer.yellow('Hello world')
21
+ assert_equal "\e[0;34mHello world\e[0m", String::Colorizer.blue('Hello world')
22
+ assert_equal "\e[0;35mHello world\e[0m", String::Colorizer.magenta('Hello world')
23
+ assert_equal "\e[0;36mHello world\e[0m", String::Colorizer.cyan('Hello world')
24
+ assert_equal "\e[0;37mHello world\e[0m", String::Colorizer.white('Hello world')
25
25
  end
26
26
 
27
- it "should be possible to set the mode" do
28
- assert_equal "\e[1;34mHello world\e[0m", "Hello world".colorize(:color => :blue, :mode => :bold)
29
- assert_equal "\e[1;34mHello world\e[0m", String::Colorizer.blue("Hello world", :bold)
27
+ it 'should be possible to set the mode' do
28
+ assert_equal "\e[1;34mHello world\e[0m", 'Hello world'.colorize(color: :blue, mode: :bold)
29
+ assert_equal "\e[1;34mHello world\e[0m", String::Colorizer.blue('Hello world', :bold)
30
30
  end
31
31
  end
data/test/test_utils.rb CHANGED
@@ -1,14 +1,14 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/helper')
1
+ require_relative 'helper'
2
2
 
3
3
  class Minitest::Spec
4
- def assert_query_equal(expected, actual, namespace=nil)
4
+ def assert_query_equal(expected, actual, namespace = nil)
5
5
  assert_equal expected.split('&').sort, Padrino::Utils.build_uri_query(actual, namespace).split('&').sort
6
6
  end
7
7
  end
8
8
 
9
9
  describe 'Padrino::Utils.build_uri_query' do
10
10
  it 'should do simple conversion' do
11
- assert_query_equal 'a=10', :a => 10
11
+ assert_query_equal 'a=10', a: 10
12
12
  end
13
13
 
14
14
  it 'should do cgi escaping' do
@@ -16,45 +16,39 @@ describe 'Padrino::Utils.build_uri_query' do
16
16
  end
17
17
 
18
18
  it 'should expand nested hashes' do
19
- assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas',
20
- :person => { :login => 'seckar', :name => 'Nicholas' }
19
+ assert_query_equal 'person%5Blogin%5D=seckar&person%5Bname%5D=Nicholas', person: {
20
+ login: 'seckar', name: 'Nicholas'
21
+ }
21
22
  end
22
23
 
23
24
  it 'should expand deeply nested hashes' do
24
- assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10',
25
- { :account => { :person => { :id => 20 } }, :person => {:id => 10} }
25
+ assert_query_equal 'account%5Bperson%5D%5Bid%5D=20&person%5Bid%5D=10', {
26
+ account: { person: { id: 20 } },
27
+ person: { id: 10 }
28
+ }
26
29
  end
27
30
 
28
31
  it 'should accept arrays' do
29
- assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20',
30
- :person => {:id => [10, 20]}
32
+ assert_query_equal 'person%5Bid%5D%5B%5D=10&person%5Bid%5D%5B%5D=20', person: { id: [10, 20] }
31
33
  end
32
34
 
33
35
  it 'should accept empty arrays' do
34
- assert_query_equal "person%5B%5D=",
35
- [],
36
- 'person'
36
+ assert_query_equal 'person%5B%5D=', [], 'person'
37
37
  end
38
38
 
39
39
  it 'should expand nested hashes' do
40
- assert_query_equal '',
41
- {}
42
- assert_query_equal 'a=1&b%5Bc%5D=3',
43
- { a: 1, b: { c: 3, d: {} } }
44
- assert_query_equal '',
45
- { a: {b: {c: {}}} }
46
- assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12',
47
- { p: 12, b: { c: false, e: nil, f: '' } }
48
- assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=',
49
- { b: { c: 3, k: {}, f: '' } }
50
- assert_query_equal 'b=3',
51
- {a: [], b: 3}
40
+ assert_query_equal '', {}
41
+ assert_query_equal 'a=1&b%5Bc%5D=3', { a: 1, b: { c: 3, d: {} } }
42
+ assert_query_equal '', { a: { b: { c: {} } } }
43
+ assert_query_equal 'b%5Bc%5D=false&b%5Be%5D=&b%5Bf%5D=&p=12', { p: 12, b: { c: false, e: nil, f: '' } }
44
+ assert_query_equal 'b%5Bc%5D=3&b%5Bf%5D=', { b: { c: 3, k: {}, f: '' } }
45
+ assert_query_equal 'b=3', { a: [], b: 3 }
52
46
  end
53
47
 
54
48
  it 'should accept namespace for hashes' do
55
- assert_query_equal "user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian",
56
- { name: 'Nakshay', nationality: 'Indian' },
57
- 'user'
49
+ assert_query_equal 'user%5Bname%5D=Nakshay&user%5Bnationality%5D=Indian', {
50
+ name: 'Nakshay', nationality: 'Indian'
51
+ }, 'user'
58
52
  end
59
53
  end
60
54
 
@@ -68,7 +62,7 @@ describe 'Padrino::Utils.deep_dup' do
68
62
  end
69
63
 
70
64
  it 'should recursively dup hash' do
71
- hash = { :a => { :b => 'b' } }
65
+ hash = { a: { b: 'b' } }
72
66
  dup = Padrino::Utils.deep_dup(hash)
73
67
  dup[:a][:c] = 'c'
74
68
  refute_includes hash[:a], :c
@@ -76,7 +70,7 @@ describe 'Padrino::Utils.deep_dup' do
76
70
  end
77
71
 
78
72
  it 'should recursively dup array with hash' do
79
- array = [1, { :a => 2, :b => 3 } ]
73
+ array = [1, { a: 2, b: 3 }]
80
74
  dup = Padrino::Utils.deep_dup(array)
81
75
  dup[1][:c] = 4
82
76
  refute_includes array[1], :c
@@ -84,7 +78,7 @@ describe 'Padrino::Utils.deep_dup' do
84
78
  end
85
79
 
86
80
  it 'should recursively dup hash with array' do
87
- hash = { :a => [1, 2] }
81
+ hash = { a: [1, 2] }
88
82
  dup = Padrino::Utils.deep_dup(hash)
89
83
  dup[:a][2] = 'c'
90
84
  assert_equal 2, hash[:a].size
@@ -93,7 +87,7 @@ describe 'Padrino::Utils.deep_dup' do
93
87
 
94
88
  it 'should dup initial hash values' do
95
89
  zero_hash = Hash.new 0
96
- hash = { :a => zero_hash }
90
+ hash = { a: zero_hash }
97
91
  dup = Padrino::Utils.deep_dup(hash)
98
92
  assert_equal 0, dup[:a][44]
99
93
  end
@@ -102,7 +96,7 @@ describe 'Padrino::Utils.deep_dup' do
102
96
  object = Object.new
103
97
  dup = Padrino::Utils.deep_dup(object)
104
98
  dup.instance_variable_set(:@a, 1)
105
- assert !object.instance_variable_defined?(:@a)
99
+ refute object.instance_variable_defined?(:@a)
106
100
  assert dup.instance_variable_defined?(:@a)
107
101
  end
108
102
 
@@ -115,7 +109,7 @@ end
115
109
 
116
110
  describe 'Padrino::Utils.symbolize_keys' do
117
111
  it 'should symbolize string keys' do
118
- assert_equal({ :a => 1, :b => 2 }, Padrino::Utils.symbolize_keys('a' => 1, 'b' => 2))
112
+ assert_equal({ a: 1, b: 2 }, Padrino::Utils.symbolize_keys('a' => 1, 'b' => 2))
119
113
  end
120
114
 
121
115
  it 'should not fail on non-symbolizable keys' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: padrino-support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0.pre4
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Padrino Team
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2025-11-19 00:00:00.000000000 Z
15
+ date: 2025-12-02 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: A number of support methods and extensions for Padrino framework
18
18
  email: padrinorb@gmail.com
@@ -72,9 +72,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
72
72
  version: 2.7.8
73
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">"
75
+ - - ">="
76
76
  - !ruby/object:Gem::Version
77
- version: 1.3.1
77
+ version: 1.3.6
78
78
  requirements: []
79
79
  rubygems_version: 3.4.19
80
80
  signing_key: