Skip to content

Commit

Permalink
Setup gem as ActsAsScope (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
mklemme authored Nov 18, 2019
1 parent cd163e2 commit e1c6cfb
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 51 deletions.
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ commands:
key: v1-dependencies-{{ checksum "Gemfile.lock" }}-{{ checksum "yarn.lock" }}

executors:
acts_as_template-config:
acts_as_scope-config:
docker:
- image: circleci/ruby:2.6.3-node-browsers
environment:
Expand All @@ -48,18 +48,18 @@ executors:
RACK_ENV: test
- image: circleci/postgres:9.6
environment:
POSTGRES_DB: acts_as_template_test
POSTGRES_DB: acts_as_scope_test
POSTGRES_USER: root
working_directory: ~/project

jobs:
setup:
executor: acts_as_template-config
executor: acts_as_scope-config
steps:
- install_dependencies

rspec:
executor: acts_as_template-config
executor: acts_as_scope-config
steps:
- install_dependencies
- run:
Expand All @@ -84,7 +84,7 @@ jobs:

workflows:
version: 2.1
acts_as_template:
acts_as_scope:
jobs:
- setup
- rspec:
Expand Down
16 changes: 12 additions & 4 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
# This configuration was generated by
# `rubocop --auto-gen-config --exclude-limit 999`
# on 2019-11-17 00:08:01 -0800 using RuboCop version 0.76.0.
# on 2019-11-17 21:53:29 -0800 using RuboCop version 0.76.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
# Cop supports --auto-correct.
# Configuration parameters: TreatCommentsAsGroupSeparators, Include.
# Include: **/*.gemspec
Gemspec/OrderedDependencies:
Exclude:
- 'act_as_scope.gemspec'

# Offense count: 1
Naming/AccessorMethodName:
Exclude:
- 'lib/acts_as_template.rb'
- 'lib/acts_as_scope.rb'

# Offense count: 4
# Cop supports --auto-correct.
# Configuration parameters: AutoCorrect, EnforcedStyle.
# SupportedStyles: nested, compact
Style/ClassAndModuleChildren:
Exclude:
- 'lib/acts_as_template/engine.rb'
- 'lib/acts_as_scope/engine.rb'
- 'spec/dummy/app/channels/application_cable/channel.rb'
- 'spec/dummy/app/channels/application_cable/connection.rb'
- 'spec/dummy/config/application.rb'
Expand All @@ -27,7 +35,7 @@ Style/Documentation:
Exclude:
- 'db/**/*'
- 'app/models/application_record.rb'
- 'lib/acts_as_template.rb'
- 'lib/acts_as_scope.rb'
- 'spec/dummy/app/helpers/application_helper.rb'
- 'spec/dummy/app/mailers/application_mailer.rb'
- 'spec/dummy/app/models/application_record.rb'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

# Declare your gem's dependencies in acts_as_template.gemspec.
# Declare your gem's dependencies in acts_as_scope.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# ActsAsTemplate
# ActsAsScope


## Usage

```ruby
class User < ApplicationRecord
acts_as_template
acts_as_scope
end
```

## Installation
Add this line to your application's Gemfile:

```ruby
gem 'acts_as_template'
gem 'acts_as_scope'
```

And then execute:
Expand All @@ -23,7 +23,7 @@ $ bundle

Or install it yourself as:
```bash
$ gem install acts_as_template
$ gem install acts_as_scope
```

## Contributing
Expand Down
10 changes: 5 additions & 5 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require 'rdoc/task'

RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'ActsAsTemplate'
rdoc.title = 'ActsAsScope'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.md')
rdoc.rdoc_files.include('lib/**/*.rb')
Expand All @@ -29,18 +29,18 @@ Rake::TestTask.new(:test) do |t|
end

# require 'rails'
# require "acts_as_template"
# require "acts_as_scope"
require 'github_changelog_generator/task'

namespace :acts_as_template do
namespace :acts_as_scope do
namespace :changelog do
desc 'Create a new changelog based on the current version'
GitHubChangelogGenerator::RakeTask.new :generate do |config|
user, project = ActsAsTemplate::REPO.split('/')
user, project = ActsAsScope::REPO.split('/')

config.user = user
config.project = project
config.future_release = "v#{ActsAsTemplate::VERSION}"
config.future_release = "v#{ActsAsScope::VERSION}"
config.token = ENV['CHANGELOG_TOKEN'] || ENV['GITHUB_TOKEN']
end
end
Expand Down
20 changes: 10 additions & 10 deletions act_as_template.gemspec → act_as_scope.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
$LOAD_PATH.push File.expand_path('lib', __dir__)

# Maintain your gem's version:
require 'acts_as_template/project_meta'
require 'acts_as_scope/project_meta'

# Describe your gem and declare its dependencies:
Gem::Specification.new do |spec|
spec.name = ActsAsTemplate::NAME
spec.version = ActsAsTemplate::VERSION
spec.authors = ActsAsTemplate::AUTHORS
spec.email = ActsAsTemplate::EMAIL
spec.homepage = ActsAsTemplate::HOMEPAGE
spec.summary = ActsAsTemplate::SUMMARY
spec.description = ActsAsTemplate::DESCRIPTION
spec.license = ActsAsTemplate::LICENSE
spec.name = ActsAsScope::NAME
spec.version = ActsAsScope::VERSION
spec.authors = ActsAsScope::AUTHORS
spec.email = ActsAsScope::EMAIL
spec.homepage = ActsAsScope::HOMEPAGE
spec.summary = ActsAsScope::SUMMARY
spec.description = ActsAsScope::DESCRIPTION
spec.license = ActsAsScope::LICENSE

spec.metadata['allowed_push_host'] = 'https://rubygems.org'

Expand All @@ -29,6 +29,6 @@ Gem::Specification.new do |spec|

spec.add_development_dependency 'invisible_standards'
spec.add_development_dependency 'rspec', '>= 3'
spec.add_development_dependency 'rubocop', '>= 0.70'
spec.add_development_dependency 'rspec_junit_formatter', '>= 0'
spec.add_development_dependency 'rubocop', '>= 0.70'
end
2 changes: 1 addition & 1 deletion app/models/application_record.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class ApplicationRecord < ActiveRecord::Base
include ActsAsTemplate
include ActsAsScope

self.abstract_class = true
end
6 changes: 3 additions & 3 deletions lib/acts_as_template.rb → lib/acts_as_scope.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# frozen_string_literal: true

require 'acts_as_template/engine'
require 'acts_as_scope/engine'
require 'invisible_standards'

module ActsAsTemplate
module ActsAsScope
extend ActiveSupport::Concern

included do
Expand All @@ -13,7 +13,7 @@ def set_foo_bar_field(string)
end

class_methods do
def acts_as_template(options = {})
def acts_as_scope(options = {})
cattr_accessor :foo_bar_field,
default: options.fetch(:foo_bar_field, '')
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module ActsAsTemplate
module ActsAsScope
class Engine < ::Rails::Engine
end
end
13 changes: 13 additions & 0 deletions lib/acts_as_scope/project_meta.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# frozen_string_literal: true

module ActsAsScope
VERSION = '0.1.0'
NAME = 'acts_as_scope'
REPO = 'invisiblehats/acts_as_scope'
AUTHORS = ['Myk Klemme'].freeze
EMAIL = ['[email protected]'].freeze
HOMEPAGE = 'https://github.com/invisiblehats/acts_as_scope'
SUMMARY = 'Summary of ActsAsScope.'
DESCRIPTION = 'Description of ActsAsScope.'
LICENSE = 'MIT'
end
13 changes: 0 additions & 13 deletions lib/acts_as_template/project_meta.rb

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true
# desc "Explaining what the task does"
# task :acts_as_template do
# task :acts_as_scope do
# # Task goes here
# end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

RSpec.describe ActsAsTemplate, type: :model do
RSpec.describe ActsAsScope, type: :model do
it 'this test succeeds' do
expect(true).to eq true
end
Expand Down
2 changes: 1 addition & 1 deletion spec/dummy/config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'rails/all'

Bundler.require(*Rails.groups)
require 'acts_as_template'
require 'acts_as_scope'

module Dummy
class Application < Rails::Application
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require 'rails'
require 'bundler/setup'
require 'acts_as_template'
require 'acts_as_scope'

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand Down

0 comments on commit e1c6cfb

Please sign in to comment.