Skip to content

Commit

Permalink
Add rubocop
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanahman committed Apr 7, 2019
1 parent 25faf66 commit 724a11c
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 49 deletions.
24 changes: 24 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# This is the modified configuration used to check the source code.

# === OVERRIDE ===
#
# - https://rubocop.readthedocs.io/en/latest/cops_metrics/#metricslinelength
#
Metrics/LineLength:
Max: 120

# === OVERRIDE ===
#
# - https://rubocop.readthedocs.io/en/latest/cops_metrics/#metricsmethodlength
#
Metrics/MethodLength:
Max: 15

# === DISABLE
#
# - https://rubocop.readthedocs.io/en/latest/cops_style/#styletrivialaccessors
#
# Why? Faulty corrections.
#
Style/TrivialAccessors:
Enabled: false
6 changes: 4 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
source "https://rubygems.org"
# frozen_string_literal: true

git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
source 'https://rubygems.org'

git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }

# Specify your gem's dependencies in nssql.gemspec
gemspec
14 changes: 8 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
require "bundler/gem_tasks"
require "rake/testtask"
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rake/testtask'

Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.libs << "lib"
t.test_files = FileList["test/**/*_test.rb"]
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end

task :default => :test
task default: :test
7 changes: 4 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "nssql"
require 'bundler/setup'
require 'nssql'

# You can add fixtures and/or initialization code here to make experimenting
# with your gem easier. You can also use a different console, if you like.
Expand All @@ -10,5 +11,5 @@ require "nssql"
# require "pry"
# Pry.start

require "irb"
require 'irb'
IRB.start(__FILE__)
16 changes: 9 additions & 7 deletions lib/nssql.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
require "nssql/version"
require "nssql/settings"
require "nssql/table"
# frozen_string_literal: true

require 'nssql/version'
require 'nssql/settings'
require 'nssql/table'

require 'odbc_utf8'
require 'tempfile'

# NSSQL module.
#
module NSSQL
class Error < StandardError; end

class << self
def select_array(query)
execute(query) do |result|
result.fetch_all
end
execute(query, &:fetch_all)
end

def select_to_file(query)
Expand Down Expand Up @@ -45,7 +47,7 @@ def system_call(command)
end

def one_line_query(query)
query.gsub("\n", ' ').gsub(/\s+/, ' ').strip
query.tr("\n", ' ').gsub(/\s+/, ' ').strip
end

def netsuite_connection
Expand Down
8 changes: 4 additions & 4 deletions lib/nssql/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ module NSSQL
class Settings
include Singleton

SETTINGS = [
:user,
:password,
SETTINGS = %i[
user
password
].freeze

attr_accessor *SETTINGS
attr_accessor(*SETTINGS)

class << self
SETTINGS.each do |setting|
Expand Down
2 changes: 2 additions & 0 deletions lib/nssql/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module NSSQL
VERSION = '0.1.0'
end
44 changes: 23 additions & 21 deletions nssql.gemspec
Original file line number Diff line number Diff line change
@@ -1,44 +1,46 @@
# frozen_string_literal: true

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

Gem::Specification.new do |spec|
spec.name = "nssql"
spec.name = 'nssql'
spec.version = NSSQL::VERSION
spec.authors = ["Love Ottosson"]
spec.email = ["[email protected]"]
spec.authors = ['Love Ottosson']
spec.email = ['[email protected]']

spec.summary = "Lightweight gem for fetching data from NetSuite with SQL."
spec.description = "Represent NetSuite tables as you want and fetch only the needed data."
spec.homepage = "https://github.com/apoex/nssql"
spec.license = "MIT"
spec.summary = 'Lightweight gem for fetching data from NetSuite with SQL.'
spec.description = 'Represent NetSuite tables as you want and fetch only the needed data.'
spec.homepage = 'https://github.com/apoex/nssql'
spec.license = 'MIT'

# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
# to allow pushing to a single host or delete this section to allow pushing to any host.
if spec.respond_to?(:metadata)
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"

spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = "https://github.com/apoex/nssql"
spec.metadata["changelog_uri"] = "https://github.com/apoex/nssql/blob/master/CHANGELOG.md"
spec.metadata['homepage_uri'] = spec.homepage
spec.metadata['source_code_uri'] = 'https://github.com/apoex/nssql'
spec.metadata['changelog_uri'] = 'https://github.com/apoex/nssql/blob/master/CHANGELOG.md'
else
raise "RubyGems 2.0 or newer is required to protect against " \
"public gem pushes."
raise 'RubyGems 2.0 or newer is required to protect against ' \
'public gem pushes.'
end

# 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__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
end
spec.bindir = "exe"
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]
spec.require_paths = ['lib']

spec.add_runtime_dependency 'ruby-odbc', '~> 0.99997'

spec.add_development_dependency "bundler", "~> 1.17"
spec.add_development_dependency "rake", "~> 10.0"
spec.add_development_dependency "minitest", "~> 5.0"
spec.add_development_dependency 'bundler', '~> 1.17'
spec.add_development_dependency 'minitest', '~> 5.0'
spec.add_development_dependency 'rake', '~> 10.0'
spec.add_development_dependency 'rubocop', '>= 0.60.0'
end
4 changes: 3 additions & 1 deletion test/nssql_settings_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "test_helper"
# frozen_string_literal: true

require 'test_helper'

class NssqlSettingsTest < Minitest::Test
def test_that_it_is_configurable
Expand Down
4 changes: 3 additions & 1 deletion test/nssql_table_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "test_helper"
# frozen_string_literal: true

require 'test_helper'

class NssqlTableTest < Minitest::Test
class TestTable < NSSQL::Table
Expand Down
4 changes: 3 additions & 1 deletion test/nssql_test.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
require "test_helper"
# frozen_string_literal: true

require 'test_helper'

class NssqlTest < Minitest::Test
def setup
Expand Down
8 changes: 5 additions & 3 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
require "nssql"
# frozen_string_literal: true

require "minitest/autorun"
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'nssql'

require 'minitest/autorun'

0 comments on commit 724a11c

Please sign in to comment.