cfror 0.0.1

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 (36) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/Rakefile +26 -0
  4. data/app/assets/stylesheets/cfror/application.css +15 -0
  5. data/app/controllers/cfror/application_controller.rb +4 -0
  6. data/app/helpers/cfror/application_helper.rb +4 -0
  7. data/app/models/cfror/boolean.rb +6 -0
  8. data/app/models/cfror/date.rb +6 -0
  9. data/app/models/cfror/datetime.rb +6 -0
  10. data/app/models/cfror/field.rb +18 -0
  11. data/app/models/cfror/image.rb +8 -0
  12. data/app/models/cfror/integer.rb +6 -0
  13. data/app/models/cfror/option.rb +7 -0
  14. data/app/models/cfror/select_option.rb +5 -0
  15. data/app/models/cfror/string.rb +6 -0
  16. data/app/models/cfror/text.rb +6 -0
  17. data/app/uploaders/cfror/image_uploader.rb +51 -0
  18. data/app/views/layouts/cfror/application.html.erb +14 -0
  19. data/config/locales/cfror_en.yml +10 -0
  20. data/config/locales/cfror_ru.yml +10 -0
  21. data/config/routes.rb +2 -0
  22. data/db/migrate/20150703114808_create_cfror_fields.rb +15 -0
  23. data/db/migrate/20150703122109_create_cfror_strings.rb +18 -0
  24. data/db/migrate/20150703130107_create_cfror_texts.rb +19 -0
  25. data/db/migrate/20150709082957_create_cfror_integers.rb +18 -0
  26. data/db/migrate/20150709083429_create_cfror_booleans.rb +18 -0
  27. data/db/migrate/20150709083638_create_cfror_dates.rb +18 -0
  28. data/db/migrate/20150709084129_create_cfror_datetimes.rb +18 -0
  29. data/db/migrate/20150709084304_create_cfror_select_options.rb +18 -0
  30. data/db/migrate/20150709084409_create_cfror_options.rb +18 -0
  31. data/db/migrate/20150709131240_create_cfror_images.rb +18 -0
  32. data/lib/cfror/engine.rb +20 -0
  33. data/lib/cfror/version.rb +3 -0
  34. data/lib/cfror.rb +4 -0
  35. data/lib/tasks/cfror_tasks.rake +4 -0
  36. metadata +106 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 635c51e30a69d4cb9b361296018063be0e4e63da
4
+ data.tar.gz: e5572e2ce25815e8022164c09c5cb17e7935a532
5
+ SHA512:
6
+ metadata.gz: 78f21de510f4f51931bb5795b1dbdd1c9ac1b600a4778b8c39e8928b521e29c063b45d7efabb91d2c94e4ebc7fbd07bada76b2df7d08d5e99a6e2d814cfcfdb7
7
+ data.tar.gz: 3979827ac9065a75e9b9e0fa655769c10c3a24a13797ef28890fc6f7bc741a2a493ec83358985a5da6505ab7200b484c544137cdfaebfefd34ef08cf4a93c9d9
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 Александр Дмитриев
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/Rakefile ADDED
@@ -0,0 +1,26 @@
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 = 'Cfror'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/cfror/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module Cfror
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Cfror
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class Boolean < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class Date < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class Datetime < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,18 @@
1
+ module Cfror
2
+ class Field < ActiveRecord::Base
3
+ enum field_type: [ :string, :text, :integer, :boolean, :date, :option ]
4
+
5
+ belongs_to :fieldable, polymorphic: true
6
+
7
+ has_many :select_options, dependent: :destroy
8
+ accepts_nested_attributes_for :select_options, allow_destroy: true
9
+
10
+ has_many :strings, dependent: :destroy
11
+ has_many :texts, dependent: :destroy
12
+ has_many :integers, dependent: :destroy
13
+ has_many :booleans, dependent: :destroy
14
+ has_many :dates, dependent: :destroy
15
+ has_many :datetimes, dependent: :destroy
16
+ has_many :options, dependent: :destroy
17
+ end
18
+ end
@@ -0,0 +1,8 @@
1
+ module Cfror
2
+ class Image < ActiveRecord::Base
3
+ mount_uploader :body, Cfror::Image
4
+
5
+ belongs_to :dataable, polymorphic: true
6
+ belongs_to :field
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class Integer < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Cfror
2
+ class Option < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ belongs_to :select_option
6
+ end
7
+ end
@@ -0,0 +1,5 @@
1
+ module Cfror
2
+ class SelectOption < ActiveRecord::Base
3
+ belongs_to :field
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class String < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ module Cfror
2
+ class Text < ActiveRecord::Base
3
+ belongs_to :dataable, polymorphic: true
4
+ belongs_to :field
5
+ end
6
+ end
@@ -0,0 +1,51 @@
1
+ # encoding: utf-8
2
+
3
+ class Cfror::ImageUploader < CarrierWave::Uploader::Base
4
+
5
+ # Include RMagick or MiniMagick support:
6
+ # include CarrierWave::RMagick
7
+ # include CarrierWave::MiniMagick
8
+
9
+ # Choose what kind of storage to use for this uploader:
10
+ storage :file
11
+ # storage :fog
12
+
13
+ # Override the directory where uploaded files will be stored.
14
+ # This is a sensible default for uploaders that are meant to be mounted:
15
+ def store_dir
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
+ end
18
+
19
+ # Provide a default URL as a default if there hasn't been a file uploaded:
20
+ # def default_url
21
+ # # For Rails 3.1+ asset pipeline compatibility:
22
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
23
+ #
24
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
25
+ # end
26
+
27
+ # Process files as they are uploaded:
28
+ # process :scale => [200, 300]
29
+ #
30
+ # def scale(width, height)
31
+ # # do something
32
+ # end
33
+
34
+ # Create different versions of your uploaded files:
35
+ # version :thumb do
36
+ # process :resize_to_fit => [50, 50]
37
+ # end
38
+
39
+ # Add a white list of extensions which are allowed to be uploaded.
40
+ # For images you might use something like this:
41
+ # def extension_white_list
42
+ # %w(jpg jpeg gif png)
43
+ # end
44
+
45
+ # Override the filename of the uploaded files:
46
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
47
+ # def filename
48
+ # "something.jpg" if original_filename
49
+ # end
50
+
51
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Cfror</title>
5
+ <%= stylesheet_link_tag "cfror/application", media: "all" %>
6
+ <%= javascript_include_tag "cfror/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,10 @@
1
+ en:
2
+ cfror:
3
+ field_type:
4
+ string: String
5
+ text: Text
6
+ integer: Integer
7
+ boolean: Boolean
8
+ date: Date
9
+ datetime: Date and Time
10
+ option: Select
@@ -0,0 +1,10 @@
1
+ ru:
2
+ cfror:
3
+ field_type:
4
+ string: Строка
5
+ text: Текст
6
+ integer: Число
7
+ boolean: 'Да/Нет'
8
+ date: Дата
9
+ datetimes: Дата и время
10
+ option: Список
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Cfror::Engine.routes.draw do
2
+ end
@@ -0,0 +1,15 @@
1
+ class CreateCfrorFields < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_fields do |t|
4
+ t.string :fieldable_type
5
+ t.index :fieldable_type
6
+ t.integer :fieldable_id
7
+ t.index :fieldable_id
8
+ t.index [:fieldable_type, :fieldable_id]
9
+
10
+ t.string :field_type
11
+ t.string :title
12
+ t.string :name
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorStrings < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_strings do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.string :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ class CreateCfrorTexts < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_texts do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+
16
+ t.text :body
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorIntegers < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_integers do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.integer :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorBooleans < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_booleans do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.boolean :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorDates < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_dates do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.date :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorDatetimes < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_datetimes do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.datetime :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorSelectOptions < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_select_options do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.string :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorOptions < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_options do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.integer :select_option_id
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateCfrorImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :cfror_images do |t|
4
+ t.integer :field_id
5
+ t.index :field_id
6
+
7
+ t.string :dataable_type
8
+ t.index :dataable_type
9
+
10
+ t.integer :dataable_id
11
+ t.index :dataable_id
12
+
13
+ t.index [:dataable_type, :dataable_id]
14
+
15
+ t.string :body
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,20 @@
1
+ module Cfror
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Cfror
4
+
5
+ config.generators do |g|
6
+ g.test_framework :rspec
7
+ g.fixture_replacement :factory_girl, :dir => 'spec/factories'
8
+ end
9
+
10
+
11
+ initializer :append_migrations do |app|
12
+ unless app.root.to_s.match root.to_s
13
+ config.paths["db/migrate"].expanded.each do |expanded_path|
14
+ app.config.paths["db/migrate"] << expanded_path
15
+ end
16
+ end
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ module Cfror
2
+ VERSION = "0.0.1"
3
+ end
data/lib/cfror.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "cfror/engine"
2
+
3
+ module Cfror
4
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :cfror do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cfror
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Alexander Dmitriev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-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: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ description: Cfror add custom fields to rails model.
42
+ email:
43
+ - alexanderdmv@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - MIT-LICENSE
49
+ - Rakefile
50
+ - app/assets/stylesheets/cfror/application.css
51
+ - app/controllers/cfror/application_controller.rb
52
+ - app/helpers/cfror/application_helper.rb
53
+ - app/models/cfror/boolean.rb
54
+ - app/models/cfror/date.rb
55
+ - app/models/cfror/datetime.rb
56
+ - app/models/cfror/field.rb
57
+ - app/models/cfror/image.rb
58
+ - app/models/cfror/integer.rb
59
+ - app/models/cfror/option.rb
60
+ - app/models/cfror/select_option.rb
61
+ - app/models/cfror/string.rb
62
+ - app/models/cfror/text.rb
63
+ - app/uploaders/cfror/image_uploader.rb
64
+ - app/views/layouts/cfror/application.html.erb
65
+ - config/locales/cfror_en.yml
66
+ - config/locales/cfror_ru.yml
67
+ - config/routes.rb
68
+ - db/migrate/20150703114808_create_cfror_fields.rb
69
+ - db/migrate/20150703122109_create_cfror_strings.rb
70
+ - db/migrate/20150703130107_create_cfror_texts.rb
71
+ - db/migrate/20150709082957_create_cfror_integers.rb
72
+ - db/migrate/20150709083429_create_cfror_booleans.rb
73
+ - db/migrate/20150709083638_create_cfror_dates.rb
74
+ - db/migrate/20150709084129_create_cfror_datetimes.rb
75
+ - db/migrate/20150709084304_create_cfror_select_options.rb
76
+ - db/migrate/20150709084409_create_cfror_options.rb
77
+ - db/migrate/20150709131240_create_cfror_images.rb
78
+ - lib/cfror.rb
79
+ - lib/cfror/engine.rb
80
+ - lib/cfror/version.rb
81
+ - lib/tasks/cfror_tasks.rake
82
+ homepage: https://github.com/sunchess/cfror
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.4.3
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: Cfror add custom fields to rails model.
106
+ test_files: []