active_admin_api_only_initializer 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 683e467603ecd7369537cd47d84fd2b8567a9b2fadc17ca0bc220cc2b3616564
4
+ data.tar.gz: ccf52f91b57efcfa6ed4fd90f43e379f8a947716fd1ade324d0ac0f992ba385a
5
+ SHA512:
6
+ metadata.gz: 6b1f65fe8350dc390bf95424d97885d11f0dc1debc918976516877ffeabea5ac317e3466a91c79b59e38ae6fef6801071e82a2ec92bce7f8fb2870ec72274ece
7
+ data.tar.gz: c965525ec8212a305b082135eb1f317af25ac6ed5acf4e5eded8ca0d10edfdb34e3f62edae7e1db1e2fd5c32663c4dcf7807bf884f54c2f562ebc10e626fe9a8
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 uda5150
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Active Admin Api Only Initializer
2
+ Active Admin Initializer for Rails API-only.
3
+ It adds middleware and change controller inheritance relationship for [Active Admin](https://github.com/activeadmin/activeadmin).
4
+
5
+ ## Installation
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'active_admin_api_only_initializer'
10
+ ```
11
+
12
+ And then execute:
13
+ ```bash
14
+ $ bundle
15
+ ```
16
+
17
+ Or install it yourself as:
18
+ ```bash
19
+ $ gem install active_admin_api_only_initializer
20
+ ```
21
+
22
+ ## Usage
23
+ After installed Active Admin Api Only Initializer:
24
+
25
+ ```bash
26
+ $ rails g active_admin_api_only_initializer:init
27
+ ```
28
+
29
+ Now, you can install [Active Admin](https://github.com/activeadmin/activeadmin).
30
+ Follow its Getting started.
31
+
32
+ ## Warning
33
+ This gem is suitable for new Rails API-only project.
34
+ DO NOT use at a progressed Rails API-only project.
35
+ It rename the contents of `app/controllers/application_controller.rb`.
36
+
37
+ If you want to use Active Admin at Rails API-Only project, add middleware below and change `app/controllers/application_controller.rb` inheritance manually.
38
+ - Rack::MethodOverride
39
+ - ActionDispatch::Flash
40
+ - ActionDispatch::Cookies
41
+ - ActionDispatch::Session::CookieStore
42
+
43
+ ## Contributing
44
+ Bug reports and pull requests are welcome on GitHub at https://github.com/udayan28/active_admin_api_only_initializer. 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.
45
+
46
+ ## License
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'ActiveAdminApiOnlyInitializer'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
@@ -0,0 +1,5 @@
1
+ require "active_admin_api_only_initializer/railtie"
2
+
3
+ module ActiveAdminApiOnlyInitializer
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,4 @@
1
+ module ActiveAdminApiOnlyInitializer
2
+ class Railtie < ::Rails::Railtie
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ module ActiveAdminApiOnlyInitializer
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,28 @@
1
+ module ActiveAdminApiOnlyInitializer
2
+ class InitGenerator < Rails::Generators::Base
3
+ desc "Rewrite files for preparing Active Admin installation"
4
+
5
+ `mkdir -p app/assets/config && echo '{}' > app/assets/config/manifest.js`
6
+ path = File.expand_path('config/application.rb')
7
+ replacement = <<-EOS
8
+ config.api_only = true
9
+ # For Active Admin
10
+ config.middleware.use Rack::MethodOverride
11
+ config.middleware.use ActionDispatch::Flash
12
+ config.middleware.use ActionDispatch::Cookies
13
+ config.middleware.use ActionDispatch::Session::CookieStore
14
+ EOS
15
+
16
+ buffer = File.open(path, 'r+').read
17
+ buffer.gsub!(/(config.api_only = true)/, replacement)
18
+ File.open(path, 'w').write(buffer)
19
+
20
+ api_controller_text = "class ApiController < ActionController::API\nend\n"
21
+ app_controller_text = "class ApplicationController < ActionController::Base\nend\n"
22
+
23
+ File.open('app/controllers/api_controller.rb', 'w').write(api_controller_text)
24
+ File.open('app/controllers/application_controller.rb', 'w').write(app_controller_text)
25
+
26
+ desc "Finished!\n You can install Active Admin!"
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: active_admin_api_only_initializer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - udayan28
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.0.2
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.2.1
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - "~>"
28
+ - !ruby/object:Gem::Version
29
+ version: 6.0.2
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.2.1
33
+ - !ruby/object:Gem::Dependency
34
+ name: sqlite3
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :development
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: rspec-rails
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ description: Active Admin Initializer for Rails API-Only
62
+ email:
63
+ - tks.udagawa@gmail.com
64
+ executables: []
65
+ extensions: []
66
+ extra_rdoc_files: []
67
+ files:
68
+ - MIT-LICENSE
69
+ - README.md
70
+ - Rakefile
71
+ - lib/active_admin_api_only_initializer.rb
72
+ - lib/active_admin_api_only_initializer/railtie.rb
73
+ - lib/active_admin_api_only_initializer/version.rb
74
+ - lib/generators/active_admin_api_only_initializer/init/init_generator.rb
75
+ homepage: https://github.com/udayan28
76
+ licenses:
77
+ - MIT
78
+ metadata: {}
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.7.6.2
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: Active Admin Initializer for Rails API-Only
99
+ test_files: []