Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.bundle/*
pkg/*
*.gem
.idea
12 changes: 12 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
inherit_from: .rubocop_todo.yml

# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://github.com/rubocop-hq/rubocop/blob/master/manual/configuration.md
70 changes: 70 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2024-01-22 12:49:43 +0000 using RuboCop version 0.75.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: 1
Metrics/AbcSize:
Max: 28

# Offense count: 1
# Configuration parameters: CountComments, ExcludedMethods.
# ExcludedMethods: refine
Metrics/BlockLength:
Max: 59

# Offense count: 1
Metrics/CyclomaticComplexity:
Max: 8

# Offense count: 3
# Configuration parameters: CountComments, ExcludedMethods.
Metrics/MethodLength:
Max: 228

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 230

# Offense count: 1
Metrics/PerceivedComplexity:
Max: 9

# Offense count: 5
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/fiscal/base.rb'
- 'lib/fiscal/config.rb'
- 'lib/fiscal/methods.rb'
- 'lib/fiscal/period.rb'

# Offense count: 1
# Configuration parameters: MinBodyLength.
Style/GuardClause:
Exclude:
- 'lib/fiscal/period.rb'

# Offense count: 1
# Configuration parameters: AllowIfModifier.
Style/IfInsideElse:
Exclude:
- 'lib/fiscal/period.rb'

# Offense count: 2
# Cop supports --auto-correct.
Style/IfUnlessModifier:
Exclude:
- 'lib/fiscal/period.rb'

# Offense count: 39
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
# URISchemes: http, https
Metrics/LineLength:
Max: 200
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in fiscal.gemspec
Expand Down
35 changes: 22 additions & 13 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
PATH
remote: .
specs:
fiscal (0.2.2)
fiscal (0.3.0)
activesupport

GEM
remote: https://rubygems.org/
specs:
activesupport (6.0.3.1)
activesupport (7.1.1)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
concurrent-ruby (1.1.6)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
base64 (0.1.1)
bigdecimal (3.1.4)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
diff-lcs (1.3)
i18n (1.8.2)
drb (2.1.1)
ruby2_keywords
i18n (1.14.1)
concurrent-ruby (~> 1.0)
minitest (5.14.1)
minitest (5.20.0)
mutex_m (0.1.2)
rake (13.0.1)
rspec (3.9.0)
rspec-core (~> 3.9.0)
Expand All @@ -32,10 +42,9 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.9.0)
rspec-support (3.9.3)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
zeitwerk (2.3.0)
ruby2_keywords (0.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)

PLATFORMS
ruby
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
require "bundler/gem_tasks"
# frozen_string_literal: true

require 'bundler/gem_tasks'
31 changes: 16 additions & 15 deletions fiscal.gemspec
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'fiscal/version'

Gem::Specification.new do |spec|
spec.name = "fiscal"
spec.name = 'fiscal'
spec.version = Fiscal::VERSION
spec.authors = ["Geordee Naliyath"]
spec.email = ["geordee@gmail.com"]
spec.summary = %q{Get the fiscal period attributes for various countries}
spec.description = %q{The "fiscal" gem helps to retrieve the fiscal year, half year, quarter and month along with start and end dates for many countries.}
spec.homepage = "https://github.com/samyukti/fiscal"
spec.license = "MIT"
spec.authors = ['Geordee Naliyath']
spec.email = ['geordee@gmail.com']
spec.summary = 'Get the fiscal period attributes for various countries'
spec.description = 'The "fiscal" gem helps to retrieve the fiscal year, half year, quarter and month along with start and end dates for many countries.'
spec.homepage = 'https://github.com/samyukti/fiscal'
spec.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_dependency "activesupport"
spec.add_dependency 'activesupport'

spec.add_development_dependency "bundler", "~> 2.1"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency 'bundler', '~> 2.1'
spec.add_development_dependency 'rake'
spec.add_development_dependency 'rspec'
end
6 changes: 4 additions & 2 deletions lib/fiscal.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'date'
require 'active_support'
require 'active_support/core_ext'
Expand All @@ -7,5 +9,5 @@
require 'fiscal/methods'
require 'fiscal/base'

Date.send :include, Fiscal
Time.send :include, Fiscal
Date.include Fiscal
Time.include Fiscal
6 changes: 3 additions & 3 deletions lib/fiscal/base.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Fiscal
# frozen_string_literal: true

module Fiscal
def self.included(base)
base.extend ClassMethods
end
Expand All @@ -12,8 +13,7 @@ def fiscal(options = {})

def fiscal(options = {})
# default date from the date instance
options[:date] = options[:date] || Date.new(self.year, self.month, self.day)
options[:date] = options[:date] || Date.new(year, month, day)
Fiscal.new(options)
end

end
11 changes: 5 additions & 6 deletions lib/fiscal/config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Fiscal
# frozen_string_literal: true

module Fiscal
module FiscalConfig
def config
# The World Factbook 2013-14. Washington, DC: Central Intelligence Agency, 2013 .
Expand All @@ -8,7 +9,7 @@ def config
# NOTE: ki, so are defaulted to 1, 1

# country, month, day
{nil: { mm: 1, dd: 1 },
{ nil: { mm: 1, dd: 1 },
ad: { mm: 1, dd: 1 },
ae: { mm: 1, dd: 1 },
af: { mm: 12, dd: 21 },
Expand Down Expand Up @@ -235,9 +236,7 @@ def config
ye: { mm: 1, dd: 1 },
za: { mm: 4, dd: 1 },
zm: { mm: 1, dd: 1 },
zw: { mm: 1, dd: 1 }
}
zw: { mm: 1, dd: 1 } }
end
end

end
end
4 changes: 2 additions & 2 deletions lib/fiscal/methods.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Fiscal
# frozen_string_literal: true

module Fiscal
class Fiscal
def initialize(options = {})
@date = options[:date]
Expand All @@ -22,5 +23,4 @@ def month(index = nil)
FiscalPeriod.new(date: @date, country: @country, type: :month, index: index)
end
end

end
Loading