Skip to content

Commit

Permalink
Merge pull request #262 from North-Two-Five/ruby3.2-New
Browse files Browse the repository at this point in the history
Ruby3.2 new
  • Loading branch information
MichaelGHSeg authored Mar 14, 2023
2 parents 7fac392 + 13a0ddc commit 46cec0c
Show file tree
Hide file tree
Showing 7 changed files with 208 additions and 79 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ jobs:
packages: write

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: actions/setup-ruby@v1
- uses: actions/checkout@v3
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7.x
ruby-version: 2.7.7

- name: Publish to GPR
run: |
Expand Down
9 changes: 3 additions & 6 deletions .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,12 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.4.3', '2.5', '2.6', '2.7.2']
ruby-version: ['2.4', '2.5', '2.6', '2.7', '3.0', '3.1', '3.2']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
Expand Down
14 changes: 6 additions & 8 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
inherit_from: .rubocop_todo.yml

AllCops:
# Rubocop doesn't support 2.0, so we'll use the minimum available
TargetRubyVersion: 2.1
TargetRubyVersion: '2.0'
SuggestExtensions: false
NewCops: disable

Layout/IndentHash:
Layout/FirstHashElementIndentation:
EnforcedStyle: consistent

Metrics/AbcSize:
Expand All @@ -23,7 +24,7 @@ Metrics/CyclomaticComplexity:
Exclude:
- "spec/**/*.rb"

Metrics/LineLength:
Layout/LineLength:
Exclude:
- "spec/**/*.rb"

Expand All @@ -40,16 +41,13 @@ Naming/FileName:
- lib/analytics-ruby.rb # Gem name, added for easier Gemfile usage

Naming/PredicateName:
NameWhitelist:
AllowedMethods:
- is_requesting? # Can't be renamed, backwards compatibility

Style/BlockDelimiters:
Exclude:
- 'spec/**/*'

Style/BracesAroundHashParameters:
Enabled: false

Style/DateTime:
Exclude:
- 'spec/**/*.rb'
Expand Down
165 changes: 150 additions & 15 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,170 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2019-10-06 02:55:44 +0530 using RuboCop version 0.51.0.
# on 2023-01-24 09:12:04 UTC using RuboCop version 1.44.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'analytics-ruby.gemspec'

# Offense count: 1
# Configuration parameters: Severity, Include.
# Include: **/*.gemspec
Gemspec/RubyVersionGlobalsUsage:
Exclude:
- 'analytics-ruby.gemspec'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Layout/EmptyLineAfterGuardClause:
Exclude:
- 'lib/segment/analytics/client.rb'
- 'spec/spec_helper.rb'

# Offense count: 3
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
# SupportedHashRocketStyles: key, separator, table
# SupportedColonStyles: key, separator, table
# SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
Layout/HashAlignment:
Exclude:
- 'spec/segment/analytics/client_spec.rb'
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Layout/SpaceAfterComma:
Exclude:
- 'Rakefile'

# Offense count: 1
# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'bin/analytics'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: IgnoreEmptyBlocks, AllowUnusedKeywordArguments.
Lint/UnusedBlockArgument:
Exclude:
- 'bin/analytics'

# Offense count: 3
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods, CountRepeatedAttributes.
Metrics/AbcSize:
Max: 24
Max: 25

# Offense count: 3
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
# AllowedMethods: refine
Metrics/BlockLength:
Max: 76

# Offense count: 1
# Configuration parameters: CountComments.
# Configuration parameters: CountComments, CountAsOne.
Metrics/ClassLength:
Max: 120
Max: 115

# Offense count: 1
# Offense count: 2
# Configuration parameters: AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 8
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 147

# Offense count: 10
# Configuration parameters: CountComments.
# Offense count: 11
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, AllowedMethods, AllowedPatterns, IgnoredMethods.
Metrics/MethodLength:
Max: 16

# Offense count: 1
Metrics/PerceivedComplexity:
Max: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: PreferredName.
Naming/RescuedExceptionsVariableName:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/ExpandPathArguments:
Exclude:
- 'analytics-ruby.gemspec'

# Offense count: 6
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: MaxUnannotatedPlaceholdersAllowed, AllowedMethods, AllowedPatterns, IgnoredMethods.
# SupportedStyles: annotated, template, unannotated
Style/FormatStringToken:
EnforcedStyle: unannotated

# Offense count: 1
# This cop supports unsafe autocorrection (--autocorrect-all).
Style/GlobalStdStream:
Exclude:
- 'lib/segment/analytics/logging.rb'

# Offense count: 4
# This cop supports safe autocorrection (--autocorrect).
Style/IfUnlessModifier:
Exclude:
- 'analytics-ruby.gemspec'
- 'bin/analytics'
- 'lib/segment/analytics/client.rb'

# Offense count: 1
Style/MixinUsage:
Exclude:
- 'spec/spec_helper.rb'

# Offense count: 2
# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/segment/analytics/utils.rb'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
Style/Proc:
Exclude:
- 'bin/analytics'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowMultipleReturnValues.
Style/RedundantReturn:
Exclude:
- 'bin/analytics'

# Offense count: 8
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
# SupportedStyles: single_quotes, double_quotes
Style/StringLiterals:
Exclude:
- 'Rakefile'
- 'analytics-ruby.gemspec'
- 'bin/analytics'

# Offense count: 1
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: EnforcedStyleForMultiline.
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInArrayLiteral:
Exclude:
- 'Rakefile'

# Offense count: 2
# This cop supports safe autocorrection (--autocorrect).
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns, IgnoredPatterns.
# URISchemes: http, https
Layout/LineLength:
Max: 147
5 changes: 3 additions & 2 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ Dir.glob('spec/isolated/**/*.rb').each do |isolated_test_path|
default_tasks << isolated_test_path
end

# Rubocop doesn't support < 2.1
if RUBY_VERSION >= "2.1"
# Older versions of Rubocop don't support a target Ruby version of 2.1
require 'rubocop/version'
if RuboCop::Version::STRING >= '1.30.0'
require 'rubocop/rake_task'

RuboCop::RakeTask.new(:rubocop) do |task|
Expand Down
14 changes: 6 additions & 8 deletions analytics-ruby.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'commander', '~> 4.4'

# Used in specs
spec.add_development_dependency 'rake', '~> 10.3'
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rspec', '~> 3.0'
spec.add_development_dependency 'tzinfo', '1.2.1'
spec.add_development_dependency 'activesupport', '~> 4.1.11'
if RUBY_VERSION >= '2.0' && RUBY_PLATFORM != 'java'
spec.add_development_dependency 'tzinfo', '~> 1.2'
spec.add_development_dependency 'activesupport', '~> 5.2.0'
if RUBY_PLATFORM != 'java'
spec.add_development_dependency 'oj', '~> 3.6.2'
end
if RUBY_VERSION >= '2.1'
spec.add_development_dependency 'rubocop', '~> 0.51.0'
end
spec.add_development_dependency 'codecov', '~> 0.1.4'
spec.add_development_dependency 'rubocop', '~> 1.0'
spec.add_development_dependency 'codecov', '~> 0.6'
end
72 changes: 36 additions & 36 deletions bin/analytics
Original file line number Diff line number Diff line change
Expand Up @@ -43,62 +43,62 @@ command :send do |c|

c.action do |args, options|
Analytics = Segment::Analytics.new({
write_key: options.writeKey,
on_error: Proc.new { |status, msg| print msg }
:write_key => options.writeKey,
:on_error => Proc.new { |status, msg| print msg }
})

case options.type
when "track"
Analytics.track({
user_id: options.userId,
event: options.event,
anonymous_id: options.anonymousId,
properties: json_hash(options.properties),
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:user_id => options.userId,
:event => options.event,
:anonymous_id => options.anonymousId,
:properties => json_hash(options.properties),
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
when "page"
Analytics.page({
user_id: options.userId,
anonymous_id: options.anonymousId,
name: options.name,
properties: json_hash(options.properties),
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:user_id => options.userId,
:anonymous_id => options.anonymousId,
:name => options.name,
:properties => json_hash(options.properties),
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
when "screen"
Analytics.screen({
user_id: options.userId,
anonymous_id: options.anonymousId,
name: options.name,
properties: json_hash(options.properties),
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:user_id => options.userId,
:anonymous_id => options.anonymousId,
:name => options.name,
:properties => json_hash(options.properties),
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
when "identify"
Analytics.identify({
user_id: options.userId,
anonymous_id: options.anonymousId,
traits: json_hash(options.traits),
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:user_id => options.userId,
:anonymous_id => options.anonymousId,
:traits => json_hash(options.traits),
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
when "group"
Analytics.group({
user_id: options.userId,
anonymous_id: options.anonymousId,
group_id: options.groupId,
traits: json_hash(options.traits),
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:user_id => options.userId,
:anonymous_id => options.anonymousId,
:group_id => options.groupId,
:traits => json_hash(options.traits),
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
when "alias"
Analytics.alias({
previous_id: options.previousId,
user_id: options.userId,
anonymous_id: options.anonymousId,
context: json_hash(options.context),
integrations: json_hash(options.integrations)
:previous_id => options.previousId,
:user_id => options.userId,
:anonymous_id => options.anonymousId,
:context => json_hash(options.context),
:integrations => json_hash(options.integrations)
})
else
raise "Invalid Message Type #{options.type}"
Expand Down

0 comments on commit 46cec0c

Please sign in to comment.