fast_underscore 0.3.1 → 0.3.2

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: f7979abf665d0f01098c8ceb7f8a38d35ec293facc7359c2f46e1097acf27972
4
- data.tar.gz: 6611a83e71d5dc12ca49d0cd59796f1c2ddfe5bf0a16f2b0a13f183899bbceb4
3
+ metadata.gz: c2583b85fa16dc97528fa3ec41034227888c101b1a27cd337bc22d6200f99699
4
+ data.tar.gz: 30b8d7d02c635a29956e3500a731669d3d6e5db1d51b48cbedd36c9edd0aeebc
5
5
  SHA512:
6
- metadata.gz: ecb7db9b18d84db45026439535c6e4f1fbb653b41b046aef7c1dfc0a1a3ceb3435c2e8ffa8ca1dbb9626b825a4eb427a1e5b028dfa764271628880bd24c97511
7
- data.tar.gz: 24e60ffe74f04f08fdde2234727842d4583c36d06b146a3f234216e478abf1b9d57c300e539148f6e5cd97409f59f3cff0058ce51e5a8f8d3ae2e2a4e0ce5582
6
+ metadata.gz: 85f2af29ca6c2635001bf3524fe25e1d6d5fffb2029b17a7422102a955a6d9ce178b9b07811f3d8c3971825fd1e0b2a7caebe46ce209d7890c0ae9d41fd18e27
7
+ data.tar.gz: 870ece51ee05cf83a643469b7b1f885086301053fd45ab78ebeedcd107118a98fe2a4c3f3157d8dd3600db600c2d35e04557671555963bc9bcefdc729c138caa
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: "bundler"
4
+ directory: "/"
5
+ schedule:
6
+ interval: "daily"
@@ -0,0 +1,44 @@
1
+ name: Main
2
+ on:
3
+ - push
4
+ - pull_request_target
5
+ jobs:
6
+ ci:
7
+ name: CI
8
+ runs-on: ubuntu-latest
9
+ strategy:
10
+ fail-fast: false
11
+ matrix:
12
+ gemfile:
13
+ - "5.1"
14
+ - "5.2"
15
+ - "6.0"
16
+ - "6.1"
17
+ env:
18
+ CI: true
19
+ BUNDLE_GEMFILE: gemfiles/${{ matrix.gemfile }}.gemfile
20
+ steps:
21
+ - uses: actions/checkout@master
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: 3.0
25
+ bundler-cache: true
26
+ - name: Lint and test
27
+ run: |
28
+ bundle exec rubocop --parallel
29
+ bundle exec rake test
30
+ bundle exec steep check
31
+ automerge:
32
+ name: AutoMerge
33
+ needs: ci
34
+ runs-on: ubuntu-latest
35
+ if: github.event_name == 'pull_request_target' && (github.actor == github.repository_owner || github.actor == 'dependabot[bot]')
36
+ steps:
37
+ - uses: actions/github-script@v3
38
+ with:
39
+ script: |
40
+ github.pulls.merge({
41
+ owner: context.payload.repository.owner.login,
42
+ repo: context.payload.repository.name,
43
+ pull_number: context.payload.pull_request.number
44
+ })
data/.rubocop.yml CHANGED
@@ -1,14 +1,30 @@
1
1
  AllCops:
2
2
  DisplayCopNames: true
3
3
  DisplayStyleGuide: true
4
- TargetRubyVersion: 2.5
4
+ TargetRubyVersion: 2.7
5
5
  Exclude:
6
- - 'bin/**/*'
7
- - 'gemfiles/**/*'
8
- - 'tmp/**/*'
6
+ - '{tmp,vendor,yard}/**/*'
7
+
8
+ Gemspec/RequiredRubyVersion:
9
+ Enabled: false
10
+
11
+ Layout/LineLength:
12
+ Max: 80
13
+
14
+ Lint/AmbiguousBlockAssociation:
15
+ Enabled: false
16
+
17
+ Naming/RescuedExceptionsVariableName:
18
+ Enabled: false
9
19
 
10
20
  Style/Documentation:
11
21
  Enabled: false
12
22
 
13
- Style/PerlBackrefs:
23
+ Style/FormatString:
24
+ EnforcedStyle: percent
25
+
26
+ Style/FormatStringToken:
14
27
  Enabled: false
28
+
29
+ Style/PerlBackrefs:
30
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,44 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.3.2] - 2021-04-16
10
+
11
+ ### Changed
12
+
13
+ - Ensure that `String#underscore` still uses acronyms when `ActiveSupport` is being loaded.
14
+
15
+ ## [0.3.1] - 2018-08-18
16
+
17
+ ### Changed
18
+
19
+ - Don't require `'active_support'`, just allow the user to side-load it.
20
+
21
+ ## [0.3.0] - 2018-01-03
22
+
23
+ ### Changed
24
+
25
+ - Use `include` instead of `prepend` for extending the inflector.
26
+
27
+ ## [0.2.0] - 2018-01-02
28
+
29
+ ### Changed
30
+
31
+ - Instead of needing `ActiveSupport` to be loaded before requiring `fast_underscore`, `fast_underscore` can now detect when `ActiveSupport` redefines the `underscore` method and automatically redefine at that point. Note that this basically flips the requirement such that `fast_underscore` needs to be loaded first (which is actually much faster).
32
+
33
+ ## [0.1.0] - 2017-12-17
34
+
35
+ ### Added
36
+
37
+ - Support for the Rails 5.2 beta.
38
+
39
+ [unreleased]: https://github.com/kddeisz/fast_underscore/compare/v0.3.2...HEAD
40
+ [0.3.2]: https://github.com/kddeisz/fast_underscore/compare/v0.3.1...v0.3.2
41
+ [0.3.1]: https://github.com/kddeisz/fast_underscore/compare/v0.3.0...v0.3.1
42
+ [0.3.0]: https://github.com/kddeisz/fast_underscore/compare/v0.2.0...v0.3.0
43
+ [0.2.0]: https://github.com/kddeisz/fast_underscore/compare/v0.1.0...v0.2.0
44
+ [0.1.0]: https://github.com/kddeisz/fast_underscore/compare/6981d0...v0.1.0
@@ -0,0 +1,76 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kevin.deisz@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72
+
73
+ [homepage]: https://www.contributor-covenant.org
74
+
75
+ For answers to common questions about this code of conduct, see
76
+ https://www.contributor-covenant.org/faq
data/Gemfile CHANGED
@@ -4,4 +4,4 @@ source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
6
 
7
- gem 'activesupport', github: 'rails/rails'
7
+ gem 'activesupport', '~> 6.1'
data/Gemfile.lock CHANGED
@@ -1,60 +1,82 @@
1
- GIT
2
- remote: git://github.com/rails/rails.git
3
- revision: 185fce159721b331cc9a0ae17b662373ee0fc95f
4
- specs:
5
- activesupport (6.0.0.alpha)
6
- concurrent-ruby (~> 1.0, >= 1.0.2)
7
- i18n (>= 0.7, < 2)
8
- minitest (~> 5.1)
9
- tzinfo (~> 1.1)
10
-
11
1
  PATH
12
2
  remote: .
13
3
  specs:
14
- fast_underscore (0.3.1)
4
+ fast_underscore (0.3.2)
15
5
 
16
6
  GEM
17
7
  remote: https://rubygems.org/
18
8
  specs:
19
- ast (2.4.0)
20
- benchmark-ips (2.7.2)
21
- concurrent-ruby (1.0.5)
22
- i18n (1.0.1)
9
+ activesupport (6.1.3.1)
10
+ concurrent-ruby (~> 1.0, >= 1.0.2)
11
+ i18n (>= 1.6, < 2)
12
+ minitest (>= 5.1)
13
+ tzinfo (~> 2.0)
14
+ zeitwerk (~> 2.3)
15
+ ast (2.4.2)
16
+ benchmark-ips (2.8.4)
17
+ concurrent-ruby (1.1.8)
18
+ ffi (1.15.0)
19
+ i18n (1.8.10)
23
20
  concurrent-ruby (~> 1.0)
24
- minitest (5.11.3)
25
- parallel (1.12.1)
26
- parser (2.4.0.2)
27
- ast (~> 2.3)
28
- powerpack (0.1.1)
21
+ language_server-protocol (3.16.0.0)
22
+ listen (3.5.1)
23
+ rb-fsevent (~> 0.10, >= 0.10.3)
24
+ rb-inotify (~> 0.9, >= 0.9.10)
25
+ minitest (5.14.4)
26
+ parallel (1.20.1)
27
+ parser (3.0.1.0)
28
+ ast (~> 2.4.1)
29
29
  rainbow (3.0.0)
30
- rake (12.3.0)
31
- rake-compiler (1.0.4)
30
+ rake (13.0.3)
31
+ rake-compiler (1.1.1)
32
32
  rake
33
- rubocop (0.52.1)
33
+ rb-fsevent (0.10.4)
34
+ rb-inotify (0.10.1)
35
+ ffi (~> 1.0)
36
+ rbs (1.1.1)
37
+ regexp_parser (2.1.1)
38
+ rexml (3.2.5)
39
+ rubocop (1.12.1)
34
40
  parallel (~> 1.10)
35
- parser (>= 2.4.0.2, < 3.0)
36
- powerpack (~> 0.1)
41
+ parser (>= 3.0.0.0)
37
42
  rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.8, < 3.0)
44
+ rexml
45
+ rubocop-ast (>= 1.2.0, < 2.0)
38
46
  ruby-progressbar (~> 1.7)
39
- unicode-display_width (~> 1.0, >= 1.0.1)
40
- ruby-progressbar (1.9.0)
41
- thread_safe (0.3.6)
42
- tzinfo (1.2.5)
43
- thread_safe (~> 0.1)
44
- unicode-display_width (1.3.0)
47
+ unicode-display_width (>= 1.4.0, < 3.0)
48
+ rubocop-ast (1.4.1)
49
+ parser (>= 2.7.1.5)
50
+ ruby-progressbar (1.11.0)
51
+ steep (0.43.1)
52
+ activesupport (>= 5.1)
53
+ language_server-protocol (>= 3.15, < 4.0)
54
+ listen (~> 3.0)
55
+ parallel (>= 1.0.0)
56
+ parser (>= 2.7)
57
+ rainbow (>= 2.2.2, < 4.0)
58
+ rbs (~> 1.1.0)
59
+ terminal-table (>= 2, < 4)
60
+ terminal-table (3.0.0)
61
+ unicode-display_width (~> 1.1, >= 1.1.1)
62
+ tzinfo (2.0.4)
63
+ concurrent-ruby (~> 1.0)
64
+ unicode-display_width (1.7.0)
65
+ zeitwerk (2.4.2)
45
66
 
46
67
  PLATFORMS
47
68
  ruby
48
69
 
49
70
  DEPENDENCIES
50
- activesupport!
71
+ activesupport (~> 6.1)
51
72
  benchmark-ips (~> 2)
52
- bundler (~> 1)
73
+ bundler (~> 2)
53
74
  fast_underscore!
54
75
  minitest (~> 5)
55
- rake (~> 12)
76
+ rake (~> 13)
56
77
  rake-compiler (~> 1)
57
- rubocop (~> 0.52)
78
+ rubocop (~> 1.12)
79
+ steep
58
80
 
59
81
  BUNDLED WITH
60
- 1.16.1
82
+ 2.2.3
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2017 Kevin Deisz
3
+ Copyright (c) 2017-present Kevin Deisz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,52 +1,25 @@
1
1
  # `String#underscore` Ruby Extension
2
2
 
3
- [![Build Status](https://travis-ci.org/kddeisz/fast_underscore.svg?branch=master)](https://travis-ci.org/kddeisz/fast_underscore)
4
- [![Gem Version](https://img.shields.io/gem/v/fast_underscore.svg)](fast_underscore)
3
+ [![Build Status](https://github.com/kddeisz/fast_underscore/workflows/Main/badge.svg)](https://github.com/kddeisz/fast_underscore/actions)
4
+ [![Gem Version](https://img.shields.io/gem/v/fast_underscore.svg)](https://rubygems.org/gems/fast_underscore)
5
5
 
6
- `fast_underscore` is a simple C extension which provides a fast implementation of [Active Support's `String#underscore` method](http://api.rubyonrails.org/classes/String.html#method-i-underscore).
7
-
8
- ## Do I need this?
9
-
10
- Maybe! Run a stack profiler like [`ruby-prof`](https://github.com/ruby-prof/ruby-prof). If `String#underscore` or `ActiveSupport::Inflector#underscore` is coming up near the top of the list, this gem might be for you! If not, you probably don't need it. Either way, your milage may vary depending on the type of strings on which you're calling `underscore`.
11
-
12
- ## Usage with Rails
13
-
14
- `ActiveSupport::Inflector#underscore`, in addition to underscoring the input will additionally take into account known acronyms. Since this can't be done at compile time, `FastUnderscore` will detect when `ActiveSupport` is loaded and take advantage of its knowledge of acronyms while still using the native extension.
15
-
16
- Since the `#underscore` method is used so much throughout the Rails boot process (for autoloading dependencies, determining table names, determining inverse associations, etc.), it's best to hook into Rails as early as possible. As such, for the best results in your `Gemfile` add `require: false` to the `gem 'fast_underscore'` declaration and add `require 'fast_underscore'` to the bottom of `config/boot.rb`.
6
+ `fast_underscore` is a C extension that provides a fast implementation of [ActiveSupport's `String#underscore` method](http://api.rubyonrails.org/classes/String.html#method-i-underscore).
17
7
 
18
8
  ## Is it fast?
19
9
 
20
- At last check, these were the benchmarks (obtained by running `bin/benchmark`):
21
-
22
- ### Rails 5.1.4
23
-
24
- ```
25
- Warming up --------------------------------------
26
- ActiveSupport 2.000 i/100ms
27
- FastUnderscore 64.000 i/100ms
28
- Calculating -------------------------------------
29
- ActiveSupport 28.839 (± 6.9%) i/s - 144.000 in 5.019140s
30
- FastUnderscore 650.151 (± 7.7%) i/s - 3.264k in 5.056094s
31
-
32
- Comparison:
33
- FastUnderscore: 650.2 i/s
34
- ActiveSupport: 28.8 i/s - 22.54x slower
35
- ```
36
-
37
- ### Rails 5.2.0
10
+ At last check, these were the benchmarks (obtained by running `bin/bench` with Rails 6.0.2):
38
11
 
39
12
  ```
40
13
  Warming up --------------------------------------
41
14
  ActiveSupport 5.000 i/100ms
42
- FastUnderscore 66.000 i/100ms
15
+ FastUnderscore 70.000 i/100ms
43
16
  Calculating -------------------------------------
44
- ActiveSupport 50.0556.0%) i/s - 250.000 in 5.016223s
45
- FastUnderscore 655.1812.1%) i/s - 3.300k in 5.038968s
17
+ ActiveSupport 50.5649.9%) i/s - 250.000 in 5.012563s
18
+ FastUnderscore 707.6911.3%) i/s - 3.570k in 5.045375s
46
19
 
47
20
  Comparison:
48
- FastUnderscore: 655.2 i/s
49
- ActiveSupport: 50.1 i/s - 13.09x slower
21
+ FastUnderscore: 707.7 i/s
22
+ ActiveSupport: 50.6 i/s - 14.00x slower
50
23
  ```
51
24
 
52
25
  ## Installation
@@ -65,6 +38,12 @@ Or install it yourself as:
65
38
 
66
39
  $ gem install fast_underscore
67
40
 
41
+ ### Usage with Rails
42
+
43
+ `ActiveSupport::Inflector#underscore`, in addition to underscoring the input will additionally take into account known acronyms. Since this can't be done at compile time, `FastUnderscore` will detect when `ActiveSupport` is loaded and take advantage of its knowledge of acronyms while still using the native extension.
44
+
45
+ Since the `#underscore` method is used so much throughout the Rails boot process (for autoloading dependencies, determining table names, determining inverse associations, etc.), it's best to hook into Rails as early as possible. As such, for the best results in your `Gemfile` add `require: false` to the `gem 'fast_underscore'` declaration and add `require 'fast_underscore'` to the bottom of `config/boot.rb`.
46
+
68
47
  ## Development
69
48
 
70
49
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/Steepfile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ target :lib do
4
+ signature 'sig'
5
+ check 'lib'
6
+ end
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  require 'bundler/setup'
4
5
  require 'benchmark/ips'