crud 0.0.3

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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1 -0
  3. data/LICENSE.md +674 -0
  4. data/README.md +136 -0
  5. data/Rakefile +72 -0
  6. data/app/assets/images/crud/search-icon.png +0 -0
  7. data/app/assets/javascripts/crud/application.js +17 -0
  8. data/app/assets/javascripts/crud/dashboard.js +7 -0
  9. data/app/assets/javascripts/crud/pagination.js +41 -0
  10. data/app/assets/stylesheets/crud/application.css +27 -0
  11. data/app/assets/stylesheets/crud/dashboard.css +4 -0
  12. data/app/assets/stylesheets/crud/flash_notices.css +19 -0
  13. data/app/assets/stylesheets/crud/pagination.css +104 -0
  14. data/app/assets/stylesheets/dataTables/jquery.dataTables-override.css +20 -0
  15. data/app/controllers/crud/crud_base_controller.rb +28 -0
  16. data/app/controllers/crud/crud_controller.rb +149 -0
  17. data/app/controllers/crud/dashboard_controller.rb +17 -0
  18. data/app/helpers/crud/crud_helper.rb +104 -0
  19. data/app/helpers/crud/dashboard_helper.rb +4 -0
  20. data/app/models/crud/klass_info.rb +166 -0
  21. data/app/models/crud/klass_list.rb +51 -0
  22. data/app/models/crud/menus/development_menu.rb +63 -0
  23. data/app/views/crud/crud/_attribute_value.html.erb +5 -0
  24. data/app/views/crud/crud/_error_messages.html.erb +10 -0
  25. data/app/views/crud/crud/_flash_messages.html.erb +10 -0
  26. data/app/views/crud/crud/_form.html.erb +22 -0
  27. data/app/views/crud/crud/_klass_data.html.erb +117 -0
  28. data/app/views/crud/crud/edit.html.erb +17 -0
  29. data/app/views/crud/crud/index.html.erb +6 -0
  30. data/app/views/crud/crud/index.js.erb +1 -0
  31. data/app/views/crud/crud/new.html.erb +13 -0
  32. data/app/views/crud/crud/show.html.erb +69 -0
  33. data/app/views/crud/dashboard/index.html.erb +15 -0
  34. data/app/views/layouts/crud/application.html.erb +13 -0
  35. data/config/cucumber.yml +8 -0
  36. data/config/initializers/inflections.rb +5 -0
  37. data/config/initializers/rails_engine.rb +8 -0
  38. data/config/initializers/will_paginate.rb +1 -0
  39. data/config/locales/de.yml +3 -0
  40. data/config/locales/en.yml +3 -0
  41. data/config/locales/es.yml +3 -0
  42. data/config/locales/fr.yml +3 -0
  43. data/config/routes.rb +16 -0
  44. data/crud.gemspec +29 -0
  45. data/lib/crud.rb +144 -0
  46. data/lib/crud/engine.rb +23 -0
  47. data/lib/crud/version.rb +3 -0
  48. data/lib/tasks/crud_tasks.rake +4 -0
  49. metadata +157 -0
@@ -0,0 +1,5 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ #inflect.uncountable %w( asset_data )
3
+ #inflect.plural /^(asset_data)$/i, '\1'
4
+ #inflect.singular /^(asset_data)$/i, '\1'
5
+ end
@@ -0,0 +1,8 @@
1
+ class Rails::Engine
2
+ def self.mounted_path
3
+ route = Rails.application.routes.routes.detect do |route|
4
+ route.app == self
5
+ end
6
+ route && (route.path.spec.left.to_s + route.path.spec.right.to_s)
7
+ end
8
+ end
@@ -0,0 +1 @@
1
+ WillPaginate.per_page = 10
@@ -0,0 +1,3 @@
1
+ de:
2
+ search_prompt: "Suchbegriffe eingeben..."
3
+ advanced_search_prompt: "Erweiterte Suche"
@@ -0,0 +1,3 @@
1
+ en:
2
+ search_prompt: "Enter search terms..."
3
+ advanced_search_prompt: "Advanced search"
@@ -0,0 +1,3 @@
1
+ es:
2
+ search_prompt: "Introduzca los términos de búsqueda..."
3
+ advanced_search_prompt: "Búsqueda avanzada"
@@ -0,0 +1,3 @@
1
+ fr:
2
+ search_prompt: "Entrez les termes de recherche..."
3
+ advanced_search_prompt: "Recherche avancée"
data/config/routes.rb ADDED
@@ -0,0 +1,16 @@
1
+ Crud::Engine.routes.draw do
2
+
3
+ controller 'crud' do
4
+ match '/model/*class_name/new', :to => :new, :via => :get, :as => :new
5
+ match '/model/*class_name/:id/delete', :to => :delete, :via => :delete, :as => :delete
6
+ match '/model/*class_name/:id/edit', :to => :edit, :via => :get, :as => :edit
7
+ match '/model/*class_name/:id', :to => :show, :via => :get, :as => :show
8
+ match '/model/*class_name/:id', :to => :update, :via => :put, :as => :update
9
+ match '/model/*class_name/:id', :to => :destroy, :via => :delete, :as => :destroy
10
+ match '/model/(*class_name)', :to => :create, :via => :post, :as => :create
11
+ match '/model/(*class_name)', :to => :index, :via => :get, :as => :index
12
+ end
13
+
14
+ #get 'dashboard' => 'dashboard#index'
15
+ root :to => "dashboard#index"
16
+ end
data/crud.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # Encoding: UTF-8
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ # Maintain your gem's version:
5
+ require "crud/version"
6
+
7
+ # Describe your gem and declare its dependencies:
8
+ Gem::Specification.new do |s|
9
+ s.name = "crud"
10
+ s.version = Crud::VERSION.dup
11
+ s.authors = ["Everard Brown"]
12
+ s.email = ["Everard.Brown@htcl.eu"]
13
+ s.homepage = "https://github.com/htcl/crud"
14
+ s.summary = "Crud engine (v#{s.version})"
15
+ s.description = "Performs CRUD operations by reflection"
16
+ s.license = 'GPL-3.0'
17
+
18
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["#{s.name}.gemspec", "Rakefile", "LICENSE.md", "README.md"]
19
+ #s.test_files = Dir["{test,spec,features}/**/*"]
20
+ s.require_paths = ["lib"]
21
+
22
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "crud", "--main", "README.md"]
23
+ s.extra_rdoc_files = ["CHANGELOG", "README.md", "lib/tasks/crud_tasks.rake", "lib/crud.rb"]
24
+
25
+ s.add_dependency 'rails'
26
+ s.add_dependency 'jquery-rails'
27
+ s.add_dependency 'jquery-ui-rails'
28
+ s.add_dependency 'will_paginate'
29
+ end
data/lib/crud.rb ADDED
@@ -0,0 +1,144 @@
1
+ # To use the mattr functions, ActiveSupport dependencies are required.
2
+ #require 'rails'
3
+ require "active_support/dependencies"
4
+
5
+ module Crud
6
+
7
+ # The parent controller all engine controllers inherits from.
8
+ # Defaults to ApplicationController. This should be set early
9
+ # in the initialisation process and should be set to a string.
10
+ mattr_accessor :parent_controller
11
+ self.parent_controller = "ApplicationController"
12
+
13
+ # Our host application root path
14
+ # We set this when the engine is initialised
15
+ # mattr_accessor :app_root
16
+ # self.app_root = 'xyz'
17
+
18
+ # Allow clients to register paths containing models. The backend determines
19
+ # acceptable model sources.
20
+ #
21
+ # Clients may register additional paths like this:
22
+ # model_path << 'path/to/model/directory'
23
+ mattr_accessor :model_path
24
+ self.model_path ||= []
25
+
26
+ # Access permissions
27
+ #
28
+ # Holds the definition of a proc which should be called. If the returned
29
+ # value is true then user is granted the access. Otherwise access is denied.
30
+ mattr_writer :is_allowed_to_view
31
+ #self.is_allowed_to_view = true
32
+ def self.is_allowed_to_view
33
+ is_allowed = @@is_allowed_to_view.nil? ? lambda { return true } :
34
+ lambda {|controller| return ((@@is_allowed_to_view.class == Proc) ? @@is_allowed_to_view.call(controller) : @@is_allowed_to_view)}
35
+
36
+ is_allowed
37
+ end
38
+
39
+ # Holds the definition of a proc which should be called. If the returned
40
+ # value is true then user is granted the access. Otherwise access is denied.
41
+ mattr_writer :is_allowed_to_update
42
+ #self.is_allowed_to_update = false
43
+ def self.is_allowed_to_update
44
+ is_allowed = @@is_allowed_to_update.nil? ? lambda { |controller| return true } :
45
+ lambda {|controller| return ((@@is_allowed_to_update.class == Proc) ? @@is_allowed_to_update.call(controller) : @@is_allowed_to_update)}
46
+
47
+ is_allowed
48
+ end
49
+
50
+ # Allow clients to customise the appearance of fields when rendering model data.
51
+ #
52
+ # :class
53
+ # The fully qualified name of the model to which this definition applies
54
+ #
55
+ # NOTE: If :class is set to :all, the definition will apply to all models.
56
+ #
57
+ # :hidden_fields
58
+ # If :hidden_fields contains an existing column, the column will not be displayed
59
+ #
60
+ # :only
61
+ # Filter to define in which views this definition applies.
62
+ # Valid values: :index, :show, :new, :edit
63
+ #
64
+ # Clients may register column settings like this:
65
+ # column_settings << { :class => 'Model',
66
+ # :hidden_fields => [:id, :created_at, :updated_at],
67
+ # :only => [:index, :show ]
68
+ # }
69
+ #
70
+ # column_settings << { :class => :all,
71
+ # :hidden_fields => [:id, :created_at, :updated_at],
72
+ # :only => [:index, :show],
73
+ # }
74
+ #
75
+ mattr_accessor :column_settings
76
+ self.column_settings ||= []
77
+
78
+ # Allow clients to register additional customisation to fields when rendering
79
+ # model data.
80
+ #
81
+ # :global
82
+ # If :global is specified and set to 'true', the partial will be at the end
83
+ # as an extension of the active view.
84
+ #
85
+ # :column_name
86
+ # If :column_name is an existing column, the partial will be rendered alongside
87
+ # the default, unless :column_replacement is set to true
88
+ #
89
+ # NOTE: The functionality of :column_name and :global are mutually exclusive.
90
+ # As such, if both are specified, :global will take presedence
91
+ #
92
+ # :column_replacement
93
+ # Flag to indicate whether this customisation should replace the default or
94
+ # appear alongside the default.
95
+ #
96
+ # :record_data_parameter
97
+ # :record_data_parameter is the name of the symbol used for passing the record
98
+ # data to the partial.
99
+ #
100
+ # :additional_partial_parameters
101
+ # A hash containing any additional partial parameters
102
+ #
103
+ # :only
104
+ # Filter to define in which views the extension applies.
105
+ # Valid values: :index, :show, :new, :edit
106
+ #
107
+ # Clients may register custom fields like this:
108
+ # custom_fields << { :class => 'Model',
109
+ # :only => [:index, :show ],
110
+ # :global => false,
111
+ # :column_name => 'id',
112
+ # :column_replacement => true,
113
+ # :partial => 'partial_path', :record_data_parameter => 'data',
114
+ # :additional_partial_parameters => {:size => 20, :contract => true}
115
+ # }
116
+ #
117
+ mattr_accessor :custom_fields
118
+ self.custom_fields ||= []
119
+
120
+ # Default way to setup the engine.
121
+ #
122
+ # Run 'rails generate crud_install' to create a fresh initializer with all
123
+ # configuration values.
124
+ def self.setup
125
+ yield self
126
+ end
127
+
128
+ def self.railtie_name
129
+ ::Crud::Engine.railtie_name
130
+ end
131
+
132
+ def self.mounted_path
133
+ ::Crud::Engine.mounted_path
134
+ end
135
+
136
+ def self.root_path
137
+ ::Crud::Engine.root
138
+ end
139
+
140
+ end
141
+
142
+ # Require our engine
143
+ require 'crud/version'
144
+ require 'crud/engine'
@@ -0,0 +1,23 @@
1
+ module Crud
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Crud
4
+
5
+ # Make the asset pipeline of the following gems available to the application
6
+ require 'jquery-rails'
7
+ require 'jquery-ui-rails'
8
+ #require 'jquery-datatables-rails'
9
+ require 'will_paginate'
10
+
11
+ #config.autoload_paths << File.expand_path("../validators", __FILE__)
12
+
13
+ config.generators do |g|
14
+ g.test_framework :rspec, :fixture_replacement => :factory_girl, :views => false, :helper => true
15
+ g.view_specs false
16
+ g.helper_specs true
17
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
18
+ end
19
+
20
+ # Load translations from config/locales/*.rb,yml are auto loaded.
21
+ config.i18n.load_path += Dir[File.join(File.dirname(__FILE__), '..', '..', 'config', 'locales', '**', '*.{rb,yml}').to_s]
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Crud
2
+ VERSION = "0.0.3"
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :crud do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: crud
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Everard Brown
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-16 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jquery-rails
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jquery-ui-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: will_paginate
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Performs CRUD operations by reflection
70
+ email:
71
+ - Everard.Brown@htcl.eu
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files:
75
+ - CHANGELOG
76
+ - README.md
77
+ - lib/tasks/crud_tasks.rake
78
+ - lib/crud.rb
79
+ files:
80
+ - CHANGELOG
81
+ - LICENSE.md
82
+ - README.md
83
+ - Rakefile
84
+ - app/assets/images/crud/search-icon.png
85
+ - app/assets/javascripts/crud/application.js
86
+ - app/assets/javascripts/crud/dashboard.js
87
+ - app/assets/javascripts/crud/pagination.js
88
+ - app/assets/stylesheets/crud/application.css
89
+ - app/assets/stylesheets/crud/dashboard.css
90
+ - app/assets/stylesheets/crud/flash_notices.css
91
+ - app/assets/stylesheets/crud/pagination.css
92
+ - app/assets/stylesheets/dataTables/jquery.dataTables-override.css
93
+ - app/controllers/crud/crud_base_controller.rb
94
+ - app/controllers/crud/crud_controller.rb
95
+ - app/controllers/crud/dashboard_controller.rb
96
+ - app/helpers/crud/crud_helper.rb
97
+ - app/helpers/crud/dashboard_helper.rb
98
+ - app/models/crud/klass_info.rb
99
+ - app/models/crud/klass_list.rb
100
+ - app/models/crud/menus/development_menu.rb
101
+ - app/views/crud/crud/_attribute_value.html.erb
102
+ - app/views/crud/crud/_error_messages.html.erb
103
+ - app/views/crud/crud/_flash_messages.html.erb
104
+ - app/views/crud/crud/_form.html.erb
105
+ - app/views/crud/crud/_klass_data.html.erb
106
+ - app/views/crud/crud/edit.html.erb
107
+ - app/views/crud/crud/index.html.erb
108
+ - app/views/crud/crud/index.js.erb
109
+ - app/views/crud/crud/new.html.erb
110
+ - app/views/crud/crud/show.html.erb
111
+ - app/views/crud/dashboard/index.html.erb
112
+ - app/views/layouts/crud/application.html.erb
113
+ - config/cucumber.yml
114
+ - config/initializers/inflections.rb
115
+ - config/initializers/rails_engine.rb
116
+ - config/initializers/will_paginate.rb
117
+ - config/locales/de.yml
118
+ - config/locales/en.yml
119
+ - config/locales/es.yml
120
+ - config/locales/fr.yml
121
+ - config/routes.rb
122
+ - crud.gemspec
123
+ - lib/crud.rb
124
+ - lib/crud/engine.rb
125
+ - lib/crud/version.rb
126
+ - lib/tasks/crud_tasks.rake
127
+ homepage: https://github.com/htcl/crud
128
+ licenses:
129
+ - GPL-3.0
130
+ metadata: {}
131
+ post_install_message:
132
+ rdoc_options:
133
+ - --line-numbers
134
+ - --inline-source
135
+ - --title
136
+ - crud
137
+ - --main
138
+ - README.md
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '>='
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - '>='
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.4.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Crud engine (v0.0.3)
157
+ test_files: []