rails_codebook 0.0.1.alpha → 0.0.1.alpha2
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 +4 -4
- data/.gitignore +4 -0
- data/.travis.yml +14 -1
- data/Gemfile +5 -1
- data/README.md +3 -29
- data/Rakefile +17 -0
- data/app/controllers/rails_codebook/admin/codebooks_controller.rb +8 -6
- data/app/controllers/rails_codebook/api/codebooks_controller.rb +5 -3
- data/app/models/rails_codebook/codebook.rb +5 -0
- data/app/views/rails_codebook/admin/codebooks/_codebook.html.erb +1 -1
- data/app/views/rails_codebook/admin/codebooks/index.html.erb +3 -3
- data/config/routes.rb +6 -11
- data/lib/generators/rails_codebook/install/templates/seeds.rb.erb +4 -4
- data/lib/rails_codebook/has_codebooks.rb +6 -6
- data/lib/rails_codebook/model/base.rb +8 -20
- data/lib/rails_codebook/version.rb +1 -1
- data/rails_codebook.gemspec +5 -1
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/javascripts/articles.js +2 -0
- data/test/dummy/app/assets/javascripts/comments.js +2 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/assets/stylesheets/articles.css +4 -0
- data/test/dummy/app/assets/stylesheets/comments.css +4 -0
- data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/articles_controller.rb +58 -0
- data/test/dummy/app/controllers/comments_controller.rb +58 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/articles_helper.rb +2 -0
- data/test/dummy/app/helpers/comments_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/article.rb +18 -0
- data/test/dummy/app/models/comment.rb +13 -0
- data/test/dummy/app/models/comment_relation.rb +15 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/articles/_form.html.erb +33 -0
- data/test/dummy/app/views/articles/edit.html.erb +6 -0
- data/test/dummy/app/views/articles/index.html.erb +31 -0
- data/test/dummy/app/views/articles/new.html.erb +5 -0
- data/test/dummy/app/views/articles/show.html.erb +24 -0
- data/test/dummy/app/views/comments/_form.html.erb +29 -0
- data/test/dummy/app/views/comments/edit.html.erb +6 -0
- data/test/dummy/app/views/comments/index.html.erb +30 -0
- data/test/dummy/app/views/comments/new.html.erb +5 -0
- data/test/dummy/app/views/comments/show.html.erb +19 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/routes.rb +62 -0
- data/test/dummy/db/migrate/20131121101057_create_articles.rb +13 -0
- data/test/dummy/db/migrate/20131121101251_create_comments.rb +11 -0
- data/test/dummy/db/migrate/20131121142715_create_comment_relations.rb +12 -0
- data/test/dummy/db/schema.rb +42 -0
- data/test/dummy/db/seeds.rb +189 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/controllers/articles_controller_test.rb +50 -0
- data/test/dummy/test/controllers/comments_controller_test.rb +50 -0
- data/test/dummy/test/factories/articles.rb +11 -0
- data/test/dummy/test/factories/comment_relations.rb +8 -0
- data/test/dummy/test/factories/comments.rb +12 -0
- data/test/dummy/test/helpers/articles_helper_test.rb +9 -0
- data/test/dummy/test/helpers/comments_helper_test.rb +9 -0
- data/test/dummy/test/models/article_test.rb +10 -0
- data/test/dummy/test/models/comment_relations_test.rb +7 -0
- data/test/dummy/test/models/comment_test.rb +10 -0
- data/test/factories/factories.rb +41 -0
- data/test/integration/rails_codebook/admin/codebooks_test.rb +176 -0
- data/test/integration/rails_codebook/api/codebooks_test.rb +104 -0
- data/test/rails_codebook/acts_as_codebook_test.rb +12 -0
- data/test/rails_codebook/controller/base_test.rb +13 -0
- data/test/rails_codebook/has_codebooks_test.rb +13 -0
- data/test/rails_codebook/model/base_test.rb +19 -0
- data/test/rails_codebook_test.rb +34 -0
- data/test/test_helper.rb +20 -20
- data/test/unit/helpers/rails_codebook/admin/codebooks_helper_test.rb +17 -0
- data/test/unit/models/rails_codebook/codebook_test.rb +79 -0
- metadata +215 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 210fcead50e815754763d60c3425e94ebff1e992
|
|
4
|
+
data.tar.gz: 9b152b741e4e3776bbeb7b498aea4ec96f5eac3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 48c299d926b1a37396f56d4fc434db0d10ce3a305f7525789d01fd0bc2fa3d7bfe5e87d754a2bc6b1e01db8c07aeb39c86475c939d4f90e1b638a84573fc81a6
|
|
7
|
+
data.tar.gz: 6de3c83b4dcba2fc0684db10ba47878cee0eb5f4d359efab302ca3ad08ff9b65abebf82e87523dba8e89806c4090a187345697d259b9de5efb6dc91eef3e3614
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
script: "bundle exec rake"
|
|
2
|
+
|
|
3
|
+
test_script: "bundle exec rake travis"
|
|
4
|
+
|
|
1
5
|
language: ruby
|
|
2
6
|
|
|
3
7
|
rvm:
|
|
@@ -7,4 +11,13 @@ gemfile:
|
|
|
7
11
|
- Gemfile
|
|
8
12
|
|
|
9
13
|
services:
|
|
10
|
-
- redis-server
|
|
14
|
+
- redis-server
|
|
15
|
+
|
|
16
|
+
# addons:
|
|
17
|
+
# sauce_connect:
|
|
18
|
+
# username: "redrick"
|
|
19
|
+
# access_key: "3147f979-90b5-4ecd-9daf-00b44dc174d9"
|
|
20
|
+
|
|
21
|
+
before_install:
|
|
22
|
+
- "export DISPLAY=:99.0"
|
|
23
|
+
- "sh -e /etc/init.d/xvfb start"
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,31 +1,5 @@
|
|
|
1
1
|
# WORK in PROGRESS
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
## Installation
|
|
8
|
-
|
|
9
|
-
Add this line to your application's Gemfile:
|
|
10
|
-
|
|
11
|
-
gem 'rails_codebook'
|
|
12
|
-
|
|
13
|
-
And then execute:
|
|
14
|
-
|
|
15
|
-
$ bundle
|
|
16
|
-
|
|
17
|
-
Or install it yourself as:
|
|
18
|
-
|
|
19
|
-
$ gem install rails_codebook
|
|
20
|
-
|
|
21
|
-
## Usage
|
|
22
|
-
|
|
23
|
-
TODO: Write usage instructions here
|
|
24
|
-
|
|
25
|
-
## Contributing
|
|
26
|
-
|
|
27
|
-
1. Fork it
|
|
28
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
29
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
31
|
-
5. Create new Pull Request
|
|
3
|
+
[](https://travis-ci.org/redrick/rails_codebook)
|
|
4
|
+
[](https://coveralls.io/r/redrick/rails_codebook)
|
|
5
|
+
[](http://badge.fury.io/rb/rails_codebook)
|
data/Rakefile
CHANGED
|
@@ -1 +1,18 @@
|
|
|
1
1
|
require "bundler/gem_tasks"
|
|
2
|
+
require "rake/testtask"
|
|
3
|
+
|
|
4
|
+
Rake::TestTask.new do |t|
|
|
5
|
+
t.libs << "lib"
|
|
6
|
+
t.libs << "test"
|
|
7
|
+
t.pattern = "test/**/*_test.rb"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
task default: :test
|
|
11
|
+
|
|
12
|
+
task :travis do
|
|
13
|
+
["rake test"].each do |cmd|
|
|
14
|
+
puts "Starting to run #{cmd}..."
|
|
15
|
+
system("export DISPLAY=:99.0 && bundle exec #{cmd}")
|
|
16
|
+
raise "#{cmd} failed!" unless $?.exitstatus == 0
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -5,18 +5,20 @@ module RailsCodebook
|
|
|
5
5
|
layout 'rails_codebook/application'
|
|
6
6
|
|
|
7
7
|
def index
|
|
8
|
-
|
|
9
|
-
@codebooks = RailsCodebook::Codebook.search(
|
|
8
|
+
if !params[:cb_name].blank?
|
|
9
|
+
@codebooks = RailsCodebook::Codebook.search('cb_name', params[:cb_name], true)
|
|
10
10
|
else
|
|
11
|
-
@codebooks = RailsCodebook::Codebook.
|
|
11
|
+
@codebooks = RailsCodebook::Codebook.all
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
unless params[:query].blank?
|
|
15
|
-
|
|
16
|
-
@codebooks = RailsCodebook::Codebook.search(
|
|
17
|
-
@codebooks = RailsCodebook::Codebook.search(
|
|
15
|
+
(params[:query] == '*') ? \
|
|
16
|
+
@codebooks = RailsCodebook::Codebook.search('name', params[:query], true, @codebooks) : \
|
|
17
|
+
@codebooks = RailsCodebook::Codebook.search('name', params[:query], false, @codebooks)
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
+
@codebooks = @codebooks.paginate(page: params[:page])
|
|
21
|
+
|
|
20
22
|
respond_to do |format|
|
|
21
23
|
format.html {
|
|
22
24
|
render 'index', layout: true
|
|
@@ -5,10 +5,11 @@ module RailsCodebook
|
|
|
5
5
|
# index for all codebooks
|
|
6
6
|
# /codebooks
|
|
7
7
|
def index
|
|
8
|
-
@codebooks = codebook.all
|
|
8
|
+
@codebooks = codebook.all
|
|
9
9
|
if params[:q]
|
|
10
10
|
search
|
|
11
11
|
else
|
|
12
|
+
@codebooks = @codebooks.paginate(page: params[:page])
|
|
12
13
|
render json: @codebooks.cb_serialize(params[:format])
|
|
13
14
|
end
|
|
14
15
|
end
|
|
@@ -16,10 +17,11 @@ module RailsCodebook
|
|
|
16
17
|
# index showing only one codebook
|
|
17
18
|
# /codebooks/cb_name
|
|
18
19
|
def codebook_index
|
|
19
|
-
@codebooks = RailsCodebook::Codebook.search(
|
|
20
|
+
@codebooks = RailsCodebook::Codebook.search('cb_name', params[:cb_name], true)
|
|
20
21
|
if params[:q]
|
|
21
22
|
search
|
|
22
23
|
else
|
|
24
|
+
@codebooks = @codebooks.paginate(page: params[:page])
|
|
23
25
|
render json: @codebooks.cb_serialize(params[:format])
|
|
24
26
|
end
|
|
25
27
|
end
|
|
@@ -35,7 +37,7 @@ module RailsCodebook
|
|
|
35
37
|
# /codebooks?q=something
|
|
36
38
|
# /codebooks/cb_name?q=something
|
|
37
39
|
def search
|
|
38
|
-
@codebooks = RailsCodebook::Codebook.search(
|
|
40
|
+
@codebooks = RailsCodebook::Codebook.search('name', params[:q], false, @codebooks).paginate(page: params[:page])
|
|
39
41
|
render json: @codebooks.cb_serialize(params[:format])
|
|
40
42
|
end
|
|
41
43
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<% codebook ||= @codebook %>
|
|
2
|
-
<tr id="codebook_<%= id %>" class="<%= (codebook.deleted == 1) ? "red" : ''%>">
|
|
2
|
+
<tr id="codebook_<%= id %>" class="codebook_line <%= (codebook.deleted == 1) ? "red" : ''%>">
|
|
3
3
|
<td>
|
|
4
4
|
<div class="btn-group">
|
|
5
5
|
<a class="btn btn-primary" href="#"><i class="icon-book icon-white"> </i><%= codebook.id %></a>
|
|
@@ -44,16 +44,16 @@
|
|
|
44
44
|
<div class="navbar-inner">
|
|
45
45
|
<%= form_tag admin_codebooks_path, class: 'navbar-form pull-left', method: :get, id: 'search-form' do %>
|
|
46
46
|
<%= text_field_tag :query, params[:query], hint: 'Search', placeholder: 'Search', autofocus: true %>
|
|
47
|
-
<%= button_tag '
|
|
47
|
+
<%= button_tag 'Search', class: 'btn' %>
|
|
48
48
|
<%= select_tag :cb_name, options_from_collection_for_select(all_codebooks, "cb_name", "cb_name", params[:cb_name]), include_blank: true %>
|
|
49
49
|
<% end %>
|
|
50
50
|
|
|
51
51
|
<div class="clear_button">
|
|
52
|
-
<%= link_to '
|
|
52
|
+
<%= link_to 'Clear', admin_codebooks_path, class: 'btn' %>
|
|
53
53
|
</div>
|
|
54
54
|
|
|
55
55
|
<div class="new_button">
|
|
56
|
-
<%= link_to '
|
|
56
|
+
<%= link_to 'New', '#', data: { toggle: "modal", target: '#add-codebook'}, id: 'add-codebook-link', class: 'btn' %>
|
|
57
57
|
</div>
|
|
58
58
|
|
|
59
59
|
</div>
|
data/config/routes.rb
CHANGED
|
@@ -3,23 +3,18 @@ RailsCodebook::Engine.routes.draw do
|
|
|
3
3
|
get "/(:lang)" => "admin/codebooks#index", as: :rails_codebook_root, lang: /[a-z]{2}/
|
|
4
4
|
|
|
5
5
|
namespace :api do
|
|
6
|
-
get "/(:lang)" => "codebooks#index", as: :
|
|
7
|
-
|
|
8
|
-
get "/(:lang)/:cb_name" => "codebooks#
|
|
9
|
-
get "/(:lang)/:cb_name/:id" => "codebooks#show", cb_name: /[a-z]+/, lang: /[a-z]{2}/
|
|
6
|
+
get "/(:lang)" => "codebooks#index", as: :codebooks, lang: /[a-z]{2}/
|
|
7
|
+
get "/(:lang)/:cb_name" => "codebooks#codebook_index", as: :codebook, cb_name: /[a-z]*\_*[a-z]*/, lang: /[a-z]{2}/
|
|
8
|
+
get "/(:lang)/:cb_name/:id" => "codebooks#show", as: :codebook_show , cb_name: /[a-z]*\_*[a-z]*/, lang: /[a-z]{2}/
|
|
10
9
|
end
|
|
11
10
|
|
|
12
11
|
namespace :admin do
|
|
13
12
|
get '/(:lang)' => 'codebooks#index', as: :codebooks
|
|
14
13
|
post '/' => 'codebooks#create', as: :create_codebooks
|
|
15
14
|
delete '/codebooks/:id(.:format)' => 'codebooks#destroy', as: :codebook
|
|
16
|
-
# POST /admin/codebooks(.:format) rails_codebook/admin/codebooks#create
|
|
17
|
-
# new_admin_codebook_path GET /admin/codebooks/new(.:format) rails_codebook/admin/codebooks#new
|
|
18
|
-
# edit_admin_codebook_path GET /admin/codebooks/:id/edit(.:format) rails_codebook/admin/codebooks#edit
|
|
19
|
-
# admin_codebook_path GET /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#show
|
|
20
|
-
# PATCH /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#update
|
|
21
|
-
# PUT /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#update
|
|
22
|
-
# DELETE /admin/codebooks/:id(.:format) rails_codebook/admin/codebooks#destroy
|
|
23
15
|
end
|
|
24
16
|
|
|
17
|
+
# mount with
|
|
18
|
+
# mount RailsCodebook::Engine => '/codebooks'
|
|
19
|
+
|
|
25
20
|
end
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
unless RailsCodebook::Codebook.search(
|
|
1
|
+
unless RailsCodebook::Codebook.search('cb_name', 'boolean', true).length > 0
|
|
2
2
|
RailsCodebook::Codebook.create(value: 'yes', name: 'codebook.boolean.yes', cb_name: 'boolean')
|
|
3
3
|
RailsCodebook::Codebook.create(value: 'no', name: 'codebook.boolean.no', cb_name: 'boolean')
|
|
4
4
|
end
|
|
5
5
|
|
|
6
|
-
unless RailsCodebook::Codebook.search(
|
|
6
|
+
unless RailsCodebook::Codebook.search('cb_name', 'country', true).length > 0
|
|
7
7
|
RailsCodebook::Codebook.create(value: 'afg', name: 'codebook.country.afg', cb_name: 'country')
|
|
8
8
|
RailsCodebook::Codebook.create(value: 'ala', name: 'codebook.country.ala', cb_name: 'country')
|
|
9
9
|
RailsCodebook::Codebook.create(value: 'alb', name: 'codebook.country.alb', cb_name: 'country')
|
|
@@ -252,7 +252,7 @@ unless RailsCodebook::Codebook.search(1, 'cb_name', 'country', true).length > 0
|
|
|
252
252
|
RailsCodebook::Codebook.create(value: 'svk', name: 'codebook.country.svk', cb_name: 'country')
|
|
253
253
|
end
|
|
254
254
|
|
|
255
|
-
unless RailsCodebook::Codebook.search(
|
|
255
|
+
unless RailsCodebook::Codebook.search('cb_name', 'currency', true).length > 0
|
|
256
256
|
RailsCodebook::Codebook.create(value: 'aud', name: 'codebook.currency.aud', cb_name: 'currency')
|
|
257
257
|
RailsCodebook::Codebook.create(value: 'cad', name: 'codebook.currency.cad', cb_name: 'currency')
|
|
258
258
|
RailsCodebook::Codebook.create(value: 'chf', name: 'codebook.currency.chf', cb_name: 'currency')
|
|
@@ -264,7 +264,7 @@ unless RailsCodebook::Codebook.search(1, 'cb_name', 'currency', true).length > 0
|
|
|
264
264
|
RailsCodebook::Codebook.create(value: 'usd', name: 'codebook.currency.usd', cb_name: 'currency')
|
|
265
265
|
end
|
|
266
266
|
|
|
267
|
-
unless RailsCodebook::Codebook.search(
|
|
267
|
+
unless RailsCodebook::Codebook.search('cb_name', 'importance', true).length > 0
|
|
268
268
|
RailsCodebook::Codebook.create(value: 'low', name: 'codebook.importance.low', cb_name: 'importance')
|
|
269
269
|
RailsCodebook::Codebook.create(value: 'medium', name: 'codebook.importance.medium', cb_name: 'importance')
|
|
270
270
|
RailsCodebook::Codebook.create(value: 'high', name: 'codebook.importance.high', cb_name: 'importance')
|
|
@@ -69,7 +69,7 @@ class << ActiveRecord::Base
|
|
|
69
69
|
|
|
70
70
|
# method for getting the one row referenced from model as object (something_object)
|
|
71
71
|
define_method (base_method_name+"_object").to_sym do |hash={}|
|
|
72
|
-
all = RailsCodebook::Codebook.search(
|
|
72
|
+
all = RailsCodebook::Codebook.search("cb_name", codebook_name, true)
|
|
73
73
|
all.each {|row| return row if row.send(fk_cb) == self.send(column_name) }; hash
|
|
74
74
|
end
|
|
75
75
|
|
|
@@ -85,27 +85,27 @@ class << ActiveRecord::Base
|
|
|
85
85
|
|
|
86
86
|
# method for getting all possible values of codebook or the column given (something_object_all) => OBJECT
|
|
87
87
|
define_singleton_method (base_method_name+"_object_all").to_sym do
|
|
88
|
-
RailsCodebook::Codebook.search(
|
|
88
|
+
RailsCodebook::Codebook.search("cb_name", codebook_name, true)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
# method for getting all possible values of codebook or the column given (something_object_all) => OBJECT
|
|
92
92
|
define_singleton_method (base_method_name+"_collection").to_sym do
|
|
93
|
-
RailsCodebook::Codebook.search(
|
|
93
|
+
RailsCodebook::Codebook.search("cb_name", codebook_name, true)
|
|
94
94
|
end
|
|
95
95
|
|
|
96
96
|
# method for getting all possible values of codebook or the column given (something_all) => JSON
|
|
97
97
|
define_singleton_method (base_method_name+"_all").to_sym do
|
|
98
|
-
RailsCodebook::Codebook.search(
|
|
98
|
+
RailsCodebook::Codebook.search("cb_name", codebook_name, true).cb_serialize
|
|
99
99
|
end
|
|
100
100
|
|
|
101
101
|
# method for getting the array of i18ned names of cb rows (something_names)
|
|
102
102
|
define_singleton_method (base_method_name+"_values").to_sym do |array=[]|
|
|
103
|
-
RailsCodebook::Codebook.search(
|
|
103
|
+
RailsCodebook::Codebook.search("cb_name", codebook_name, true).each {|cb| array << I18n.t(cb.name) }; array
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
# method for getting the array of values of cb rows (something_values)
|
|
107
107
|
define_singleton_method (base_method_name+"_keys").to_sym do
|
|
108
|
-
RailsCodebook::Codebook.search(
|
|
108
|
+
RailsCodebook::Codebook.search("cb_name", codebook_name, true).map(&:value)
|
|
109
109
|
end
|
|
110
110
|
|
|
111
111
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
require 'redis_orm'
|
|
2
|
+
|
|
1
3
|
module RailsCodebook
|
|
2
4
|
|
|
3
5
|
module Model
|
|
@@ -5,29 +7,15 @@ module RailsCodebook
|
|
|
5
7
|
class Base < ::RedisOrm::Base
|
|
6
8
|
self.abstract_class = true
|
|
7
9
|
|
|
8
|
-
# array with value columns from the codebook
|
|
9
|
-
def self.get_values
|
|
10
|
-
self.all.map(&:value)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
# array with name columns from the codebook
|
|
14
|
-
def self.get_names
|
|
15
|
-
self.all.map(&:name)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
# searching through codebook with usage of i18n
|
|
19
|
-
def self.search_i18n query_string, array=[]
|
|
20
|
-
self.all.each {|redis_row| array << redis_row.codebook_format if I18n.t(redis_row.name) =~ /#{query_string}/i }; array
|
|
21
|
-
end
|
|
22
|
-
|
|
23
10
|
# universal regexp_search
|
|
24
|
-
def self.search
|
|
11
|
+
def self.search column_name='', value='', strict=false, init_cb=RailsCodebook::Codebook.all
|
|
12
|
+
# binding.pry
|
|
25
13
|
if column_name != ''
|
|
26
14
|
strict ? \
|
|
27
|
-
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~ /^#{value}$/i}
|
|
28
|
-
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~
|
|
29
|
-
else
|
|
30
|
-
init_cb
|
|
15
|
+
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~ /^#{value}$/i} : \
|
|
16
|
+
init_cb.select{|j| ((column_name == 'name') ? I18n.t(j.send(column_name)) : j.send(column_name)) =~ /(#{value})/i}
|
|
17
|
+
else
|
|
18
|
+
init_cb
|
|
31
19
|
end
|
|
32
20
|
end
|
|
33
21
|
|
data/rails_codebook.gemspec
CHANGED
|
@@ -34,7 +34,11 @@ Gem::Specification.new do |spec|
|
|
|
34
34
|
spec.add_development_dependency "coveralls"
|
|
35
35
|
spec.add_development_dependency "bundler", "~> 1.3"
|
|
36
36
|
spec.add_development_dependency "minitest-rails"
|
|
37
|
+
spec.add_development_dependency "capybara" #, '2.0.2'
|
|
37
38
|
spec.add_development_dependency "minitest-rails-capybara"
|
|
38
39
|
spec.add_development_dependency "factory_girl_rails"
|
|
39
|
-
spec.add_development_dependency "
|
|
40
|
+
spec.add_development_dependency "selenium-webdriver"
|
|
41
|
+
spec.add_development_dependency "turn"
|
|
42
|
+
|
|
43
|
+
spec.add_dependency "rake"
|
|
40
44
|
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
|
3
|
+
|
|
4
|
+
require File.expand_path('../config/application', __FILE__)
|
|
5
|
+
require 'rake'
|
|
6
|
+
|
|
7
|
+
Dummy::Application.load_tasks
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
14
|
+
//= require jquery
|
|
15
|
+
//= require jquery_ujs
|