admin_script 0.3.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 869e5f1cf2ecbdada5116840bdabb72b6ce8aadc
4
- data.tar.gz: 3ad84752ea0ec91af8dd95683081d4ab15434fae
3
+ metadata.gz: 2ddad48eff1ca28f63912fac89362cbf1096598f
4
+ data.tar.gz: 7b8ce9f14d85131b43245bc50442f85c4ce5228e
5
5
  SHA512:
6
- metadata.gz: 5fd0be08d51e57412302273c025afa201b23611e8dae995f6de804f17be0c0e388e8428b5146179ee091969e0b4bb2031a9f1e2e274ac12d900755025f63d54f
7
- data.tar.gz: ff52b57576aedb19e3d08f8997abbd764497cbf0b98f48715d3208da1f0bdfc6b79f65145915009d348f82f27d93cc99b31ef9f86675c7c50f2ebb06a9f3e416
6
+ metadata.gz: 5baaa338600945f0cf78ba40c0acd071efb724d169069dd25f97415baa84eb2578200c141bcc611fa0f48657b1cc8e9ef66324bdc3629d05a98867e7af9bcf2c
7
+ data.tar.gz: cec8993977e4dc039a1028dc8ee774aa091c90fa35de10cb9e19d45d29893629a7cf170f4b764d253b0d942b4450fcaa94900aa6d23f94eab308c5940ab3c0d4
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.3
4
+ gemfile:
5
+ - Gemfile
6
+ notifications:
7
+ email: false
8
+ script: bundle exec rspec
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # AdminScript
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/admin_script.png)](http://badge.fury.io/rb/admin\_extractor)
4
+ [![Build Status](https://travis-ci.org/alpaca-tc/admin_script.png)](https://travis-ci.org/alpaca-tc/admin\_script)
5
+
3
6
  A module for creating flexible, simple scripts for project in Rails.
4
7
 
5
8
  <img width="1147" alt="edit_page_example" src="https://cloud.githubusercontent.com/assets/1688137/21744577/cd1d3bac-d55b-11e6-8a9d-bda96edd4d36.png">
@@ -11,7 +14,7 @@ A new template is also a complete waste of time.
11
14
 
12
15
  Therefore, AdminScript provides management page of scripts.
13
16
  Only once to define model to perform a script, it generates template automatically.
14
- No configuration of routing, controller, template and as so on needed.
17
+ No configuration of routing, controller and template.
15
18
 
16
19
  ## Getting Started
17
20
 
@@ -39,7 +42,7 @@ mount AdminScript::Engine => '/admin_scripts'
39
42
  When you have AdminScript installed
40
43
 
41
44
  ```
42
- bundle exec rails generate admin_script:model awesome_script
45
+ bundle exec rails generate admin_script:model awesome_script id:integer body:text
43
46
  ```
44
47
 
45
48
  ...to create the `AdminScript::AwesomeScript`.
@@ -1,4 +1,7 @@
1
1
  class ::AdminScript::AdminScriptsController < AdminScript.configuration.parent_controller.constantize
2
+ # FIXME: How to check parent layout?
3
+ layout 'admin_script/application' unless _layout
4
+
2
5
  before_action :set_admin_script_class, only: [:edit, :update]
3
6
 
4
7
  def index
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  AdminScript::Engine.routes.draw do
2
+ controller = AdminScript.configuration.controller.constantize
3
+
2
4
  resources :admin_scripts, only: [:index, :edit, :update],
3
5
  path: '',
4
- controller: AdminScript.configuration.controller_path
6
+ controller: "/#{controller.controller_path}" # REVIEW: Is absolute controller path available?
5
7
  end
@@ -5,7 +5,6 @@ require 'action_mailer/railtie'
5
5
  require 'sprockets/railtie'
6
6
 
7
7
  Bundler.require(*Rails.groups)
8
- require 'admin_script'
9
8
 
10
9
  module Dummy
11
10
  class Application < Rails::Application
@@ -1,5 +1,3 @@
1
- require 'sass'
2
-
3
1
  module AdminScript
4
2
  class Bootstrap
5
3
  def load!
@@ -23,7 +23,7 @@ module AdminScript
23
23
  end
24
24
 
25
25
  define_configuration(:parent_controller, default: 'ActionController::Base')
26
+ define_configuration(:controller, default: 'AdminScript::AdminScriptsController')
26
27
  define_configuration(:default_url_options, default: {})
27
- define_configuration(:controller_path, default: 'admin_scripts')
28
28
  end
29
29
  end
@@ -25,10 +25,13 @@ module AdminScript
25
25
  reloader.execute_if_updated
26
26
  end
27
27
 
28
+ # Execute reloader at the first
29
+ reloader.execute
30
+
28
31
  app.reloaders << reloader
29
32
  end
30
33
 
31
- config.assets.paths += %w(stylesheets javascripts fonts).map do |path|
34
+ config.assets.paths += %w(stylesheets javascripts).map do |path|
32
35
  File.expand_path("../../../vendor/#{path}", __FILE__)
33
36
  end
34
37
 
@@ -1,3 +1,3 @@
1
1
  module AdminScript
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
@@ -9,12 +9,13 @@ module AdminScript
9
9
  def install
10
10
  template 'controller.rb', "app/controllers/#{file_path}_controller.rb"
11
11
  template 'layout.html.slim', 'app/views/layouts/admin_script/application.html.slim'
12
+ template '../../install/templates/initializer.rb', 'config/initializers/admin_script.rb'
12
13
 
13
14
  inject_into_file 'config/initializers/admin_script.rb', after: "AdminScript.configure do |config|" do <<-RUBY
14
15
 
15
- config.controller_path = '/#{file_path}'
16
+ config.controller = '#{class_name}'
16
17
  RUBY
17
- end
18
+ end
18
19
  end
19
20
  end
20
21
  end
@@ -2,10 +2,10 @@ AdminScript.configure do |config|
2
2
  # Configure the parent class responsible to render views.
3
3
  # config.parent_controller = 'ActionController::Base'
4
4
 
5
- # Custom controller. Default controller is AdminScript::AdminScriptsController
6
- # config.controller_path = 'admin_scripts'
5
+ # Custom controller.
6
+ # config.controller = 'AdminScript::AdminScriptsController'
7
7
  #
8
8
  # Example:
9
9
  # class Admin::ScriptsController < AdminScript::AdminScriptsController; end
10
- # config.controller_path = '/admin/scripts'
10
+ # config.controller = 'Admin::ScriptsController'
11
11
  end
@@ -4,10 +4,10 @@ module AdminScript
4
4
  module Generators
5
5
  class ModelGenerator < Rails::Generators::NamedBase
6
6
  source_root File.expand_path('../templates', __FILE__)
7
+ argument :attributes, type: :array, default: [], banner: 'field[:type] field[:type]'
7
8
  desc 'AdminScript model generator'
8
9
 
9
10
  def install
10
- # FIXME: Improve default template
11
11
  template 'model.rb', "app/models/admin_script/#{file_path.tr('/', '_')}.rb"
12
12
  end
13
13
  end
@@ -1,10 +1,12 @@
1
- class AdminScript
1
+ module AdminScript
2
2
  class <%= class_name %> < AdminScript::Base
3
3
  self.description = '<%= class_name %>'
4
-
5
- type_attribute :id, :integer
6
-
7
- validates :id, presence: true
4
+ <% attributes.each do |attribute| %>
5
+ type_attribute :<%= attribute.name %>, :<%= attribute.type || 'string' -%>
6
+ <% end %>
7
+ <% if attributes.present? -%>
8
+ validates <%= attributes.map { |attr| ":#{attr.name}" }.join(', ') %>, presence: true
9
+ <% end -%>
8
10
 
9
11
  def perform
10
12
  return false unless valid?
@@ -7,7 +7,6 @@ module AdminScript
7
7
  desc 'AdminScript view generator'
8
8
 
9
9
  def install
10
- # FIXME: Improve default template
11
10
  template 'view.html.slim', "app/views/admin_script/admin_scripts/_#{file_path.tr('/', '_')}.rb"
12
11
  end
13
12
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin_script
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alpaca-tc
@@ -219,6 +219,7 @@ extra_rdoc_files: []
219
219
  files:
220
220
  - ".gitignore"
221
221
  - ".rspec"
222
+ - ".travis.yml"
222
223
  - Gemfile
223
224
  - README.md
224
225
  - Rakefile
@@ -229,7 +230,6 @@ files:
229
230
  - app/assets/stylesheets/admin_script/application.scss
230
231
  - app/controllers/.keep
231
232
  - app/controllers/admin_script/admin_scripts_controller.rb
232
- - app/controllers/admin_script/application_controller.rb
233
233
  - app/helpers/.keep
234
234
  - app/mailers/.keep
235
235
  - app/models/.keep
@@ -1,4 +0,0 @@
1
- module AdminScript
2
- class ApplicationController < AdminScript.configuration.parent_controller.constantize
3
- end
4
- end