Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/publish-gem.yml
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これもclaude作です。
こちらを参考にすると問題なさそうです
https://syucream.hatenablog.jp/entry/2023/06/28/115812

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Publish Gem

on:
push:
tags:
- 'v*'

jobs:
publish:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
bundler-cache: true

- name: Install dependencies
run: bundle install

- name: Run tests
run: bundle exec rspec

- name: Build gem
run: gem build soapforce.gemspec

- name: Publish to GitHub Packages
run: |
mkdir -p ~/.gem
echo "---" > ~/.gem/credentials
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
chmod 0600 ~/.gem/credentials
gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions lib/soapforce.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
require "soapforce/result"
require "soapforce/query_result"
require "soapforce/sobject"
require "soapforce/string_utils"

module Soapforce

Expand Down
4 changes: 2 additions & 2 deletions lib/soapforce/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def initialize(options = {})
@response_tags = lambda { |key| key }
else
@tag_style = :snakecase
@response_tags = lambda { |key| key.snakecase.to_sym }
@response_tags = lambda { |key| ::Soapforce::StringUtils.snakecase(key).to_sym }
end

# Override optional Savon attributes
Expand Down Expand Up @@ -586,7 +586,7 @@ def method_missing(method, *args)

def key_name(key)
if @tag_style == :snakecase
key.is_a?(Symbol) ? key : key.snakecase.to_sym
key.is_a?(Symbol) ? key : ::Soapforce::StringUtils.snakecase(key).to_sym
else
if key.to_s.include?('_')
camel_key = key.to_s.gsub(/\_(\w{1})/) {|cap| cap[1].upcase }
Expand Down
2 changes: 1 addition & 1 deletion lib/soapforce/query_result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def method_missing(method, *args, &block)

def key_name(key)
if @key_type == :symbol
key.is_a?(String) ? key.snakecase.to_sym : key
key.is_a?(String) ? ::Soapforce::StringUtils.snakecase(key).to_sym : key
else
key.to_s
end
Expand Down
2 changes: 1 addition & 1 deletion lib/soapforce/result.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def [](index)
elsif @raw_hash.key?(index.to_sym)
@raw_hash[index.to_sym]
else
@raw_hash[index.snakecase.to_sym]
@raw_hash[::Soapforce::StringUtils.snakecase(index).to_sym]
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/soapforce/sobject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def method_missing(method, *args, &block)
end

if string_method =~ /[A-Z+]/
string_method = string_method.snakecase
string_method = ::Soapforce::StringUtils.snakecase(string_method)
end

index = string_method.downcase.to_sym
Expand Down
21 changes: 21 additions & 0 deletions lib/soapforce/string_utils.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Soapforce
module StringUtils
# Converts a string to snake case.
#
# @param inputstring [String] The string to be converted to snake case.
# @return [String] A copy of the input string converted to snake case.
#
# copy from nori
# ref: https://github.com/savonrb/nori/pull/102/files
def self.snakecase(inputstring)
str = inputstring.dup
str.gsub!(/::/, '/')
str.gsub!(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
str.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
str.tr!(".", "_")
str.tr!("-", "_")
str.downcase!
str
end
end
end
2 changes: 1 addition & 1 deletion lib/soapforce/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Soapforce
VERSION = "0.8.0"
VERSION = "0.8.0.trocco.0.0.1"
end
1 change: 0 additions & 1 deletion soapforce.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Gem::Specification.new do |spec|
spec.require_paths = ["lib"]

spec.add_runtime_dependency "savon", ">= 2.3.0", '< 3.0.0'
spec.add_runtime_dependency "nori", "2.6.0"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1
で、一時的に追加したものなので、削除
ローカルでは、2.7.1 (String#snakecaseがないもの)でrspecの確認しています


spec.add_development_dependency 'rspec', '>= 2.14.0', '< 4.0.0'
spec.add_development_dependency 'webmock', '>=2.3.2'
Expand Down