boring_generators 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/FUNDING.yml +12 -0
  3. data/.github/workflows/ci.yml +17 -0
  4. data/CHANGELOG.md +35 -1
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +148 -0
  7. data/README.md +45 -3
  8. data/boring_generators.gemspec +2 -0
  9. data/exe/boring +5 -0
  10. data/lib/boring_generators.rb +1 -0
  11. data/lib/boring_generators/cli.rb +26 -0
  12. data/lib/boring_generators/version.rb +1 -1
  13. data/lib/generators/boring/active_storage/aws/install/install_generator.rb +48 -0
  14. data/lib/generators/boring/active_storage/azure/install/install_generator.rb +48 -0
  15. data/lib/generators/boring/active_storage/google/install/install_generator.rb +48 -0
  16. data/lib/generators/boring/audit/install/install_generator.rb +22 -0
  17. data/lib/generators/boring/bootstrap/install/install_generator.rb +2 -2
  18. data/lib/generators/boring/bullet/install/install_generator.rb +31 -0
  19. data/lib/generators/boring/bullet/install/templates/bullet.rb +8 -0
  20. data/lib/generators/boring/ci/circleci/install/install_generator.rb +31 -0
  21. data/lib/generators/boring/ci/circleci/install/templates/config.psql.yml.tt +48 -0
  22. data/lib/generators/boring/ci/circleci/install/templates/config.sql.yml.tt +48 -0
  23. data/lib/generators/boring/ci/circleci/install/templates/database.yml.ci.tt +14 -0
  24. data/lib/generators/boring/ci/github_action/install/install_generator.rb +45 -0
  25. data/lib/generators/boring/ci/github_action/install/templates/ci.yml.tt +49 -0
  26. data/lib/generators/boring/ci/travisci/install/install_generator.rb +23 -0
  27. data/lib/generators/boring/ci/travisci/install/templates/.travis.yml.tt +35 -0
  28. data/lib/generators/boring/devise/install/install_generator.rb +75 -0
  29. data/lib/generators/boring/favicon/build/build_generator.rb +120 -0
  30. data/lib/generators/boring/favicon/build/templates/favicon.html.erb.tt +19 -0
  31. data/lib/generators/boring/graphql/install/install_generator.rb +51 -0
  32. data/lib/generators/boring/graphql/install/templates/base_resolver.rb +2 -0
  33. data/lib/generators/boring/graphql/install/templates/hello_world_resolver.rb +11 -0
  34. data/lib/generators/boring/oauth/base_generator.rb +63 -0
  35. data/lib/generators/boring/oauth/facebook/install/install_generator.rb +42 -0
  36. data/lib/generators/boring/oauth/facebook/install/templates/README +20 -0
  37. data/lib/generators/boring/oauth/facebook/install/templates/omniauth.rb +3 -0
  38. data/lib/generators/boring/oauth/facebook/install/templates/omniauth_callbacks_controller.rb +21 -0
  39. data/lib/generators/boring/oauth/github/install/install_generator.rb +42 -0
  40. data/lib/generators/boring/oauth/github/install/templates/README +20 -0
  41. data/lib/generators/boring/oauth/github/install/templates/omniauth_callbacks_controller.rb +21 -0
  42. data/lib/generators/boring/pry/install/install_generator.rb +29 -0
  43. data/lib/generators/boring/pry/install/templates/pryrc +24 -0
  44. data/lib/generators/boring/pundit/install/install_generator.rb +85 -0
  45. data/lib/generators/boring/rubocop/install/install_generator.rb +37 -0
  46. data/lib/generators/boring/rubocop/install/templates/.rubocop.yml.tt +262 -0
  47. data/lib/generators/boring/simple_form/install/install_generator.rb +44 -0
  48. data/lib/generators/boring/tailwind/install/install_generator.rb +13 -12
  49. data/lib/generators/boring/tailwind/install/templates/README +13 -0
  50. metadata +2524 -5
  51. data/.travis.yml +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e277610c48ddb35578742b883529c07b4d4b6dfd1c0291b38b0049ae6eab340
4
- data.tar.gz: cfc446b54c8591a9eed4b583652a34a0b02a8c9535fd3ebdea54f1599685cb1b
3
+ metadata.gz: 1c38ce00aea24f2d84874abeaf67e8fc1e917934b8dc24e7a722c695cd55b75f
4
+ data.tar.gz: 3373b320ace30d8a04e14af9780b65b819f266712cfd37e676f89872ce157cb5
5
5
  SHA512:
6
- metadata.gz: 7117cb3bef90a4c33edd5c980effa8272fc8669e2225ea85c81371262714ab68ed8122d56f83490331fca00ff619e2b35f788e2dbff83534f8c7fb567e76e17d
7
- data.tar.gz: c055b5921c43dcb681364c2a5bbe99becf0c8559c057bd50ee96ea7731c260857a02ff6d75e0f1807418942100a5da6875a40f3bd74482b196cb4e37a9de1afe
6
+ metadata.gz: f9e074f948419ff51132578335b1b9003ba99f73779b535b0a306753a3057dd924833d31eeb12091af4ebbb0db59b0ea5faa207da0ae9e413a6c3c7d61f24f32
7
+ data.tar.gz: 5c06d9e92fa9b7f5599cdf77d5c391c59adffea7ccdad470e723daa1190bc94ded77b57e4417564b5ebcc53507c3b421b1093b827ea81aaa4ea2786813531df6
@@ -0,0 +1,12 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
+ patreon: # Replace with a single Patreon username
5
+ open_collective: boring_generators
6
+ ko_fi: # Replace with a single Ko-fi username
7
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
+ liberapay: # Replace with a single Liberapay username
10
+ issuehunt: # Replace with a single IssueHunt username
11
+ otechie: # Replace with a single Otechie username
12
+ custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
@@ -0,0 +1,17 @@
1
+ name: CI
2
+ on: [push]
3
+ jobs:
4
+ test:
5
+ name: Tests
6
+ runs-on: ubuntu-latest
7
+ steps:
8
+ - name: Checkout code
9
+ uses: actions/checkout@v2
10
+ - name: Set up Ruby
11
+ uses: ruby/setup-ruby@v1
12
+ with:
13
+ ruby-version: 2.7.0
14
+ - name: Install gems
15
+ run: bundle install --jobs 4 --retry 3
16
+ - name: Run tests
17
+ run: bundle exec rake test
@@ -2,7 +2,38 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
- ## 0.1.0 (September 16th, 2020)
5
+ ## 0.7.0 (January 30th, 2021)
6
+ * Upgrade the Tailwind CSS generator to support Tailwind V2.0. ([@abhaynikam][])
7
+ * Adds Devise GitHub Omniauth generator. ([@abhaynikam][])
8
+
9
+ ## 0.6.0 (January 10th, 2021)
10
+ * Updates default ruby version of GitHub Actions install generator. ([@jamesglover][])
11
+ * Simplify generated GitHub Actions install ([@jamesglover][])
12
+ * Adds boring generator CLI ([@luathn][])
13
+ * Adds Devise Facebook Omniauth generator. ([@abhaynikam][])
14
+
15
+ ## 0.5.0 (December 20th, 2020)
16
+ * Adds favicon build generator. ([@abhaynikam][])
17
+ * Adds Pundit install generator. ([@CiTroNaK][])
18
+ * Adds GraphQL generator. ([@abhaynikam][])
19
+ * Adds SimpleForm generator. ([@abhaynikam][])
20
+ * Adds Devise generator. ([@abhaynikam][])
21
+
22
+ ## 0.4.0 (October 23rd, 2020)
23
+ * Adds CircleCI install generator. ([@abhaynikam][])
24
+ * Adds GitHub Actions install generator. ([@abhaynikam][])
25
+ * Adds Travis CI install generator. ([@abhaynikam][])
26
+ * Adds Rubocop install generator. ([@abhaynikam][])
27
+
28
+ ## 0.3.0 (September 19th, 2020)
29
+ * Adds Bullet install generator. ([@abhaynikam][])
30
+ * Adds Audit gems(bundler-audit, ruby_audit) install generator. ([@abhaynikam][])
31
+ * Adds Pry install generator. ([@abhaynikam][])
32
+ * Adds Active Storage Google install generator. ([@abhaynikam][])
33
+ * Adds Active Storage AWS install generator. ([@abhaynikam][])
34
+ * Adds Active Storage Microsoft Azure install generator. ([@abhaynikam][])
35
+
36
+ ## 0.2.0 (September 16th, 2020)
6
37
  * Adds JQuery install generator. ([@abhaynikam][])
7
38
  * Adds Bootstrap install generator. ([@abhaynikam][])
8
39
  * Adds FontAwesome install generator via Yarn. ([@abhaynikam][])
@@ -14,3 +45,6 @@
14
45
  * Initial release. ([@abhaynikam][])
15
46
 
16
47
  [@abhaynikam]: https://github.com/abhaynikam
48
+ [@CiTroNaK]: https://github.com/CiTroNaK
49
+ [@jamesglover]: https://github.com/JamesGlover
50
+ [@luathn]: https://github.com/luathn
data/Gemfile CHANGED
@@ -3,5 +3,11 @@ source "https://rubygems.org"
3
3
  # Specify your gem's dependencies in boring_generators.gemspec
4
4
  gemspec
5
5
 
6
+ gem "rails", "~> 6.0.3.4"
6
7
  gem "rake", "~> 12.0"
7
8
  gem "minitest", "~> 5.0"
9
+ gem "byebug"
10
+
11
+ platforms :ruby do
12
+ gem "sqlite3", "~> 1.4"
13
+ end
@@ -0,0 +1,148 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ boring_generators (0.7.0)
5
+ railties
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.0.3.4)
11
+ actionpack (= 6.0.3.4)
12
+ nio4r (~> 2.0)
13
+ websocket-driver (>= 0.6.1)
14
+ actionmailbox (6.0.3.4)
15
+ actionpack (= 6.0.3.4)
16
+ activejob (= 6.0.3.4)
17
+ activerecord (= 6.0.3.4)
18
+ activestorage (= 6.0.3.4)
19
+ activesupport (= 6.0.3.4)
20
+ mail (>= 2.7.1)
21
+ actionmailer (6.0.3.4)
22
+ actionpack (= 6.0.3.4)
23
+ actionview (= 6.0.3.4)
24
+ activejob (= 6.0.3.4)
25
+ mail (~> 2.5, >= 2.5.4)
26
+ rails-dom-testing (~> 2.0)
27
+ actionpack (6.0.3.4)
28
+ actionview (= 6.0.3.4)
29
+ activesupport (= 6.0.3.4)
30
+ rack (~> 2.0, >= 2.0.8)
31
+ rack-test (>= 0.6.3)
32
+ rails-dom-testing (~> 2.0)
33
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
34
+ actiontext (6.0.3.4)
35
+ actionpack (= 6.0.3.4)
36
+ activerecord (= 6.0.3.4)
37
+ activestorage (= 6.0.3.4)
38
+ activesupport (= 6.0.3.4)
39
+ nokogiri (>= 1.8.5)
40
+ actionview (6.0.3.4)
41
+ activesupport (= 6.0.3.4)
42
+ builder (~> 3.1)
43
+ erubi (~> 1.4)
44
+ rails-dom-testing (~> 2.0)
45
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
46
+ activejob (6.0.3.4)
47
+ activesupport (= 6.0.3.4)
48
+ globalid (>= 0.3.6)
49
+ activemodel (6.0.3.4)
50
+ activesupport (= 6.0.3.4)
51
+ activerecord (6.0.3.4)
52
+ activemodel (= 6.0.3.4)
53
+ activesupport (= 6.0.3.4)
54
+ activestorage (6.0.3.4)
55
+ actionpack (= 6.0.3.4)
56
+ activejob (= 6.0.3.4)
57
+ activerecord (= 6.0.3.4)
58
+ marcel (~> 0.3.1)
59
+ activesupport (6.0.3.4)
60
+ concurrent-ruby (~> 1.0, >= 1.0.2)
61
+ i18n (>= 0.7, < 2)
62
+ minitest (~> 5.1)
63
+ tzinfo (~> 1.1)
64
+ zeitwerk (~> 2.2, >= 2.2.2)
65
+ builder (3.2.4)
66
+ byebug (11.1.3)
67
+ concurrent-ruby (1.1.7)
68
+ crass (1.0.6)
69
+ erubi (1.10.0)
70
+ globalid (0.4.2)
71
+ activesupport (>= 4.2.0)
72
+ i18n (1.8.5)
73
+ concurrent-ruby (~> 1.0)
74
+ loofah (2.8.0)
75
+ crass (~> 1.0.2)
76
+ nokogiri (>= 1.5.9)
77
+ mail (2.7.1)
78
+ mini_mime (>= 0.1.1)
79
+ marcel (0.3.3)
80
+ mimemagic (~> 0.3.2)
81
+ method_source (1.0.0)
82
+ mimemagic (0.3.5)
83
+ mini_mime (1.0.2)
84
+ mini_portile2 (2.4.0)
85
+ minitest (5.14.2)
86
+ nio4r (2.5.4)
87
+ nokogiri (1.10.10)
88
+ mini_portile2 (~> 2.4.0)
89
+ rack (2.2.3)
90
+ rack-test (1.1.0)
91
+ rack (>= 1.0, < 3)
92
+ rails (6.0.3.4)
93
+ actioncable (= 6.0.3.4)
94
+ actionmailbox (= 6.0.3.4)
95
+ actionmailer (= 6.0.3.4)
96
+ actionpack (= 6.0.3.4)
97
+ actiontext (= 6.0.3.4)
98
+ actionview (= 6.0.3.4)
99
+ activejob (= 6.0.3.4)
100
+ activemodel (= 6.0.3.4)
101
+ activerecord (= 6.0.3.4)
102
+ activestorage (= 6.0.3.4)
103
+ activesupport (= 6.0.3.4)
104
+ bundler (>= 1.3.0)
105
+ railties (= 6.0.3.4)
106
+ sprockets-rails (>= 2.0.0)
107
+ rails-dom-testing (2.0.3)
108
+ activesupport (>= 4.2.0)
109
+ nokogiri (>= 1.6)
110
+ rails-html-sanitizer (1.3.0)
111
+ loofah (~> 2.3)
112
+ railties (6.0.3.4)
113
+ actionpack (= 6.0.3.4)
114
+ activesupport (= 6.0.3.4)
115
+ method_source
116
+ rake (>= 0.8.7)
117
+ thor (>= 0.20.3, < 2.0)
118
+ rake (12.3.3)
119
+ sprockets (4.0.2)
120
+ concurrent-ruby (~> 1.0)
121
+ rack (> 1, < 3)
122
+ sprockets-rails (3.2.2)
123
+ actionpack (>= 4.0)
124
+ activesupport (>= 4.0)
125
+ sprockets (>= 3.0.0)
126
+ sqlite3 (1.4.2)
127
+ thor (1.0.1)
128
+ thread_safe (0.3.6)
129
+ tzinfo (1.2.9)
130
+ thread_safe (~> 0.1)
131
+ websocket-driver (0.7.3)
132
+ websocket-extensions (>= 0.1.0)
133
+ websocket-extensions (0.1.5)
134
+ zeitwerk (2.4.2)
135
+
136
+ PLATFORMS
137
+ ruby
138
+
139
+ DEPENDENCIES
140
+ boring_generators!
141
+ byebug
142
+ minitest (~> 5.0)
143
+ rails (~> 6.0.3.4)
144
+ rake (~> 12.0)
145
+ sqlite3 (~> 1.4)
146
+
147
+ BUNDLED WITH
148
+ 2.1.4
data/README.md CHANGED
@@ -1,8 +1,20 @@
1
- # BoringGenerators
1
+ <h3 align="center">
2
+ Boring Generators
3
+ </h3>
2
4
 
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/boring_generators`. To experiment with that code, run `bin/console` for an interactive prompt.
5
+ <p align="center">
6
+ <a href="https://rubygems.org/gems/boring_generators"><img alt="Gem" src="https://img.shields.io/gem/dt/boring_generators?style=flat-square"></a>
7
+ <img alt="GitHub Workflow Status" src="https://img.shields.io/github/workflow/status/abhaynikam/boring_generators/CI?style=flat-square">
8
+ </p>
9
+
10
+ <p>
11
+ Have you ever started a new adventure/hobby project of your and instead of spending time in solving the actual problem statement with the website ended up configuring the application and put a lot of effort into it. Yeah, We felt that too. Boring generator tries to resolve the painful same redundant configuration you do in every application by adding generators to easily configure it.
12
+ </p>
13
+
14
+ <p>
15
+ Check out the generator we support right now. We are planning to add support to most of the mostly used and required gems. We are open to any idea of yours, feel free to raise a discussion by opening up an issue or try contributing.
16
+ </p>
4
17
 
5
- TODO: Delete this and the text above, and describe your gem
6
18
 
7
19
  ## Installation
8
20
 
@@ -20,6 +32,11 @@ Or install it yourself as:
20
32
 
21
33
  $ gem install boring_generators
22
34
 
35
+ And then you can use it this way:
36
+
37
+ $ boring generate boring:simple_form:install --css_framework=<css_framework>
38
+ $ boring g boring:pry:install
39
+
23
40
  ## Usage
24
41
 
25
42
  The boring generator introduces following generators:
@@ -28,17 +45,42 @@ The boring generator introduces following generators:
28
45
  - Install JQuery: `rails generate boring:jquery:install`
29
46
  - Install FontAwesome via Yarn: `rails generate boring:font_awesome:yarn:install`
30
47
  - Install FontAwesome via RubyGems: `rails generate boring:font_awesome:ruby_gem:install`
48
+ - Install Bullet: `rails generate boring:bullet:install`
49
+ - Install Audit gems(bundler-audit, ruby_audit): `rails generate boring:audit:install`
50
+ - Install Pry gems for easy debugging: `rails generate boring:pry:install`
51
+ - Install Active Storage for Google Cloud Service: `rails generate boring:active_storage:google:install`
52
+ - Install Active Storage for AWS: `rails generate boring:active_storage:aws:install`
53
+ - Install Active Storage for Azure: `rails generate boring:active_storage:azure:install`
54
+ - Install CircleCI: `rails generate boring:ci:circleci:install --repository_name=<name> --ruby_version=<version>`
55
+ - Install GitHub Actions: `rails generate boring:ci:github_action:install --repository_name=<name> --ruby_version=<version>`
56
+ - Install Travis CI: `rails generate boring:ci:travisci:install --ruby_version=<version>`
57
+ - Install Rubocop: `rails generate boring:rubocop:install --ruby_version=<version>`
58
+ - Build Favicon: `rails generate boring:favicon:build --application_name=<application_name> --favico_letter=<favico_letter> --primary_color=<color>`
59
+ - Install Pundit: `rails generate boring:pundit:install`
60
+ - Install GraphQL: `rails generate boring:graphql:install`
61
+ - Install SimpleForm: `rails generate boring:simple_form:install --css_framework=<css_framework>`
62
+ - Install Devise: `rails generate boring:devise:install`
63
+ - Install Devise Facebook Omniauth: `rails generate boring:oauth:facebook:install`
64
+ - Install Devise GitHub Omniauth: `rails generate boring:oauth:github:install`
31
65
 
32
66
  ## Development
33
67
 
34
68
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
35
69
 
70
+ You can also run specific test cases using following commands:
71
+ ```
72
+ bundle exec ruby -w -Itest test/generators/tailwind_install_generator_test.rb
73
+ ```
74
+
36
75
  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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
37
76
 
38
77
  ## Contributing
39
78
 
40
79
  Bug reports and pull requests are welcome on GitHub at https://github.com/abhaynikam/boring_generators. 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/abhaynikam/boring_generators/blob/master/CODE_OF_CONDUCT.md).
41
80
 
81
+ ## Changelog
82
+
83
+ Boring Generators changelog is available [here](https://github.com/abhaynikam/boring_generators/blob/master/CHANGELOG.md).
42
84
 
43
85
  ## License
44
86
 
@@ -26,4 +26,6 @@ Gem::Specification.new do |spec|
26
26
  spec.bindir = "exe"
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ["lib"]
29
+
30
+ spec.add_dependency "railties"
29
31
  end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/boring_generators/cli"
4
+
5
+ BoringGenerators::CLI.start(ARGV)
@@ -1,4 +1,5 @@
1
1
  require "boring_generators/version"
2
+ require 'bundler'
2
3
 
3
4
  module BoringGenerators
4
5
  class Error < StandardError; end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+ require "rails/generators"
3
+ require_relative "../boring_generators"
4
+
5
+ module BoringGenerators
6
+ class CLI < Thor
7
+ map "g" => :generate
8
+ map %w(--version -v) => :__print_version
9
+
10
+ desc "generate GENERATOR [options]", "Add gem to the application"
11
+ def generate(generator, *options)
12
+ Rails::Generators.invoke(generator, options)
13
+ end
14
+
15
+ desc "--version, -v", "Print gem version"
16
+ def __print_version
17
+ puts "Boring generators #{BoringGenerators::VERSION}"
18
+ end
19
+
20
+ class << self
21
+ def exit_on_failure?
22
+ true
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module BoringGenerators
2
- VERSION = "0.2.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -0,0 +1,48 @@
1
+ module Boring
2
+ module ActiveStorage
3
+ module Aws
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc "Adds ActiveStorage AWS service the application"
6
+
7
+ class_option :skip_active_storage, type: :boolean, aliases: "-s",
8
+ desc: "Skips running ActiveStorage installer"
9
+
10
+ def add_active_storage
11
+ unless options[:skip_active_storage]
12
+ say "Adding ActiveStorage", :green
13
+ run "bin/rails active_storage:install"
14
+ end
15
+ end
16
+
17
+ def add_aws_to_the_application
18
+ say "Adding AWS gem", :green
19
+ aws_gem_content = <<~RUBY
20
+ \n
21
+ # for AWS Service
22
+ gem "aws-sdk-s3", require: false
23
+ RUBY
24
+ append_to_file "Gemfile", aws_gem_content
25
+ run "bundle install"
26
+ end
27
+
28
+ def add_configuration_to_production
29
+ gsub_file "config/environments/production.rb",
30
+ "config.active_storage.service = :local",
31
+ "config.active_storage.service = :amazon"
32
+ end
33
+
34
+ def add_aws_storage_configuration
35
+ aws_storage_config_content = <<~RUBY
36
+ amazon:
37
+ service: S3
38
+ access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %>
39
+ secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %>
40
+ region: us-east-1
41
+ bucket: your_own_bucket
42
+ RUBY
43
+ append_to_file "config/storage.yml", aws_storage_config_content
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,48 @@
1
+ module Boring
2
+ module ActiveStorage
3
+ module Azure
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc "Adds ActiveStorage Mircosoft Azure the application"
6
+
7
+ class_option :skip_active_storage, type: :boolean, aliases: "-s",
8
+ desc: "Skips running ActiveStorage installer"
9
+
10
+ def add_active_storage
11
+ unless options[:skip_active_storage]
12
+ say "Adding ActiveStorage", :green
13
+ run "bin/rails active_storage:install"
14
+ end
15
+ end
16
+
17
+ def add_azure_to_the_application
18
+ say "Adding mircosoft azure gem", :green
19
+ azure_gem_content = <<~RUBY
20
+ \n
21
+ # for Azure Service
22
+ gem "azure-storage-blob", require: false
23
+ RUBY
24
+ append_to_file "Gemfile", azure_gem_content
25
+ run "bundle install"
26
+ end
27
+
28
+ def add_configuration_to_production
29
+ gsub_file "config/environments/production.rb",
30
+ "config.active_storage.service = :local",
31
+ "config.active_storage.service = :microsoft"
32
+ end
33
+
34
+ def add_azure_storage_configuration
35
+ microsoft_storage_config_content = <<~RUBY
36
+ microsoft:
37
+ service: AzureStorage
38
+ storage_account_name: your_account_name
39
+ storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %>
40
+ container: your_container_name
41
+ RUBY
42
+
43
+ append_to_file "config/storage.yml", microsoft_storage_config_content
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end