k_director 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,89 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ # template_variant: :ruby
5
+
6
+ require 'English'
7
+
8
+ # NOTE: you may need change file permissions
9
+ # chmod +x hooks/pre-commit
10
+
11
+ exit 0 if ARGV.include?('--no-verify')
12
+
13
+ warning_keywords = %w[console.log]
14
+ keywords = %w[binding.pry console.dir byebug debugger]
15
+ files_changed = `git diff-index --name-only HEAD --`.split
16
+
17
+ # puts '----------------------------------------------------------------------'
18
+ # puts remove files changed from the pre-commit checking if they are one of the following files
19
+ # puts '----------------------------------------------------------------------'
20
+ # files_changed = files_changed - ['hooks/pre-commit']
21
+ # files_changed = files_changed - ['hooks/update-version']
22
+
23
+ # byebug may need to be in these files
24
+ files_changed -= ['Gemfile']
25
+ files_changed -= ['Gemfile.lock']
26
+ files_changed -= ['.gitignore']
27
+ files_changed -= ['README.md']
28
+
29
+ files_changed = files_changed.reject { |f| f.downcase.end_with?('.json') }
30
+ files_changed = files_changed.reject { |f| f.downcase.end_with?('.yml') }
31
+
32
+ # ignore files from specific folders
33
+
34
+ file_groups = files_changed.select do |item|
35
+ item.start_with?('.githooks') # ||
36
+ # item.start_with?('lib/generators')
37
+ end
38
+
39
+ files_changed -= file_groups
40
+
41
+ # remove files that are changed because they are deleted
42
+ files_changed = files_changed.select { |filename| File.file?(filename) }
43
+
44
+ # puts '----------------------------------------------------------------------'
45
+ # puts 'Files Changed'
46
+ # puts '----------------------------------------------------------------------'
47
+ # puts files_changed
48
+ # puts '----------------------------------------------------------------------'
49
+
50
+ unless files_changed.length.zero?
51
+ # puts "#{keywords.join('|')}"
52
+ # puts "#{files_changed.join(' ')}"
53
+
54
+ `git grep -q -E "#{warning_keywords.join('|')}" #{files_changed.join(' ')}`
55
+
56
+ if $CHILD_STATUS.exitstatus.zero?
57
+ puts '' # Check following lines:''
58
+ puts $CHILD_STATUS.exitstatus
59
+ files_changed.each do |file|
60
+ warning_keywords.each do |keyword|
61
+ # puts "#{keyword} ::: #{file}"
62
+ `git grep -q -E #{keyword} #{file}`
63
+ if $CHILD_STATUS.exitstatus.zero?
64
+ line = `git grep -n #{keyword} #{file} | awk -F ":" '{print $2}'`.split.join(', ')
65
+ puts "WARNING:\t\033[31m#{file}\033[0m contains #{keyword} at line \033[33m#{line}\033[0m."
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ `git grep -q -E "#{keywords.join('|')}" #{files_changed.join(' ')}`
72
+
73
+ if $CHILD_STATUS.exitstatus.zero?
74
+ puts '' # Check following lines:''
75
+ puts $CHILD_STATUS.exitstatus
76
+ files_changed.each do |file|
77
+ keywords.each do |keyword|
78
+ # puts "#{keyword} ::: #{file}"
79
+ `git grep -q -E #{keyword} #{file}`
80
+ if $CHILD_STATUS.exitstatus.zero?
81
+ line = `git grep -n #{keyword} #{file} | awk -F ":" '{print $2}'`.split.join(', ')
82
+ puts "ERROR :\t\033[31m#{file}\033[0m contains #{keyword} at line \033[33m#{line}\033[0m."
83
+ end
84
+ end
85
+ end
86
+ puts '# Force commit with --no-verify'
87
+ exit 1
88
+ end
89
+ end
@@ -0,0 +1,53 @@
1
+ name: Build Application
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby }}
13
+ strategy:
14
+ matrix:
15
+ ruby: ['2.7.1'] #, '3.1.0']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+
25
+ - name: Run tests
26
+ run: bundle exec rspec
27
+
28
+ - name: Slack notify on rspec error
29
+ if: failure()
30
+ uses: rtCamp/action-slack-notify@v2
31
+ env:
32
+ SLACK_CHANNEL: klueless-repos
33
+ SLACK_COLOR: '#ff0000'
34
+ SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
35
+ SLACK_TITLE: 'RSpec failure on ${{github.repository}} - try:'
36
+ SLACK_MESSAGE: 'rspec'
37
+ SLACK_USERNAME: klueless-io
38
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
39
+
40
+ - name: Run rubocop
41
+ run: bundle exec rubocop
42
+
43
+ - name: Slack notification on rubocop error
44
+ if: failure()
45
+ uses: rtCamp/action-slack-notify@v2
46
+ env:
47
+ SLACK_CHANNEL: klueless-repos
48
+ SLACK_COLOR: '#ff0000'
49
+ SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
50
+ SLACK_TITLE: 'Rubocop failure on $ - try:'
51
+ SLACK_MESSAGE: 'cop -a'
52
+ SLACK_USERNAME: klueless-io
53
+ SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
@@ -0,0 +1,54 @@
1
+ name: SemVer
2
+ on:
3
+ workflow_run:
4
+ workflows: ["Build Application"]
5
+ branches: [main]
6
+ types:
7
+ - completed
8
+ jobs:
9
+ release:
10
+ runs-on: ubuntu-latest
11
+ if: ${{ github.event.workflow_run.conclusion == 'success' }}
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+ - uses: actions/setup-node@v2
15
+ with:
16
+ node-version: '16'
17
+
18
+ # - uses: hmarr/debug-action@v2 # TURN on ENV DEBUG
19
+
20
+ - name: Cache node modules
21
+ uses: actions/cache@v2
22
+ id: cache-node-modules
23
+ env:
24
+ cache-name: cache-node-modules
25
+ with:
26
+ path: ~/.npm
27
+ key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
28
+ restore-keys: |
29
+ ${{ runner.os }}-build-${{ env.cache-name }}-
30
+ ${{ runner.os }}-build-
31
+ ${{ runner.os }}-
32
+
33
+ - name: Install semantic-release dependencies
34
+ if: steps.cache.outputs.cache-hit != 'true'
35
+ run: npm ci
36
+
37
+ # SEE MORE: https://github.com/semantic-release/semantic-release/issues/753
38
+ - name: Run SemVer
39
+ run: npm run release
40
+ env:
41
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42
+ GEM_HOST_API_KEY: ${{ secrets.GEM_HOST_API_KEY }}
43
+
44
+ # - name: Slack notify new version created
45
+ # if: success()
46
+ # uses: rtCamp/action-slack-notify@v2
47
+ # env:
48
+ # SLACK_CHANNEL: klueless-repos
49
+ # SLACK_COLOR: '#00ff00'
50
+ # SLACK_ICON: https://avatars.githubusercontent.com/u/2956762?s=64&v=4
51
+ # SLACK_TITLE: 'New version released on ${{github.repository}}'
52
+ # SLACK_MESSAGE: 'git pull'
53
+ # SLACK_USERNAME: klueless-io
54
+ # SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
data/.gitignore ADDED
@@ -0,0 +1,46 @@
1
+ # Move this into a KLUE SATELITE DOCUMENT
2
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
3
+ #
4
+ # If you find yourself ignoring temporary files generated by your text editor
5
+ # or operating system, you probably want to add a global ignore instead:
6
+ # git config --global core.excludesfile '~/.gitignore_global'
7
+ #
8
+ # The Octocat has a Gist containing some good rules to add to this file.
9
+ # https://gist.github.com/octocat/9257657
10
+
11
+ /_/
12
+ /.bundle/
13
+ /.history/
14
+ /.yardoc
15
+ /_yardoc/
16
+ /coverage/
17
+ /log/
18
+ !/log/.keep
19
+ /doc/
20
+ /pkg/
21
+ /spec/reports/
22
+ /tmp/
23
+ !/tmp/.keep
24
+ *.bundle
25
+ *.so
26
+ *.o
27
+ *.a
28
+ mkmf.log
29
+
30
+ # Ruby Version
31
+ .ruby-version
32
+
33
+ # Environment File
34
+ .env
35
+
36
+ # Gems should not use a Gemfile.lock
37
+ Gemfile.lock
38
+
39
+ # RubyGem definitions
40
+ *.gem
41
+
42
+ # rspec failure tracking
43
+ .rspec_status
44
+
45
+ # ByeBug history
46
+ .byebug_history
data/.releaserc-old ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "branches": [
3
+ "main"
4
+ ],
5
+ "verifyRelease": [{
6
+ "path": "@semantic-release/exec",
7
+ "cmd": "git config --global user.name 'David Cruwys';echo '${nextRelease.version}' > .ver;git add .;git commit -am '${nextRelease.version} [skip ci]';git push"
8
+ }],
9
+ "plugins": [
10
+ "@semantic-release/commit-analyzer",
11
+ "@semantic-release/release-notes-generator",
12
+ [
13
+ "@semantic-release/npm",
14
+ {
15
+ "npmPublish": false
16
+ }
17
+ ],
18
+ [
19
+ "@klueless-js/semantic-release-rubygem",
20
+ {
21
+ "gemPublish": false
22
+ }
23
+ ],
24
+ "semantic-release-rubygem",
25
+ [
26
+ "@semantic-release/changelog",
27
+ {
28
+ "changelogFile": "docs/CHANGELOG.md",
29
+ "changelogFileTitle": "k_director Changelog"
30
+ }
31
+ ],
32
+ [
33
+ "@semantic-release/git",
34
+ {
35
+ "assets": [
36
+ "lib/k_director/version.rb",
37
+ "docs/CHANGELOG.md"
38
+ ],
39
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
40
+ }
41
+ ],
42
+ "@semantic-release/github"
43
+ ],
44
+ "repositoryUrl": "git@github.com:klueless-io/k_director.git"
45
+ }
46
+
data/.releaserc.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "branches": [
3
+ "main"
4
+ ],
5
+ "plugins": [
6
+ "@semantic-release/commit-analyzer",
7
+ "@semantic-release/release-notes-generator",
8
+ [
9
+ "@semantic-release/npm",
10
+ {
11
+ "npmPublish": false
12
+ }
13
+ ],
14
+ [
15
+ "@klueless-js/semantic-release-rubygem",
16
+ {
17
+ "gemPublish": true
18
+ }
19
+ ],
20
+ [
21
+ "@semantic-release/changelog",
22
+ {
23
+ "changelogFile": "docs/CHANGE.md",
24
+ "changelogFileTitle": "k_director Changelog"
25
+ }
26
+ ],
27
+ [
28
+ "@semantic-release/git",
29
+ {
30
+ "assets": [
31
+ "lib/k_director/version.rb",
32
+ "docs/CHANGELOG.md"
33
+ ],
34
+ "message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}"
35
+ }
36
+ ],
37
+ "@semantic-release/github"
38
+ ],
39
+ "repositoryUrl": "git@github.com:klueless-io/k_director.git"
40
+ }
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,86 @@
1
+ inherit_mode:
2
+ merge:
3
+ - Exclude # see: https://stackoverflow.com/a/70818366/473923
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ DisplayCopNames: true
8
+ ExtraDetails: true
9
+ NewCops: enable
10
+ Exclude:
11
+ - ".builders/**/*"
12
+ - "spec/samples/**/*"
13
+
14
+ Metrics/BlockLength:
15
+ Exclude:
16
+ - "**/spec/**/*"
17
+ - "*.gemspec"
18
+ IgnoredMethods:
19
+ - configure
20
+ - context
21
+ - define
22
+ - describe
23
+ - draw
24
+ - factory
25
+ - feature
26
+ - guard
27
+ - included
28
+ - it
29
+ - let
30
+ - let!
31
+ - scenario
32
+ - setup
33
+ - shared_context
34
+ - shared_examples
35
+ - shared_examples_for
36
+ - transaction
37
+
38
+ Metrics/MethodLength:
39
+ Max: 25
40
+
41
+ Layout/LineLength:
42
+ Max: 200
43
+ # Ignores annotate output
44
+ IgnoredPatterns: ['\A# \*\*']
45
+ IgnoreCopDirectives: true
46
+
47
+ Lint/UnusedMethodArgument:
48
+ AllowUnusedKeywordArguments: true
49
+
50
+ Style/BlockComments:
51
+ Enabled: false
52
+ Include:
53
+ - "**/spec/*"
54
+
55
+ # My Preferences - Start
56
+ Metrics/ClassLength:
57
+ Enabled: false
58
+ Metrics/ModuleLength:
59
+ Exclude:
60
+ - "**/spec/**/*"
61
+ Naming/MemoizedInstanceVariableName:
62
+ Enabled: false
63
+ Naming/VariableNumber:
64
+ Exclude:
65
+ - "**/spec/**/*"
66
+ Style/EmptyMethod:
67
+ Exclude:
68
+ - "**/spec/**/*"
69
+ Metrics/ParameterLists:
70
+ Exclude:
71
+ - "**/spec/**/*"
72
+ Layout/EmptyLineBetweenDefs:
73
+ Exclude:
74
+ - "**/spec/**/*"
75
+
76
+ Lint/AmbiguousBlockAssociation:
77
+ Exclude:
78
+ - "**/spec/**/*"
79
+
80
+ Style/AccessorGrouping:
81
+ Enabled: false
82
+
83
+ Layout/SpaceBeforeComma:
84
+ Enabled: false
85
+ # My Preferences - End
86
+
data/.ver ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem 'guard-bundler'
9
+ gem 'guard-rspec'
10
+ gem 'guard-rubocop'
11
+ gem 'rake', '~> 12.0'
12
+ gem 'rake-compiler', require: false
13
+ gem 'rspec', '~> 3.0'
14
+ gem 'rubocop'
15
+ gem 'rubocop-rake', require: false
16
+ gem 'rubocop-rspec', require: false
17
+ end
data/Guardfile ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ guard :bundler, cmd: 'bundle install' do
4
+ watch('Gemfile')
5
+ watch('.gemspec')
6
+ end
7
+
8
+ group :green_pass_then_cop, halt_on_fail: true do
9
+ guard :rspec, cmd: 'bundle exec rspec -f doc' do
10
+ require 'guard/rspec/dsl'
11
+ dsl = Guard::RSpec::Dsl.new(self)
12
+
13
+ # RSpec files
14
+ rspec = dsl.rspec
15
+ watch(rspec.spec_helper) { rspec.spec_dir }
16
+ watch(rspec.spec_support) { rspec.spec_dir }
17
+ watch(rspec.spec_files)
18
+
19
+ # Ruby files
20
+ ruby = dsl.ruby
21
+ dsl.watch_spec_files_for(ruby.lib_files)
22
+ watch(%r{^lib//(.+)\.rb$}) { |m| "spec/unit/#{m[1]}_spec.rb" }
23
+ watch(%r{^lib//commands/(.+)\.rb$}) { |m| "spec/unit/commands/#{m[1]}_spec.rb" }
24
+ end
25
+
26
+ guard :rubocop, all_on_start: false, cli: ['--format', 'clang'] do
27
+ watch(/{.+\.rb$/)
28
+ watch(%r{(?:.+/)?\.rubocop(?:_todo)?\.yml$}) { |m| File.dirname(m[0]) }
29
+ end
30
+ end
data/README.md ADDED
@@ -0,0 +1,83 @@
1
+ # K Director
2
+
3
+ > KDirector provides domain specific language implementations for code generation
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'k_director'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ Or install it yourself as:
20
+
21
+ ```bash
22
+ gem install k_director
23
+ ```
24
+
25
+
26
+ ## Stories
27
+
28
+ ### Main Story
29
+
30
+ As a Developer, I want to generate code using a DSL, so that I can speed up application development
31
+
32
+ See all [stories](./STORIES.md)
33
+
34
+
35
+ ## Usage
36
+
37
+ See all [usage examples](./USAGE.md)
38
+
39
+
40
+
41
+ ## Development
42
+
43
+ Checkout the repo
44
+
45
+ ```bash
46
+ git clone https://github.com/klueless-io/k_director
47
+ ```
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests.
50
+
51
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
52
+
53
+ ```bash
54
+ bin/console
55
+
56
+ Aaa::Bbb::Program.execute()
57
+ # => ""
58
+ ```
59
+
60
+ `k_director` is setup with Guard, run `guard`, this will watch development file changes and run tests automatically, if successful, it will then run rubocop for style quality.
61
+
62
+ To release a new version, update the version number in `version.rb`, build the gem and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ```bash
65
+ rake publish
66
+ rake clean
67
+ ```
68
+
69
+ ## Contributing
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/klueless-io/k_director. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
76
+
77
+ ## Code of Conduct
78
+
79
+ Everyone interacting in the K Director project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/klueless-io/k_director/blob/master/CODE_OF_CONDUCT.md).
80
+
81
+ ## Copyright
82
+
83
+ Copyright (c) David Cruwys. See [MIT License](LICENSE.txt) for further details.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ # source: https://stephenagrice.medium.com/making-a-command-line-ruby-gem-write-build-and-push-aec24c6c49eb
4
+
5
+ GEM_NAME = 'k_director'
6
+
7
+ require 'bundler/gem_tasks'
8
+ require 'rspec/core/rake_task'
9
+ require 'k_director/version'
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+
13
+ require 'rake/extensiontask'
14
+
15
+ desc 'Compile all the extensions'
16
+ task build: :compile
17
+
18
+ Rake::ExtensionTask.new('k_director') do |ext|
19
+ ext.lib_dir = 'lib/k_director'
20
+ end
21
+
22
+ desc 'Publish the gem to RubyGems.org'
23
+ task :publish do
24
+ version = KDirector::VERSION
25
+ system 'gem build'
26
+ system "gem push #{GEM_NAME}-#{version}.gem"
27
+ end
28
+
29
+ desc 'Remove old *.gem files'
30
+ task :clean do
31
+ system 'rm *.gem'
32
+ end
33
+
34
+ task default: %i[clobber compile spec]
data/bin/console ADDED
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # frozen_string_literal: true
4
+
5
+ require 'bundler/setup'
6
+ require 'k_director'
7
+
8
+ # You can add fixtures and/or initialization code here to make experimenting
9
+ # with your gem easier. You can also use a different console, if you like.
10
+
11
+ # (If you use this, don't forget to add pry to your Gemfile!)
12
+ # require 'pry'
13
+ # Pry.start
14
+
15
+ require 'irb'
16
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # frozen_string_literal: true
4
+
5
+ set -euo pipefail
6
+ IFS=$'\n\t'
7
+ set -vx
8
+
9
+ bundle install
10
+
11
+ # Do any other automated setup that you need to do here
data/docs/CHANGE.md ADDED
@@ -0,0 +1,6 @@
1
+ ## [0.0.4](https://github.com/klueless-io/k_director/compare/v0.0.3...v0.0.4) (2022-01-25)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * test publish [#1](https://github.com/klueless-io/k_director/issues/1) ([1d001af](https://github.com/klueless-io/k_director/commit/1d001afb6087a50003ff3c18d53b10d35df31a1c))