Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
vinothkannans committed Jun 11, 2021
0 parents commit 1ca0306
Show file tree
Hide file tree
Showing 25 changed files with 301 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Ruby Gem

on:
push:
tags: [ v* ]

jobs:
build:
if: contains(github.ref, 'refs/tags/v')
name: Build + Publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
ruby-version: 2.6.x

- name: Publish to GPR
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
env:
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
OWNER: ${{ github.repository_owner }}

- name: Release Gem
uses: CvX/publish-rubygems-action@main
env:
RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Gemfile.lock
/pkg/
2 changes: 2 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
inherit_gem:
rubocop-discourse: default.yml
7 changes: 7 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true
source "https://rubygems.org"

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

# Specify your gem's dependencies in discourse_dev_assets.gemspec
gemspec
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2021 Civilized Discourse Construction Kit

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Discourse Dev Assets

Gem with the assets of "Discourse Dev" module.
4 changes: 4 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env rake
# frozen_string_literal: true

require "bundler/gem_tasks"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
135 changes: 135 additions & 0 deletions config/locales/faker.en.yml

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions discourse_dev_assets.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# frozen_string_literal: true

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

Gem::Specification.new do |spec|
spec.name = "discourse_dev_assets"
spec.version = DiscourseDevAssets::VERSION
spec.authors = ["Vinoth Kannan"]
spec.email = ["[email protected]"]

spec.summary = %q{Assets for Discourse dev module}
spec.description = %q{Assets for Discourse dev module}
spec.homepage = "https://github.com/discourse/discourse_dev_assets"
spec.license = "MIT"

spec.files = `git ls-files`.split($/).reject { |s| s =~ /^(spec)/ }
spec.require_paths = ["lib"]

spec.add_runtime_dependency "faker", "~> 2.16"

spec.add_development_dependency "bundler", "~> 2.0"
spec.add_development_dependency "rake", ">= 12.3.3"
spec.add_development_dependency "rubocop-discourse"

spec.required_ruby_version = '>= 2.6.0'
end
54 changes: 54 additions & 0 deletions lib/discourse_dev_assets.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# frozen_string_literal: true

Dir[File.dirname(__FILE__) + '/**/*.rb'].each { |file| require file }

module DiscourseDevAssets
require 'discourse_dev_assets/engine'

def self.avatars
# Using the stock avatar images from https://tinyfac.es
# Tiny Faces is a free crowd-sourced avatar gallery
Dir[File.join(__dir__, '..', 'avatars', '*.*')]
end
end

require "active_record/database_configurations"

ActiveRecord::Tasks::DatabaseTasks.module_eval do
alias_method :rails_each_current_configuration, :each_current_configuration

private
def each_current_configuration(environment, name = nil)
rails_each_current_configuration(environment, name) { |db_config|
next if environment == "development" &&
ENV["SKIP_TEST_DATABASE"] == "1" &&
db_config.configuration_hash[:database] != "discourse_development"

yield db_config
}
end
end

require 'faker'

Faker::Base.instance_eval do
alias :faker_translate :translate

def translate(*args, **opts)
if args[0] == "faker.lorem.words"
args[0] = "faker.discourse.words"
end

faker_translate(*args, **opts)
end
end

Faker::Lorem.instance_eval do
alias :faker_sentence :sentence

NOT_GIVEN = Object.new

def sentence(word_count: 4, supplemental: false, random_words_to_add: 15)
faker_sentence(word_count: word_count, supplemental: supplemental, random_words_to_add: random_words_to_add)
end
end
5 changes: 5 additions & 0 deletions lib/discourse_dev_assets/engine.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module DiscourseDevAssets
class Engine < Rails::Engine; end
end
5 changes: 5 additions & 0 deletions lib/discourse_dev_assets/version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# frozen_string_literal: true

module DiscourseDevAssets
VERSION = "0.0.1"
end

0 comments on commit 1ca0306

Please sign in to comment.