billet 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/main.yml +18 -0
  3. data/.gitignore +11 -0
  4. data/.rspec +3 -0
  5. data/.rubocop.yml +10 -0
  6. data/CODE_OF_CONDUCT.md +84 -0
  7. data/Gemfile +10 -0
  8. data/Gemfile.lock +55 -0
  9. data/README.md +39 -0
  10. data/Rakefile +12 -0
  11. data/billet.gemspec +34 -0
  12. data/bin/console +15 -0
  13. data/bin/rspec +29 -0
  14. data/lib/billet/version.rb +5 -0
  15. data/lib/billet.rb +8 -0
  16. data/lib/generators/billet/namespace/USAGE +8 -0
  17. data/lib/generators/billet/namespace/namespace_generator.rb +165 -0
  18. data/lib/generators/billet/namespace/templates/Gemfile.erb +15 -0
  19. data/lib/generators/billet/namespace/templates/abilities/ability.rb.erb +14 -0
  20. data/lib/generators/billet/namespace/templates/assets/css.js.erb +4 -0
  21. data/lib/generators/billet/namespace/templates/assets/css.scss.erb +5 -0
  22. data/lib/generators/billet/namespace/templates/assets/js.js.erb +1 -0
  23. data/lib/generators/billet/namespace/templates/config/api_routes.rb.erb +13 -0
  24. data/lib/generators/billet/namespace/templates/config/locales/activerecord.yml.erb +12 -0
  25. data/lib/generators/billet/namespace/templates/config/locales/defaults.yml.erb +215 -0
  26. data/lib/generators/billet/namespace/templates/config/locales/module_name.yml.erb +5 -0
  27. data/lib/generators/billet/namespace/templates/config/locales/views.yml.erb +24 -0
  28. data/lib/generators/billet/namespace/templates/config/routes.rb.erb +3 -0
  29. data/lib/generators/billet/namespace/templates/controller_concerns/.keep +0 -0
  30. data/lib/generators/billet/namespace/templates/controller_concerns/api_current_identity.rb.erb +69 -0
  31. data/lib/generators/billet/namespace/templates/controller_concerns/current_identity.rb.erb +75 -0
  32. data/lib/generators/billet/namespace/templates/controllers/api_controllers/authorizations_controller.rb.erb +25 -0
  33. data/lib/generators/billet/namespace/templates/controllers/api_controllers/ping_controller.rb.erb +12 -0
  34. data/lib/generators/billet/namespace/templates/controllers/api_controllers/profiles_controller.rb.erb +14 -0
  35. data/lib/generators/billet/namespace/templates/controllers/api_controllers/projects_controller.rb.erb +35 -0
  36. data/lib/generators/billet/namespace/templates/controllers/api_controllers/user_identities_controller.rb.erb +14 -0
  37. data/lib/generators/billet/namespace/templates/controllers/crud_controllers/application_controller.rb.erb +93 -0
  38. data/lib/generators/billet/namespace/templates/controllers/crud_controllers/controller.rb.erb +1 -0
  39. data/lib/generators/billet/namespace/templates/controllers/crud_controllers/home_controller.rb.erb +11 -0
  40. data/lib/generators/billet/namespace/templates/drappers/application_drapper.rb.erb +25 -0
  41. data/lib/generators/billet/namespace/templates/drappers/concerns/display_name_glipper.rb.erb +32 -0
  42. data/lib/generators/billet/namespace/templates/drappers/concerns/timestamp_glipper.rb.erb +21 -0
  43. data/lib/generators/billet/namespace/templates/drappers/concerns/type_glipper.rb.erb +9 -0
  44. data/lib/generators/billet/namespace/templates/drappers/user_drapper.rb.erb +10 -0
  45. data/lib/generators/billet/namespace/templates/gemspec.erb +19 -0
  46. data/lib/generators/billet/namespace/templates/helpers/application_helper.rb.erb +27 -0
  47. data/lib/generators/billet/namespace/templates/lib/engine.rb.erb +13 -0
  48. data/lib/generators/billet/namespace/templates/lib/module.rb.erb +4 -0
  49. data/lib/generators/billet/namespace/templates/lib/version.rb.erb +3 -0
  50. data/lib/generators/billet/namespace/templates/views/api_views/application/index.json.jbuilder +6 -0
  51. data/lib/generators/billet/namespace/templates/views/api_views/application/show.json.jbuilder +1 -0
  52. data/lib/generators/billet/namespace/templates/views/api_views/authorizations/create.json.jbuilder +1 -0
  53. data/lib/generators/billet/namespace/templates/views/api_views/authorizations/failure.json.jbuilder +1 -0
  54. data/lib/generators/billet/namespace/templates/views/api_views/authorizations/index.json.jbuilder +4 -0
  55. data/lib/generators/billet/namespace/templates/views/api_views/ping/index.json.jbuilder +15 -0
  56. data/lib/generators/billet/namespace/templates/views/api_views/ping/secured.json.jbuilder +1 -0
  57. data/lib/generators/billet/namespace/templates/views/api_views/profiles/_detailed.json.jbuilder +6 -0
  58. data/lib/generators/billet/namespace/templates/views/api_views/projects/_show.json.jbuilder +6 -0
  59. data/lib/generators/billet/namespace/templates/views/api_views/user_identities/_short.json.jbuilder +6 -0
  60. data/lib/generators/billet/namespace/templates/views/crud_views/application/_analytics.html.haml +9 -0
  61. data/lib/generators/billet/namespace/templates/views/crud_views/application/_button_add.html.haml +2 -0
  62. data/lib/generators/billet/namespace/templates/views/crud_views/application/_button_destroy.html.haml +2 -0
  63. data/lib/generators/billet/namespace/templates/views/crud_views/application/_button_edit.html.haml +2 -0
  64. data/lib/generators/billet/namespace/templates/views/crud_views/application/_button_index.html.haml +2 -0
  65. data/lib/generators/billet/namespace/templates/views/crud_views/application/_button_show.html.haml +3 -0
  66. data/lib/generators/billet/namespace/templates/views/crud_views/application/_buttons_edit.html.haml +3 -0
  67. data/lib/generators/billet/namespace/templates/views/crud_views/application/_buttons_index.html.haml +2 -0
  68. data/lib/generators/billet/namespace/templates/views/crud_views/application/_buttons_new.html.haml +2 -0
  69. data/lib/generators/billet/namespace/templates/views/crud_views/application/_buttons_show.html.haml +3 -0
  70. data/lib/generators/billet/namespace/templates/views/crud_views/application/_container.html.haml +4 -0
  71. data/lib/generators/billet/namespace/templates/views/crud_views/application/_favicon.html.haml +15 -0
  72. data/lib/generators/billet/namespace/templates/views/crud_views/application/_flash.html.haml +4 -0
  73. data/lib/generators/billet/namespace/templates/views/crud_views/application/_footer.html.haml +4 -0
  74. data/lib/generators/billet/namespace/templates/views/crud_views/application/_form.html.haml +5 -0
  75. data/lib/generators/billet/namespace/templates/views/crud_views/application/_form_fields.html.haml +2 -0
  76. data/lib/generators/billet/namespace/templates/views/crud_views/application/_header.html.haml +11 -0
  77. data/lib/generators/billet/namespace/templates/views/crud_views/application/_header_edit.html.haml +2 -0
  78. data/lib/generators/billet/namespace/templates/views/crud_views/application/_header_index.html.haml +2 -0
  79. data/lib/generators/billet/namespace/templates/views/crud_views/application/_header_new.html.haml +2 -0
  80. data/lib/generators/billet/namespace/templates/views/crud_views/application/_header_show.html.haml +2 -0
  81. data/lib/generators/billet/namespace/templates/views/crud_views/application/_logo.html.haml +1 -0
  82. data/lib/generators/billet/namespace/templates/views/crud_views/application/_metas.html.haml +13 -0
  83. data/lib/generators/billet/namespace/templates/views/crud_views/application/_names.html.haml +7 -0
  84. data/lib/generators/billet/namespace/templates/views/crud_views/application/_primary_menu.html.haml +0 -0
  85. data/lib/generators/billet/namespace/templates/views/crud_views/application/_row.html.haml +2 -0
  86. data/lib/generators/billet/namespace/templates/views/crud_views/application/_row_header.html.haml +2 -0
  87. data/lib/generators/billet/namespace/templates/views/crud_views/application/_secondary_menu.html.haml +5 -0
  88. data/lib/generators/billet/namespace/templates/views/crud_views/application/_show.html.haml +14 -0
  89. data/lib/generators/billet/namespace/templates/views/crud_views/application/_states.html.haml +9 -0
  90. data/lib/generators/billet/namespace/templates/views/crud_views/application/edit.html.haml +5 -0
  91. data/lib/generators/billet/namespace/templates/views/crud_views/application/index.html.haml +16 -0
  92. data/lib/generators/billet/namespace/templates/views/crud_views/application/new.html.haml +5 -0
  93. data/lib/generators/billet/namespace/templates/views/crud_views/application/show.html.haml +5 -0
  94. data/lib/generators/billet/namespace/templates/views/crud_views/home/index.html.haml.erb +1 -0
  95. data/lib/generators/billet/namespace/templates/views/crud_views/layouts/application.html.haml.erb +23 -0
  96. metadata +139 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 99cae1b3dfe64b1b7d5595e0d75f46462205782dd6db247f073b0d9b54653363
4
+ data.tar.gz: 2f2109da92044bffa9427687ae2d388495ab3ab700ade7273ce03dcba079afe8
5
+ SHA512:
6
+ metadata.gz: a5e4c099e7c627e2c3797e677dccabe868fe94b24ada2e9624bd98f5d9126ee22fec9adc0bbd708d6461b237f970eda216979df61c7e7d7d4e53d509abe8943f
7
+ data.tar.gz: c1aaa83b8602260ee923310568c16fd22376b96a00f820c93878968684346d73f0c9b1190f1ba07b404a5cb44967bcd55aa5bfca219bd20b97e4b8602b186819
@@ -0,0 +1,18 @@
1
+ name: Ruby
2
+
3
+ on: [push,pull_request]
4
+
5
+ jobs:
6
+ build:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 3.0.0
14
+ - name: Run the default task
15
+ run: |
16
+ gem install bundler -v 2.2.4
17
+ bundle install
18
+ bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,10 @@
1
+ Style/StringLiterals:
2
+ Enabled: true
3
+ EnforcedStyle: double_quotes
4
+
5
+ Style/StringLiteralsInInterpolation:
6
+ Enabled: true
7
+ EnforcedStyle: double_quotes
8
+
9
+ Layout/LineLength:
10
+ Max: 120
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at alexey@osipenko.in.ua. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in billet.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "rubocop", "~> 0.80"
data/Gemfile.lock ADDED
@@ -0,0 +1,55 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ billet (0.0.1)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ diff-lcs (1.4.4)
11
+ parallel (1.21.0)
12
+ parser (3.0.2.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (13.0.6)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.5)
18
+ rspec (3.10.0)
19
+ rspec-core (~> 3.10.0)
20
+ rspec-expectations (~> 3.10.0)
21
+ rspec-mocks (~> 3.10.0)
22
+ rspec-core (3.10.1)
23
+ rspec-support (~> 3.10.0)
24
+ rspec-expectations (3.10.1)
25
+ diff-lcs (>= 1.2.0, < 2.0)
26
+ rspec-support (~> 3.10.0)
27
+ rspec-mocks (3.10.2)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.10.0)
30
+ rspec-support (3.10.2)
31
+ rubocop (0.93.1)
32
+ parallel (~> 1.10)
33
+ parser (>= 2.7.1.5)
34
+ rainbow (>= 2.2.2, < 4.0)
35
+ regexp_parser (>= 1.8)
36
+ rexml
37
+ rubocop-ast (>= 0.6.0)
38
+ ruby-progressbar (~> 1.7)
39
+ unicode-display_width (>= 1.4.0, < 2.0)
40
+ rubocop-ast (1.12.0)
41
+ parser (>= 3.0.1.1)
42
+ ruby-progressbar (1.11.0)
43
+ unicode-display_width (1.8.0)
44
+
45
+ PLATFORMS
46
+ x86_64-darwin-20
47
+
48
+ DEPENDENCIES
49
+ billet!
50
+ rake (~> 13.0)
51
+ rspec (~> 3.0)
52
+ rubocop (~> 0.80)
53
+
54
+ BUNDLED WITH
55
+ 2.2.4
data/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # Billet
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/billet`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'billet'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install billet
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/billet. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/billet/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## Code of Conduct
38
+
39
+ Everyone interacting in the Billet project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/billet/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
data/billet.gemspec ADDED
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/billet/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "billet"
7
+ spec.version = Billet::VERSION
8
+ spec.authors = ["Alexey Osipenko"]
9
+ spec.email = ["alexey@osipenko.in.ua"]
10
+
11
+ spec.summary = "Billet as core of application changes."
12
+ spec.description = "Billet as core of application changes. Contains generators and rake tasks."
13
+ spec.homepage = "https://github.com/cimon-io/billet"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://github.com/cimon-io/billet_core"
18
+ spec.metadata["changelog_uri"] = "https://github.com/cimon-io/billet-core/commits"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
24
+ end
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ # Uncomment to register a new dependency of your gem
30
+ # spec.add_dependency "example-gem", "~> 1.0"
31
+
32
+ # For more information and examples about making a new gem, checkout our
33
+ # guide at: https://bundler.io/guides/creating_gem.html
34
+ end
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "billet"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Billet
4
+ VERSION = "0.0.1"
5
+ end
data/lib/billet.rb ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "billet/version"
4
+
5
+ module Billet
6
+ class Error < StandardError; end
7
+ # Your code goes here...
8
+ end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ Explain the generator
3
+
4
+ Example:
5
+ bin/rails generate billet:namespace Owner --access=http
6
+
7
+ This will create:
8
+ what/will/it/create
@@ -0,0 +1,165 @@
1
+ require 'json'
2
+
3
+ module Billet
4
+ class NamespaceGenerator < Rails::Generators::NamedBase
5
+ source_root File.expand_path('templates', __dir__)
6
+
7
+ class_option :kind, type: 'string', default: 'views', desc: 'Make namespace as API/views/GRAPHQL'
8
+ class_option :route, type: 'string', default: nil, desc: 'Make namespace with public access [default module_name]'
9
+ class_option :access, type: 'string', default: 'cancan', desc: 'Make namespace with public access [fake, cancan none]'
10
+ class_option :chain, type: 'string', default: 'current_company', desc: 'Make namespace with public access. \'false\' if no chain beginning.'
11
+
12
+ def initialize(*args, &block)
13
+ super
14
+
15
+ @kind = case options.kind.downcase
16
+ when 'api' then 'api'
17
+ when 'graphql' then 'graphql'
18
+ when 'crud' then 'crud'
19
+ else 'views'
20
+ end.inquiry
21
+
22
+ @access = case options.access
23
+ when 'cancancan', 'cancan', 'can' then 'cancan'
24
+ when 'http' then 'http'
25
+ when 'none', 'false', 'all', 'public' then 'none'
26
+ else options.access
27
+ end.inquiry
28
+
29
+ @chain = %w[false none nil blank].include?(options.chain) ? nil : options.chain
30
+ @route = options.route.nil? ? singular_name : options.route
31
+ end
32
+
33
+ def append_gem_dependency
34
+ gem singular_name, require: singular_name, path: "./apps/#{singular_name}"
35
+ end
36
+
37
+ def append_routes
38
+ route "mount #{class_name}::Engine => '/#{@route}', as: '#{singular_name}'"
39
+ end
40
+
41
+ def generate_apps_folder
42
+ empty_directory "apps"
43
+ end
44
+
45
+ def generate_app
46
+ template 'gemspec.erb', app_folder("#{singular_name}.gemspec")
47
+ template 'Gemfile.erb', app_folder("Gemfile")
48
+ template 'lib/engine.rb.erb', app_folder(:lib, singular_name, "engine.rb")
49
+ template 'lib/version.rb.erb', app_folder(:lib, singular_name, "version.rb")
50
+ template 'lib/module.rb.erb', app_folder(:lib, "#{singular_name}.rb")
51
+ end
52
+
53
+ def generate_i18n
54
+ template 'config/locales/module_name.yml.erb', app_folder(:config, :locales, :en, "#{singular_name}.yml")
55
+ template 'config/locales/views.yml.erb', app_folder(:config, :locales, :en, "views.yml")
56
+ template 'config/locales/defaults.yml.erb', app_folder(:config, :locales, :en, "defaults.yml")
57
+ template 'config/locales/activerecord.yml.erb', app_folder(:config, :locales, :en, "activerecord.yml")
58
+ end
59
+
60
+ def generate_ability
61
+ if @access.cancan?
62
+ template 'abilities/ability.rb.erb', app_folder(:app, :abilities, singular_name, "ability.rb")
63
+ end
64
+ end
65
+
66
+ def generate_controllers
67
+ template 'controller_concerns/.keep', app_folder(:app, :controllers, :concerns, ".keep")
68
+
69
+ if @kind.api?
70
+ template 'controller_concerns/api_current_identity.rb.erb', app_folder(:app, :controllers, :concerns, instance_name, "current_identity.rb")
71
+ elsif @kind.crud?
72
+ end
73
+
74
+ if @access.cancan?
75
+ template 'controller_concerns/current_identity.rb.erb', app_folder(:app, :controllers, :concerns, instance_name, "current_identity.rb")
76
+ end
77
+
78
+ template 'controllers/crud_controllers/controller.rb.erb', app_folder(:app, :controllers, "#{instance_name}_controller.rb")
79
+ template 'controllers/crud_controllers/application_controller.rb.erb', app_folder(:app, :controllers, instance_name, "application_controller.rb")
80
+ template 'controllers/crud_controllers/home_controller.rb.erb', app_folder(:app, :controllers, instance_name, "home_controller.rb")
81
+ end
82
+
83
+ def generate_views
84
+ case @kind
85
+ when 'api'
86
+ directory 'views/api_views', app_folder(:app, :views, instance_name)
87
+ when 'crud'
88
+ directory 'views/crud_views/application', app_folder(:app, :views, instance_name, :application)
89
+ template 'views/crud_views/home/index.html.haml.erb', app_folder(:app, :views, instance_name, :home, "index.html.haml")
90
+ template 'views/crud_views/layouts/application.html.haml.erb', app_folder(:app, :views, :layouts, instance_name, "application.html.haml")
91
+ end
92
+ end
93
+
94
+ def generate_routes
95
+ case @kind
96
+ when 'api'
97
+ template 'config/api_routes.rb.erb', app_folder(:config, "routes.rb")
98
+ when 'views'
99
+ template 'config/routes.rb.erb', app_folder(:config, "routes.rb")
100
+ end
101
+ end
102
+
103
+ def generate_drappers
104
+ template 'drappers/user_drapper.rb.erb', app_folder(:app, :drappers, instance_name, "user_drapper.rb")
105
+ template 'drappers/application_drapper.rb.erb', app_folder(:app, :drappers, instance_name, "application_drapper.rb")
106
+
107
+ template 'drappers/concerns/display_name_glipper.rb.erb', app_folder(:app, :drappers, :concerns, instance_name, "display_name_glipper.rb")
108
+ template 'drappers/concerns/timestamp_glipper.rb.erb', app_folder(:app, :drappers, :concerns, instance_name, "timestamp_glipper.rb")
109
+ template 'drappers/concerns/type_glipper.rb.erb', app_folder(:app, :drappers, :concerns, instance_name, "type_glipper.rb")
110
+ end
111
+
112
+ def generate_helpers
113
+ template "helpers/application_helper.rb.erb", app_folder(:app, :helpers, instance_name, "application_helper.rb")
114
+ end
115
+
116
+ private
117
+
118
+ def app_folder(*agrs)
119
+ "apps/#{singular_name}/#{agrs.join('/')}"
120
+ end
121
+
122
+ def scaffold_name
123
+ name
124
+ end
125
+
126
+ # model_name
127
+ def singular_name
128
+ scaffold_name.underscore
129
+ end
130
+
131
+ # model_names
132
+ def plural_name
133
+ scaffold_name.underscore.pluralize
134
+ end
135
+
136
+ # ModelName
137
+ def class_name
138
+ scaffold_name.camelize
139
+ end
140
+
141
+ # model_name
142
+ def model_path
143
+ class_name.underscore
144
+ end
145
+
146
+ # ModelNames
147
+ def plural_class_name
148
+ plural_name.camelize
149
+ end
150
+
151
+ # model_name
152
+ def instance_name
153
+ singular_name.split('/').last
154
+ end
155
+
156
+ # model_names
157
+ def instances_name
158
+ instance_name.pluralize
159
+ end
160
+
161
+ def read_template(relative_path)
162
+ ERB.new(File.read(find_in_source_paths(relative_path)), trim_mode: '-').result(binding)
163
+ end
164
+ end
165
+ end
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in owner.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem 'byebug', group: [:development, :test]
15
+
@@ -0,0 +1,14 @@
1
+ module <%= class_name %>
2
+ class Ability
3
+ include CanCan::Ability
4
+
5
+ def initialize(user, company)
6
+ user ||= User.new # guest user (not logged in)
7
+
8
+ raise CanCan::AccessDenied.new("company is nil") if company.nil?
9
+ raise CanCan::AccessDenied.new("can't login to company #{company.id}") unless company.id == user.company_id
10
+
11
+ can :login, Company, id: user.company_id
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ // We need to import the CSS so that webpack will load it.
2
+ // The MiniCssExtractPlugin is used to separate it out into
3
+ // its own CSS file.
4
+ import css from "./<%= singular_name %>.scss"
@@ -0,0 +1,5 @@
1
+ body {
2
+ &:after {
3
+ content: 'Hello from <%= singular_name %>';
4
+ }
5
+ }
@@ -0,0 +1 @@
1
+ console.log('Hello from <%= singular_name %>')
@@ -0,0 +1,13 @@
1
+ <%= class_name %>::Engine.routes.draw do
2
+ constraints ->(req) { req.format == :json } do
3
+ get "/ping" => "ping#index"
4
+ get "/ping/secured" => "ping#secured"
5
+
6
+ resources :authorizations, path: 'auth', only: [:index, :create]
7
+
8
+ resources :projects, only: [:index, :show, :update, :create]
9
+ resource :profile, only: [:show] do
10
+ resources :user_identities, only: [:index, :destroy], path: 'identities'
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,12 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ user:
5
+ one: User
6
+ other: Users
7
+ attributes:
8
+ user:
9
+ email: Email
10
+ id: ID
11
+ created_at: Created
12
+ updated_at: Updated