citier4 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 (84) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +32 -0
  5. data/lib/citier4/acts_as_citier4.rb +95 -0
  6. data/lib/citier4/child_instance_methods.rb +111 -0
  7. data/lib/citier4/core_ext.rb +118 -0
  8. data/lib/citier4/instance_methods.rb +41 -0
  9. data/lib/citier4/relation_methods.rb +139 -0
  10. data/lib/citier4/root_class_methods.rb +36 -0
  11. data/lib/citier4/root_instance_methods.rb +47 -0
  12. data/lib/citier4/version.rb +3 -0
  13. data/lib/citier4.rb +34 -0
  14. data/lib/tasks/citier4_tasks.rake +4 -0
  15. data/test/acts_as_citier4_test.rb +10 -0
  16. data/test/child_instance_methods_test.rb +70 -0
  17. data/test/citier4_test.rb +7 -0
  18. data/test/core_ext_test.rb +7 -0
  19. data/test/deleting_methods_test.rb +101 -0
  20. data/test/dummy/README.rdoc +28 -0
  21. data/test/dummy/Rakefile +6 -0
  22. data/test/dummy/app/assets/javascripts/application.js +13 -0
  23. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  24. data/test/dummy/app/controllers/application_controller.rb +5 -0
  25. data/test/dummy/app/helpers/application_helper.rb +2 -0
  26. data/test/dummy/app/models/animal.rb +16 -0
  27. data/test/dummy/app/models/bidule.rb +2 -0
  28. data/test/dummy/app/models/book.rb +7 -0
  29. data/test/dummy/app/models/dictionary.rb +3 -0
  30. data/test/dummy/app/models/fiction.rb +3 -0
  31. data/test/dummy/app/models/product.rb +8 -0
  32. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  33. data/test/dummy/bin/bundle +3 -0
  34. data/test/dummy/bin/rails +4 -0
  35. data/test/dummy/bin/rake +4 -0
  36. data/test/dummy/config/application.rb +23 -0
  37. data/test/dummy/config/boot.rb +5 -0
  38. data/test/dummy/config/database.yml +25 -0
  39. data/test/dummy/config/environment.rb +5 -0
  40. data/test/dummy/config/environments/development.rb +37 -0
  41. data/test/dummy/config/environments/production.rb +78 -0
  42. data/test/dummy/config/environments/test.rb +39 -0
  43. data/test/dummy/config/initializers/assets.rb +8 -0
  44. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  45. data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
  46. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  47. data/test/dummy/config/initializers/inflections.rb +16 -0
  48. data/test/dummy/config/initializers/mime_types.rb +4 -0
  49. data/test/dummy/config/initializers/session_store.rb +3 -0
  50. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  51. data/test/dummy/config/locales/en.yml +23 -0
  52. data/test/dummy/config/routes.rb +56 -0
  53. data/test/dummy/config/secrets.yml +22 -0
  54. data/test/dummy/config.ru +4 -0
  55. data/test/dummy/db/development.sqlite3 +0 -0
  56. data/test/dummy/db/migrate/20141228200436_create_products.rb +10 -0
  57. data/test/dummy/db/migrate/20141228200756_create_books.rb +17 -0
  58. data/test/dummy/db/migrate/20150101181703_create_dictionaries.rb +16 -0
  59. data/test/dummy/db/migrate/20150101181916_create_fictions.rb +14 -0
  60. data/test/dummy/db/migrate/20150102200342_create_bidules.rb +9 -0
  61. data/test/dummy/db/migrate/20150102200786_create_animals.rb +10 -0
  62. data/test/dummy/db/schema.rb +81 -0
  63. data/test/dummy/db/test.sqlite3 +0 -0
  64. data/test/dummy/log/development.log +2695 -0
  65. data/test/dummy/log/test.log +152338 -0
  66. data/test/dummy/public/404.html +67 -0
  67. data/test/dummy/public/422.html +67 -0
  68. data/test/dummy/public/500.html +66 -0
  69. data/test/dummy/public/favicon.ico +0 -0
  70. data/test/dummy/test/fixtures/bidules.yml +7 -0
  71. data/test/dummy/test/fixtures/books.yml +9 -0
  72. data/test/dummy/test/fixtures/dictionaries.yml +7 -0
  73. data/test/dummy/test/fixtures/fictions.yml +7 -0
  74. data/test/dummy/test/fixtures/products.yml +7 -0
  75. data/test/dummy/test/models/bidule_test.rb +7 -0
  76. data/test/dummy/test/models/book_test.rb +7 -0
  77. data/test/dummy/test/models/dictionary_test.rb +7 -0
  78. data/test/dummy/test/models/fiction_test.rb +7 -0
  79. data/test/dummy/test/models/product_test.rb +7 -0
  80. data/test/model_test.rb +34 -0
  81. data/test/retrieving_methods_test.rb +153 -0
  82. data/test/root_instance_methods_test.rb +27 -0
  83. data/test/test_helper.rb +60 -0
  84. metadata +227 -0
@@ -0,0 +1,16 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format. Inflections
4
+ # are locale specific, and you may define rules for as many different
5
+ # locales as you wish. All of these examples are active by default:
6
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
7
+ # inflect.plural /^(ox)$/i, '\1en'
8
+ # inflect.singular /^(ox)en/i, '\1'
9
+ # inflect.irregular 'person', 'people'
10
+ # inflect.uncountable %w( fish sheep )
11
+ # end
12
+
13
+ # These inflection rules are supported but not enabled by default:
14
+ # ActiveSupport::Inflector.inflections(:en) do |inflect|
15
+ # inflect.acronym 'RESTful'
16
+ # end
@@ -0,0 +1,4 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
@@ -0,0 +1,3 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
+ end
10
+
11
+ # To enable root element in JSON for ActiveRecord objects.
12
+ # ActiveSupport.on_load(:active_record) do
13
+ # self.include_root_in_json = true
14
+ # end
@@ -0,0 +1,23 @@
1
+ # Files in the config/locales directory are used for internationalization
2
+ # and are automatically loaded by Rails. If you want to use locales other
3
+ # than English, add the necessary files in this directory.
4
+ #
5
+ # To use the locales, use `I18n.t`:
6
+ #
7
+ # I18n.t 'hello'
8
+ #
9
+ # In views, this is aliased to just `t`:
10
+ #
11
+ # <%= t('hello') %>
12
+ #
13
+ # To use a different locale, set it with `I18n.locale`:
14
+ #
15
+ # I18n.locale = :es
16
+ #
17
+ # This would use the information in config/locales/es.yml.
18
+ #
19
+ # To learn more, please read the Rails Internationalization guide
20
+ # available at http://guides.rubyonrails.org/i18n.html.
21
+
22
+ en:
23
+ hello: "Hello world"
@@ -0,0 +1,56 @@
1
+ Rails.application.routes.draw do
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+ # See how all your routes lay out with "rake routes".
4
+
5
+ # You can have the root of your site routed with "root"
6
+ # root 'welcome#index'
7
+
8
+ # Example of regular route:
9
+ # get 'products/:id' => 'catalog#view'
10
+
11
+ # Example of named route that can be invoked with purchase_url(id: product.id)
12
+ # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase
13
+
14
+ # Example resource route (maps HTTP verbs to controller actions automatically):
15
+ # resources :products
16
+
17
+ # Example resource route with options:
18
+ # resources :products do
19
+ # member do
20
+ # get 'short'
21
+ # post 'toggle'
22
+ # end
23
+ #
24
+ # collection do
25
+ # get 'sold'
26
+ # end
27
+ # end
28
+
29
+ # Example resource route with sub-resources:
30
+ # resources :products do
31
+ # resources :comments, :sales
32
+ # resource :seller
33
+ # end
34
+
35
+ # Example resource route with more complex sub-resources:
36
+ # resources :products do
37
+ # resources :comments
38
+ # resources :sales do
39
+ # get 'recent', on: :collection
40
+ # end
41
+ # end
42
+
43
+ # Example resource route with concerns:
44
+ # concern :toggleable do
45
+ # post 'toggle'
46
+ # end
47
+ # resources :posts, concerns: :toggleable
48
+ # resources :photos, concerns: :toggleable
49
+
50
+ # Example resource route within a namespace:
51
+ # namespace :admin do
52
+ # # Directs /admin/products/* to Admin::ProductsController
53
+ # # (app/controllers/admin/products_controller.rb)
54
+ # resources :products
55
+ # end
56
+ end
@@ -0,0 +1,22 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key is used for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+
6
+ # Make sure the secret is at least 30 characters and all random,
7
+ # no regular words or you'll be exposed to dictionary attacks.
8
+ # You can use `rake secret` to generate a secure secret key.
9
+
10
+ # Make sure the secrets in this file are kept private
11
+ # if you're sharing your code publicly.
12
+
13
+ development:
14
+ secret_key_base: 73234b8c73f49807ca9384245ba01be9b7b7a50fe54db9aae589655ca6c10aad453b8b6d0f844c913d4ae45756b41cab69b3f1ea72fa75e33753310fdf766259
15
+
16
+ test:
17
+ secret_key_base: f8fcbfd7b012dabfd8dfed900155f6628abe599742258646f1500749ed714f244eb0ed9fde68b483272e7d5dc6ef9967915b08e3f41d7dc5682eb389517a4598
18
+
19
+ # Do not keep production secrets in the repository,
20
+ # instead read values from the environment.
21
+ production:
22
+ secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Rails.application
Binary file
@@ -0,0 +1,10 @@
1
+ class CreateProducts < ActiveRecord::Migration
2
+ def change
3
+ create_table :products do |t|
4
+ t.string :name
5
+ t.string :type
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class CreateBooks < ActiveRecord::Migration
2
+ def change
3
+ create_table :books do |t|
4
+ t.string :author
5
+ t.string :title
6
+
7
+ # PLEASE, dont't add timestamps : Duplicated attribute
8
+ # will cause SQL Exception : ambiguous column
9
+ # t.timestamps
10
+ end
11
+
12
+ reversible do |dir|
13
+ dir.up { create_citier_view(::Book) } # ::Book
14
+ dir.down { drop_citier_view(::Book) }
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ class CreateDictionaries < ActiveRecord::Migration
2
+ def change
3
+ create_table :dictionaries do |t|
4
+ t.string :language
5
+
6
+ # PLEASE, dont't add timestamps : Duplicated attribute
7
+ # will cause SQL Exception : ambiguous column
8
+ # t.timestamps
9
+ end
10
+ reversible do |dir|
11
+ dir.up { create_citier_view(::Dictionary) }
12
+ dir.down { drop_citier_view(::Dictionary) }
13
+ end
14
+ end
15
+
16
+ end
@@ -0,0 +1,14 @@
1
+ class CreateFictions < ActiveRecord::Migration
2
+ def change
3
+ create_table :fictions do |t|
4
+ t.text :story
5
+
6
+ # t.timestamps PLEASE, remember to remove ...
7
+ end
8
+
9
+ reversible do |dir|
10
+ dir.up { create_citier_view(::Fiction) }
11
+ dir.down { drop_citier_view(::Fiction) }
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class CreateBidules < ActiveRecord::Migration
2
+ def change
3
+ create_table :bidules do |t|
4
+ t.string :name
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ class CreateAnimals < ActiveRecord::Migration
2
+ def change
3
+ create_table :animals do |t|
4
+ t.string :name
5
+ t.string :race # sti inheritance field
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,81 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20150102200786) do
15
+
16
+ create_table "animals", force: true do |t|
17
+ t.string "name"
18
+ t.string "race"
19
+ t.datetime "created_at"
20
+ t.datetime "updated_at"
21
+ end
22
+
23
+ create_table "bidules", force: true do |t|
24
+ t.string "name", limit: nil
25
+ t.datetime "created_at"
26
+ t.datetime "updated_at"
27
+ end
28
+
29
+ create_table "books", force: true do |t|
30
+ t.string "author", limit: nil
31
+ t.string "title", limit: nil
32
+ end
33
+
34
+ create_table "dictionaries", force: true do |t|
35
+ t.string "language", limit: nil
36
+ end
37
+
38
+ create_table "fictions", force: true do |t|
39
+ t.text "story"
40
+ end
41
+
42
+ create_table "products", force: true do |t|
43
+ t.string "name", limit: nil
44
+ t.string "type", limit: nil
45
+ t.datetime "created_at"
46
+ t.datetime "updated_at"
47
+ end
48
+
49
+ create_view "view_books" , "SELECT products.id, name,type,created_at,updated_at,author,title FROM products, books WHERE products.id = books.id", :force => true do |v|
50
+ v.column :id
51
+ v.column :name
52
+ v.column :type
53
+ v.column :created_at
54
+ v.column :updated_at
55
+ v.column :author
56
+ v.column :title
57
+ end
58
+
59
+ create_view "view_dictionaries" , "SELECT view_books.id, name,type,created_at,updated_at,author,title,language FROM view_books, dictionaries WHERE view_books.id = dictionaries.id", :force => true do |v|
60
+ v.column :id
61
+ v.column :name
62
+ v.column :type
63
+ v.column :created_at
64
+ v.column :updated_at
65
+ v.column :author
66
+ v.column :title
67
+ v.column :language
68
+ end
69
+
70
+ create_view "view_fictions" , "SELECT view_books.id, name,type,created_at,updated_at,author,title,story FROM view_books, fictions WHERE view_books.id = fictions.id", :force => true do |v|
71
+ v.column :id
72
+ v.column :name
73
+ v.column :type
74
+ v.column :created_at
75
+ v.column :updated_at
76
+ v.column :author
77
+ v.column :title
78
+ v.column :story
79
+ end
80
+
81
+ end
Binary file