Skip to content

Commit

Permalink
Update Ruby versions
Browse files Browse the repository at this point in the history
  • Loading branch information
corny committed Aug 7, 2024
1 parent ae056dc commit 7abfd04
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rspec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
name: Ruby ${{ matrix.ruby }}
strategy:
matrix:
ruby: ['2.7', '3.0', '3.2']
ruby: ['3.0', '3.2', '3.3']

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
.ruby-version
.ruby-gemset
.gems/
*.gem

# validator working directory
validator/
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AllCops:
- Gemfile
DisplayCopNames: true
StyleGuideCopsOnly: false
TargetRubyVersion: 2.7
TargetRubyVersion: 3.0

## Layout Cops - https://docs.rubocop.org/rubocop/cops_layout.html

Expand Down
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ require "rspec/core/rake_task"

RSpec::Core::RakeTask.new(:spec)

task :default => :spec
task default: :spec

namespace :validator do
VALIDATOR_SOURCES = {
tool: {
tool: {
filename: "validator/validationtool-1.4.1-standalone.jar",
release_url: "https://github.com/itplr-kosit/validator/releases/download/v1.4.1/validationtool-1.4.1.zip",
},
scenarios: {
filename: "validator/scenarios.xml",
release_url: "https://github.com/itplr-kosit/validator-configuration-xrechnung/releases/download/release-2023-05-12/validator-configuration-xrechnung_2.3.1_2023-05-12.zip",
}
}
},
}.freeze

VALIDATOR_SOURCES.each do |_, v|
base = Pathname.new(__dir__).join("validator")
Expand Down
4 changes: 1 addition & 3 deletions lib/xrechnung.rb
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,7 @@ def to_xml(indent: 2, target: "")
xml.cbc :TaxCurrencyCode, tax_currency_code
xml.cbc :BuyerReference, buyer_reference

unless self.class.members[:invoice_period].optional && invoice_period.nil?
invoice_period&.to_xml(xml)
end
invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?

xml.cac :OrderReference do
xml.cbc :ID, purchase_order_reference
Expand Down
2 changes: 1 addition & 1 deletion lib/xrechnung/currency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def value_to_s
end

def xml_args
[value_to_s, currencyID: currency_id]
[value_to_s, { currencyID: currency_id }]
end
end

Expand Down
4 changes: 1 addition & 3 deletions lib/xrechnung/invoice_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,7 @@ def to_xml(xml)
xml.cbc :InvoicedQuantity, invoiced_quantity.amount_to_s, unitCode: invoiced_quantity.unit_code
xml.cbc :LineExtensionAmount, *line_extension_amount.xml_args

unless self.class.members[:invoice_period].optional && invoice_period.nil?
invoice_period&.to_xml(xml)
end
invoice_period&.to_xml(xml) unless self.class.members[:invoice_period].optional && invoice_period.nil?
item&.to_xml(xml)
price&.to_xml(xml)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/xrechnung/legal_monetary_total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def to_xml(xml)
self.class.members.each_key do |name|
next if self[name].nil?

xml.cbc :"#{name.to_s.split("_").map(&:capitalize).join}", *self[name].xml_args
xml.cbc :"#{name.to_s.split('_').map(&:capitalize).join}", *self[name].xml_args
end
xml.target!
end
Expand Down
4 changes: 1 addition & 3 deletions lib/xrechnung/price.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ class Price
member :allowance_charge, type: Xrechnung::AllowanceCharge

def initialize(**kwargs)
unless kwargs[:price_amount].is_a?(Currency)
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount])
end
kwargs[:price_amount] = Currency::EUR(kwargs[:price_amount]) unless kwargs[:price_amount].is_a?(Currency)
super(**kwargs)
end

Expand Down
3 changes: 1 addition & 2 deletions lib/xrechnung/quantity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ def amount_to_s
format("%0.2f", amount)
end


def xml_args
[amount_to_s, unitCode: unit_code]
[amount_to_s, { unitCode: unit_code }]
end
end
end
2 changes: 1 addition & 1 deletion lib/xrechnung/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Xrechnung
VERSION = "0.3.0"
VERSION = "0.3.0".freeze
end
4 changes: 2 additions & 2 deletions spec/fixtures/ruby/allowance_charge.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def build_allowance_charge
Xrechnung::AllowanceCharge.new(
charge_indicator: true,
amount: 0,
base_amount: 1294.30
amount: 0,
base_amount: 1294.30,
)
end
4 changes: 2 additions & 2 deletions spec/fixtures/ruby/payment_means.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

def build_payment_means
Xrechnung::PaymentMeans.new(
payment_means_code: 30,
payee_financial_account: build_payee_financial_account
payment_means_code: 30,
payee_financial_account: build_payee_financial_account,
)
end
16 changes: 8 additions & 8 deletions spec/fixtures/ruby/tax_total.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ def build_tax_total
build_tax_subtotal,

Xrechnung::TaxSubtotal.new(
taxable_amount: Xrechnung::Currency::EUR(1285.70),
tax_amount: Xrechnung::Currency::EUR(90.00),
tax_category: Xrechnung::TaxCategory.new(
id: "S",
percent: 7,
tax_scheme_id: "VAT",
),
),
taxable_amount: Xrechnung::Currency::EUR(1285.70),
tax_amount: Xrechnung::Currency::EUR(90.00),
tax_category: Xrechnung::TaxCategory.new(
id: "S",
percent: 7,
tax_scheme_id: "VAT",
),
),
],
)
end
2 changes: 1 addition & 1 deletion spec/xrechnung/party_legal_entity_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
it "generates xml" do
expect_xml_eq_fixture(
build_party_legal_entity(company_id: "DE 214365879"),
"party_legal_entity"
"party_legal_entity",
)
end
end
5 changes: 2 additions & 3 deletions spec/xrechnung/party_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
require 'spec_helper'
require "spec_helper"
load("spec/fixtures/ruby/party.rb")


RSpec.describe Xrechnung::Party do
let(:party) do
build_party
Expand All @@ -20,6 +19,6 @@
it "generates flat party" do
party.nested = false

expect(to_xml(party)).to_not include "<cbc:Party>"
expect(to_xml(party)).not_to include "<cbc:Party>"
end
end
8 changes: 4 additions & 4 deletions spec/xrechnung_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
end

it "has a version number" do
expect(Xrechnung::VERSION).not_to be nil
expect(Xrechnung::VERSION).not_to be_nil
end

# rubocop:disable RSpec/ExampleLength
Expand Down Expand Up @@ -39,7 +39,7 @@
doc.accounting_supplier_party = build_party

doc.accounting_customer_party = Xrechnung::Party.new(
postal_address: Xrechnung::PostalAddress.new(
postal_address: Xrechnung::PostalAddress.new(
street_name: "Malerweg 2",
additional_street_name: "Hinterhof A",
city_name: "Großstadt",
Expand All @@ -50,10 +50,10 @@
party_identification: Xrechnung::PartyIdentification.new(
id: "70012",
),
party_legal_entity: Xrechnung::PartyLegalEntity.new(
party_legal_entity: Xrechnung::PartyLegalEntity.new(
registration_name: "Bauamt GmbH & Co KG",
),
contact: Xrechnung::Contact.new(
contact: Xrechnung::Contact.new(
name: "Manfred Mustermann",
telephone: "+49 12345 98 765 - 44",
electronic_mail: "manfred.mustermann@bauamt.de",
Expand Down
16 changes: 8 additions & 8 deletions xrechnung.gemspec
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
require_relative 'lib/xrechnung/version'
require_relative "lib/xrechnung/version"

Gem::Specification.new do |spec|
spec.name = "xrechnung"
spec.version = Xrechnung::VERSION
spec.authors = ["Julian Kornberger"]
spec.email = ["jk+github@digineo.de"]

spec.summary = %q{Library to create invoices in the XRechnung format.}
spec.homepage = "https://github.com/digineo/xrechnung"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
spec.summary = "Library to create invoices in the XRechnung format."
spec.homepage = "https://github.com/digineo/xrechnung"
spec.license = "MIT"
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/digineo/xrechnung"

# Specify which files should be added to the gem when it is released.
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
spec.files = Dir.chdir(File.expand_path(__dir__)) {
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
}

spec.require_paths = ["lib"]

Expand Down

0 comments on commit 7abfd04

Please sign in to comment.