Skip to content

Commit

Permalink
Add standardize and version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Aug 27, 2020
1 parent 3f8c957 commit 0180f9d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Lines of Code](http://img.shields.io/badge/lines_of_code-68-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
[![Lines of Code](http://img.shields.io/badge/lines_of_code-88-brightgreen.svg?style=flat)](http://blog.codinghorror.com/the-best-code-is-no-code-at-all/)
[![Maintainability](https://api.codeclimate.com/v1/badges/7503486b1bb494b5d976/maintainability)](https://codeclimate.com/github/hopsoft/tag_columns/maintainability)
[![Build Status](http://img.shields.io/travis/hopsoft/tag_columns.svg?style=flat)](https://travis-ci.org/hopsoft/tag_columns)
[![Coverage Status](https://img.shields.io/coveralls/hopsoft/tag_columns.svg?style=flat)](https://coveralls.io/r/hopsoft/tag_columns?branch=master)
Expand Down
3 changes: 3 additions & 0 deletions bin/standardize
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

bundle exec standardrb --fix
16 changes: 8 additions & 8 deletions lib/tag_columns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,19 @@ def tag_columns(*column_names)

define_singleton_method :"unique_#{method_name}" do |conditions = "true"|
unnest = Arel::Nodes::NamedFunction.new("unnest", [arel_table[column_name]])
query = distinct.select(unnest).
where(conditions).
where.not(arel_table[column_name].eq(nil)).
where.not(arel_table[column_name].eq("{}"))
query = distinct.select(unnest)
.where(conditions)
.where.not(arel_table[column_name].eq(nil))
.where.not(arel_table[column_name].eq("{}"))
connection.execute(query.to_sql).values.flatten.sort
end

define_singleton_method :"#{method_name}_cloud" do |conditions = "true"|
unnest = Arel::Nodes::NamedFunction.new("unnest", [arel_table[column_name]])
query = unscoped.select(unnest.as("tag")).
where(conditions).
where.not(arel_table[column_name].eq(nil)).
where.not(arel_table[column_name].eq("{}"))
query = unscoped.select(unnest.as("tag"))
.where(conditions)
.where.not(arel_table[column_name].eq(nil))
.where.not(arel_table[column_name].eq("{}"))
from(query).group("tag").order("tag").pluck(Arel.sql("tag, count(*) as count"))
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tag_columns/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module TagColumns
VERSION = "0.1.8"
VERSION = "0.1.9"
end
19 changes: 10 additions & 9 deletions tag_columns.gemspec
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
require File.expand_path("../lib/tag_columns/version", __FILE__)

Gem::Specification.new do |gem|
gem.name = "tag_columns"
gem.license = "MIT"
gem.version = TagColumns::VERSION
gem.authors = ["Nathan Hopkins"]
gem.email = ["natehop@gmail.com"]
gem.homepage = "https://github.com/hopsoft/tag_columns"
gem.summary = "Fast & simple Rails ActiveRecord model tagging using PostgreSQL's Array datatype"
gem.name = "tag_columns"
gem.license = "MIT"
gem.version = TagColumns::VERSION
gem.authors = ["Nathan Hopkins"]
gem.email = ["natehop@gmail.com"]
gem.homepage = "https://github.com/hopsoft/tag_columns"
gem.summary = "Fast & simple Rails ActiveRecord model tagging using PostgreSQL's Array datatype"

gem.files = Dir["lib/**/*.rb", "bin/*", "[A-Z]*"]
gem.test_files = Dir["test/**/*.rb"]
gem.files = Dir["lib/**/*.rb", "bin/*", "[A-Z]*"]
gem.test_files = Dir["test/**/*.rb"]

gem.add_dependency "activesupport"

gem.add_development_dependency "rake"
gem.add_development_dependency "pry-test"
gem.add_development_dependency "coveralls"
gem.add_development_dependency "standardrb"
end

0 comments on commit 0180f9d

Please sign in to comment.