serializer 0.0.3 → 0.0.4

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 (56) hide show
  1. data/Rakefile +23 -0
  2. data/lib/serializer.rb +4 -4
  3. data/lib/serializer/version.rb +1 -1
  4. data/test/dummy/Rakefile +7 -0
  5. data/test/dummy/app/assets/javascripts/application.js +3 -0
  6. data/test/dummy/app/assets/javascripts/main.js +0 -0
  7. data/test/dummy/app/assets/javascripts/users.js +0 -0
  8. data/test/dummy/app/assets/stylesheets/application.css +16 -0
  9. data/test/dummy/app/assets/stylesheets/main.css +4 -0
  10. data/test/dummy/app/assets/stylesheets/scaffold.css +56 -0
  11. data/test/dummy/app/assets/stylesheets/users.css +4 -0
  12. data/test/dummy/app/controllers/application_controller.rb +3 -0
  13. data/test/dummy/app/controllers/main_controller.rb +10 -0
  14. data/test/dummy/app/controllers/users_controller.rb +57 -0
  15. data/test/dummy/app/helpers/application_helper.rb +2 -0
  16. data/test/dummy/app/helpers/main_helper.rb +2 -0
  17. data/test/dummy/app/helpers/users_helper.rb +2 -0
  18. data/test/dummy/app/models/user.rb +8 -0
  19. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  20. data/test/dummy/app/views/main/index.html.erb +5 -0
  21. data/test/dummy/app/views/users/_form.html.erb +36 -0
  22. data/test/dummy/app/views/users/edit.html.erb +6 -0
  23. data/test/dummy/app/views/users/index.html.erb +25 -0
  24. data/test/dummy/app/views/users/new.html.erb +5 -0
  25. data/test/dummy/app/views/users/show.html.erb +24 -0
  26. data/test/dummy/config.ru +4 -0
  27. data/test/dummy/config/application.rb +45 -0
  28. data/test/dummy/config/boot.rb +10 -0
  29. data/test/dummy/config/database.yml +17 -0
  30. data/test/dummy/config/environment.rb +5 -0
  31. data/test/dummy/config/environments/development.rb +30 -0
  32. data/test/dummy/config/environments/production.rb +60 -0
  33. data/test/dummy/config/environments/test.rb +39 -0
  34. data/test/dummy/config/initializers/other.rb +2 -0
  35. data/test/dummy/config/locales/en.yml +1 -0
  36. data/test/dummy/config/routes.rb +7 -0
  37. data/test/dummy/db/development.sqlite3 +0 -0
  38. data/test/dummy/db/migrate/20110927222742_create_users.rb +11 -0
  39. data/test/dummy/db/schema.rb +24 -0
  40. data/test/dummy/db/test.sqlite3 +0 -0
  41. data/test/dummy/log/development.log +24 -0
  42. data/test/dummy/log/test.log +825 -0
  43. data/test/dummy/public/favicon.ico +0 -0
  44. data/test/dummy/script/rails +6 -0
  45. data/test/dummy/test/fixtures/users.yml +11 -0
  46. data/test/dummy/test/functional/main_controller_test.rb +10 -0
  47. data/test/dummy/test/functional/users_controller_test.rb +52 -0
  48. data/test/dummy/test/integration/user_create_test.rb +17 -0
  49. data/test/dummy/test/integration/user_update_test.rb +17 -0
  50. data/test/dummy/test/unit/helpers/main_helper_test.rb +4 -0
  51. data/test/dummy/test/unit/helpers/users_helper_test.rb +4 -0
  52. data/test/dummy/test/unit/user_test.rb +55 -0
  53. data/test/serializer_test.rb +7 -0
  54. data/test/test_helper.rb +8 -0
  55. metadata +135 -6
  56. data/Gemfile +0 -3
data/Rakefile CHANGED
@@ -1,2 +1,25 @@
1
+ #!/usr/bin/env rake
2
+
1
3
  require 'bundler'
4
+
5
+ require 'rdoc/task'
6
+ require 'rake/testtask'
7
+
2
8
  Bundler::GemHelper.install_tasks
9
+
10
+ RDoc::Task.new(:rdoc) do |rdoc|
11
+ rdoc.rdoc_dir = 'rdoc'
12
+ rdoc.title = 'Serializer'
13
+ rdoc.options << '--line-numbers'
14
+ rdoc.rdoc_files.include('README.rdoc')
15
+ rdoc.rdoc_files.include('lib/**/*.rb')
16
+ end
17
+
18
+ Rake::TestTask.new(:test) do |t|
19
+ t.libs << 'lib'
20
+ t.libs << 'test'
21
+ t.pattern = 'test/**/*_test.rb'
22
+ t.verbose = false
23
+ end
24
+
25
+ task :default => :test
data/lib/serializer.rb CHANGED
@@ -29,14 +29,14 @@ module Serializer
29
29
 
30
30
  define_method "#{method}" do
31
31
  hash = send(name)
32
- result = hash[method.intern] if hash
32
+ result = hash[method.to_sym] if hash
33
33
  return options[:default] if hash.nil? or result.nil?
34
34
  return result
35
35
  end
36
36
 
37
37
  define_method "#{method}?" do
38
38
  hash = send(name)
39
- result = hash[method.intern] if hash
39
+ result = hash[method.to_sym] if hash
40
40
  return options[:default] if hash.nil? or result.nil?
41
41
  return result
42
42
  end
@@ -46,7 +46,7 @@ module Serializer
46
46
  hash = send(name)
47
47
 
48
48
  if options[:type] and value
49
- case options[:type].intern
49
+ case options[:type].to_sym
50
50
  when :float then value = value.to_f if value.respond_to? :to_f
51
51
  when :integer then value = value.to_i if value.respond_to? :to_i
52
52
  when :string then value = value.to_str if value.respond_to? :to_str
@@ -55,7 +55,7 @@ module Serializer
55
55
  end
56
56
  end
57
57
 
58
- send(name)[method.intern] = value
58
+ send(name)[method.to_sym] = value
59
59
  end
60
60
 
61
61
  end
@@ -1,3 +1,3 @@
1
1
  module Serializer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env rake
2
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
3
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
4
+
5
+ require File.expand_path('../config/application', __FILE__)
6
+
7
+ Dummy::Application.load_tasks
@@ -0,0 +1,3 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require_tree .
File without changes
File without changes
@@ -0,0 +1,16 @@
1
+ /*
2
+ *= require_self
3
+ *= require_tree .
4
+ */
5
+
6
+ html, body
7
+ {
8
+ font-family: Helvetica, Verdana, Arial, sans-serif;
9
+ font-style: normal;
10
+ font-weight: normal;
11
+ }
12
+
13
+ .field_with_errors
14
+ {
15
+ display: inline;
16
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,56 @@
1
+ body { background-color: #fff; color: #333; }
2
+
3
+ body, p, ol, ul, td {
4
+ font-family: verdana, arial, helvetica, sans-serif;
5
+ font-size: 13px;
6
+ line-height: 18px;
7
+ }
8
+
9
+ pre {
10
+ background-color: #eee;
11
+ padding: 10px;
12
+ font-size: 11px;
13
+ }
14
+
15
+ a { color: #000; }
16
+ a:visited { color: #666; }
17
+ a:hover { color: #fff; background-color:#000; }
18
+
19
+ div.field, div.actions {
20
+ margin-bottom: 10px;
21
+ }
22
+
23
+ #notice {
24
+ color: green;
25
+ }
26
+
27
+ .field_with_errors {
28
+ padding: 2px;
29
+ background-color: red;
30
+ display: table;
31
+ }
32
+
33
+ #error_explanation {
34
+ width: 450px;
35
+ border: 2px solid red;
36
+ padding: 7px;
37
+ padding-bottom: 0;
38
+ margin-bottom: 20px;
39
+ background-color: #f0f0f0;
40
+ }
41
+
42
+ #error_explanation h2 {
43
+ text-align: left;
44
+ font-weight: bold;
45
+ padding: 5px 5px 5px 15px;
46
+ font-size: 12px;
47
+ margin: -7px;
48
+ margin-bottom: 0px;
49
+ background-color: #c00;
50
+ color: #fff;
51
+ }
52
+
53
+ #error_explanation ul li {
54
+ font-size: 12px;
55
+ list-style: square;
56
+ }
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,10 @@
1
+ class MainController < ApplicationController
2
+
3
+ # GET /
4
+ def index
5
+ respond_to do |format|
6
+ format.html
7
+ end
8
+ end
9
+
10
+ end
@@ -0,0 +1,57 @@
1
+ class UsersController < ApplicationController
2
+
3
+ respond_to :html
4
+
5
+ # GET /users
6
+ def index
7
+ @users = User.all
8
+
9
+ respond_with(@users)
10
+ end
11
+
12
+ # GET /users/:id
13
+ def show
14
+ @user = User.find(params[:id])
15
+
16
+ respond_with(@user)
17
+ end
18
+
19
+ # GET /users/new
20
+ def new
21
+ @user = User.new
22
+
23
+ respond_with(@user)
24
+ end
25
+
26
+ # GET /users/:id/edit
27
+ def edit
28
+ @user = User.find(params[:id])
29
+
30
+ respond_with(@user)
31
+ end
32
+
33
+ # POST /users
34
+ def create
35
+ @user = User.create(params[:user])
36
+
37
+ respond_with(@user)
38
+ end
39
+
40
+ # PUT /users/:id
41
+ def update
42
+ @user = User.find(params[:id])
43
+ @user.attributes = params[:user]
44
+ @user.save
45
+
46
+ respond_with(@user)
47
+ end
48
+
49
+ # DELETE /users/:id
50
+ def destroy
51
+ @user = User.find(params[:id])
52
+ @user.destroy
53
+
54
+ respond_with(@user)
55
+ end
56
+
57
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module MainHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,8 @@
1
+ class User < ActiveRecord::Base
2
+
3
+ has_serialized :settings do |settings|
4
+ settings.define :tw_share, :default => true, :type => :boolean
5
+ settings.define :fb_share, :default => true, :type => :boolean
6
+ end
7
+
8
+ end
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Serializer</title>
5
+ <%= stylesheet_link_tag "application" %>
6
+ <%= javascript_include_tag "application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
@@ -0,0 +1,5 @@
1
+ <h1>Serializer</h1>
2
+
3
+ <ul>
4
+ <li><%= link_to 'Users', users_path %></li>
5
+ </ul>
@@ -0,0 +1,36 @@
1
+ <%= form_for(@user) do |f| %>
2
+
3
+ <% if @user.errors.any? %>
4
+ <p><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</p>
5
+ <ul>
6
+ <% @user.errors.each do |attribute, message| %>
7
+ <li><%= "#{attribute} : #{message}" %></li>
8
+ <% end %>
9
+ </ul>
10
+ <% end %>
11
+
12
+ <div class="field">
13
+ <%= f.label :name, "Name:" %><br />
14
+ <%= f.text_field :name %>
15
+ </div>
16
+
17
+ <div class="field">
18
+ <%= f.label :email, "Email:" %><br />
19
+ <%= f.text_field :email %>
20
+ </div>
21
+
22
+ <div class="field">
23
+ <%= f.check_box :fb_share %>
24
+ <%= f.label :fb_share, "FB Share" %>
25
+ </div>
26
+
27
+ <div class="field">
28
+ <%= f.check_box :tw_share %>
29
+ <%= f.label :tw_share, "TW Share" %>
30
+ </div>
31
+
32
+ <div class="actions">
33
+ <%= f.submit %>
34
+ </div>
35
+
36
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Edit</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @user %>
6
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Index</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Name</th>
6
+ <th>Email</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @users.each do |user| %>
13
+ <tr>
14
+ <td><%= user.name %></td>
15
+ <td><%= user.email %></td>
16
+ <td><%= link_to 'Show', user %></td>
17
+ <td><%= link_to 'Edit', edit_user_path(user) %></td>
18
+ <td><%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New User', new_user_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', users_path %>
@@ -0,0 +1,24 @@
1
+ <h1>Show</h1>
2
+
3
+ <p id="notice"><%= notice %></p>
4
+
5
+ <p>
6
+ <b>Name:</b>
7
+ <%= @user.name %>
8
+ </p>
9
+
10
+ <p>
11
+ <b>Email:</b>
12
+ <%= @user.email %>
13
+ </p>
14
+
15
+ <%- if @user.fb_share? -%>
16
+ <p>FB Share</p>
17
+ <%- end -%>
18
+
19
+ <%- if @user.tw_share? -%>
20
+ <p>TW Share</p>
21
+ <%- end -%>
22
+
23
+ <%= link_to 'Edit', edit_user_path(@user) %>
24
+ <%= link_to 'Back', users_path %>
@@ -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 Dummy::Application
@@ -0,0 +1,45 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ Bundler.require
6
+ require "serializer"
7
+
8
+ module Dummy
9
+ class Application < Rails::Application
10
+ # Settings in config/environments/* take precedence over those specified here.
11
+ # Application configuration should go into files in config/initializers
12
+ # -- all .rb files in that directory are automatically loaded.
13
+
14
+ # Custom directories with classes and modules you want to be autoloadable.
15
+ # config.autoload_paths += %W(#{config.root}/extras)
16
+
17
+ # Only load the plugins named here, in the order given (default is alphabetical).
18
+ # :all can be used as a placeholder for all plugins not explicitly named.
19
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
+
21
+ # Activate observers that should always be running.
22
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
+
24
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
+ # config.time_zone = 'Central Time (US & Canada)'
27
+
28
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
29
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
+ # config.i18n.default_locale = :de
31
+
32
+ # Configure the default encoding used in templates for Ruby 1.9.
33
+ config.encoding = "utf-8"
34
+
35
+ # Configure sensitive parameters which will be filtered from the log file.
36
+ config.filter_parameters += [:password]
37
+
38
+ # Enable the asset pipeline
39
+ config.assets.enabled = true
40
+
41
+ # Version of your assets, change this if you want to expire all your assets
42
+ config.assets.version = '1.0'
43
+ end
44
+ end
45
+