formula 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. data/Rakefile +23 -0
  2. data/lib/formula/version.rb +1 -1
  3. data/test/dummy/Rakefile +7 -0
  4. data/test/dummy/app/assets/javascripts/application.js +3 -0
  5. data/test/dummy/app/assets/javascripts/contacts.js +0 -0
  6. data/test/dummy/app/assets/javascripts/main.js +0 -0
  7. data/test/dummy/app/assets/stylesheets/application.css +158 -0
  8. data/test/dummy/app/assets/stylesheets/contacts.css +0 -0
  9. data/test/dummy/app/assets/stylesheets/main.css +0 -0
  10. data/test/dummy/app/controllers/application_controller.rb +3 -0
  11. data/test/dummy/app/controllers/contacts_controller.rb +37 -0
  12. data/test/dummy/app/controllers/main_controller.rb +10 -0
  13. data/test/dummy/app/helpers/application_helper.rb +2 -0
  14. data/test/dummy/app/helpers/contacts_helper.rb +2 -0
  15. data/test/dummy/app/helpers/main_helper.rb +2 -0
  16. data/test/dummy/app/models/contact.rb +17 -0
  17. data/test/dummy/app/models/group.rb +7 -0
  18. data/test/dummy/app/views/contacts/_form.html.erb +19 -0
  19. data/test/dummy/app/views/contacts/edit.html.erb +4 -0
  20. data/test/dummy/app/views/contacts/index.html.erb +27 -0
  21. data/test/dummy/app/views/contacts/new.html.erb +4 -0
  22. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/test/dummy/app/views/main/index.html.erb +9 -0
  24. data/test/dummy/config.ru +4 -0
  25. data/test/dummy/config/application.rb +45 -0
  26. data/test/dummy/config/boot.rb +10 -0
  27. data/test/dummy/config/database.yml +17 -0
  28. data/test/dummy/config/environment.rb +5 -0
  29. data/test/dummy/config/environments/development.rb +30 -0
  30. data/test/dummy/config/environments/production.rb +60 -0
  31. data/test/dummy/config/environments/test.rb +39 -0
  32. data/test/dummy/config/initializers/other.rb +2 -0
  33. data/test/dummy/config/locales/en.yml +1 -0
  34. data/test/dummy/config/routes.rb +6 -0
  35. data/test/dummy/db/development.sqlite3 +0 -0
  36. data/test/dummy/db/migrate/20110109175811_create_contacts.rb +20 -0
  37. data/test/dummy/db/migrate/20110213001348_create_groups.rb +9 -0
  38. data/test/dummy/db/schema.rb +36 -0
  39. data/test/dummy/db/test.sqlite3 +0 -0
  40. data/test/dummy/log/development.log +526 -0
  41. data/test/dummy/log/test.log +56 -0
  42. data/test/dummy/public/favicon.ico +0 -0
  43. data/test/dummy/script/rails +6 -0
  44. data/test/dummy/test/fixtures/contacts.yml +7 -0
  45. data/test/dummy/test/fixtures/contacts/avatar.png +0 -0
  46. data/test/dummy/test/fixtures/groups.yml +5 -0
  47. data/test/dummy/test/functional/contacts_controller_test.rb +42 -0
  48. data/test/dummy/test/functional/main_controller_test.rb +10 -0
  49. data/test/dummy/test/integration/contact_form_test.rb +78 -0
  50. data/test/dummy/test/unit/contact_test.rb +4 -0
  51. data/test/dummy/test/unit/group_test.rb +4 -0
  52. data/test/dummy/test/unit/helpers/contacts_helper_test.rb +4 -0
  53. data/test/dummy/test/unit/helpers/main_helper_test.rb +4 -0
  54. data/test/dummy/tmp/cache/assets/BAB/A00/sprockets%2F347f335128024408181207cbc0461526 +0 -0
  55. data/test/dummy/tmp/cache/assets/C77/F30/sprockets%2F021780432569bfa6c8135d5d4111f2e8 +0 -0
  56. data/test/dummy/tmp/cache/assets/C89/150/sprockets%2F1ff78c0e818b9e0311560396b734719e +0 -0
  57. data/test/dummy/tmp/cache/assets/CE1/BA0/sprockets%2F263ecf6bc5196b70405d900e7c44c946 +0 -0
  58. data/test/dummy/tmp/cache/assets/D06/B40/sprockets%2F25fca4643219052b0d5c66cf2c71f72f +0 -0
  59. data/test/dummy/tmp/cache/assets/D11/430/sprockets%2F25ea8d6063b1eb98361b1196f2fce807 +0 -0
  60. data/test/dummy/tmp/cache/assets/D24/5A0/sprockets%2F3a89b583dd80975d1e0968e730de5bc9 +0 -0
  61. data/test/dummy/tmp/cache/assets/D2D/490/sprockets%2F52514897c01dab621a0d9892aafb1ea2 +0 -0
  62. data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
  63. data/test/dummy/tmp/cache/assets/D54/ED0/sprockets%2F71c9fa01091d432b131da3bb73faf3d4 +0 -0
  64. data/test/dummy/tmp/cache/assets/D84/170/sprockets%2Fd09fc89236193cb0ff9deb09b97c648d +0 -0
  65. data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
  66. data/test/dummy/tmp/cache/assets/DA5/7E0/sprockets%2F87a5f378354ce6e80dda84ab1cfd06f3 +0 -0
  67. data/test/dummy/tmp/cache/assets/DA7/530/sprockets%2Fe36b8fcf5914a3a6bf058abfe7367b19 +0 -0
  68. data/test/dummy/tmp/cache/assets/DAA/470/sprockets%2Faa2b19ddf75cee55d7f2822e3da55779 +0 -0
  69. data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
  70. data/test/dummy/tmp/pids/server.pid +1 -0
  71. data/test/formula_test.rb +7 -0
  72. data/test/test_helper.rb +8 -0
  73. metadata +175 -10
  74. 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 = 'Formula'
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
@@ -1,3 +1,3 @@
1
1
  module Formula
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
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,158 @@
1
+ /*
2
+ *= require_self
3
+ *= require_tree .
4
+ */
5
+
6
+ /* global */
7
+
8
+ html, body
9
+ {
10
+ font-family: Helvetica, Verdana, Arial, sans-serif;
11
+ font-style: normal;
12
+ font-weight: normal;
13
+ }
14
+
15
+ /* grid */
16
+
17
+ .container
18
+ {
19
+ width: 960px;
20
+ margin-left: auto;
21
+ margin-right: auto;
22
+ }
23
+
24
+ .grid-01, .grid-02, .grid-03, .grid-04, .grid-05, .grid-06, .grid-07, .grid-08, .grid-09, .grid-10, .grid-11, .grid-12
25
+ {
26
+ float: left;
27
+ display: inline;
28
+ position: relative;
29
+ margin-left: 10px;
30
+ margin-right: 10px;
31
+ }
32
+
33
+ .alpha { margin-left: 0px; }
34
+ .omega { margin-right: 0px; }
35
+
36
+ .grid-01 { width: 60px; }
37
+ .grid-02 { width: 140px; }
38
+ .grid-03 { width: 220px; }
39
+ .grid-04 { width: 300px; }
40
+ .grid-05 { width: 380px; }
41
+ .grid-06 { width: 460px; }
42
+ .grid-07 { width: 540px; }
43
+ .grid-08 { width: 620px; }
44
+ .grid-09 { width: 700px; }
45
+ .grid-10 { width: 780px; }
46
+ .grid-11 { width: 860px; }
47
+ .grid-12 { width: 940px; }
48
+
49
+ .prefix-01 { padding-left: 80px; }
50
+ .suffix-01 { padding-right: 80px; }
51
+ .prefix-02 { padding-left: 160px; }
52
+ .suffix-02 { padding-right: 160px; }
53
+ .prefix-03 { padding-left: 240px; }
54
+ .suffix-03 { padding-right: 240px; }
55
+ .prefix-04 { padding-left: 320px; }
56
+ .suffix-04 { padding-right: 320px; }
57
+ .prefix-05 { padding-left: 400px; }
58
+ .suffix-05 { padding-right: 400px; }
59
+ .prefix-06 { padding-left: 480px; }
60
+ .suffix-06 { padding-right: 480px; }
61
+ .prefix-07 { padding-left: 560px; }
62
+ .suffix-07 { padding-right: 560px; }
63
+ .prefix-08 { padding-left: 640px; }
64
+ .suffix-08 { padding-right: 640px; }
65
+ .prefix-09 { padding-left: 720px; }
66
+ .suffix-09 { padding-right: 720px; }
67
+ .prefix-10 { padding-left: 800px; }
68
+ .suffix-10 { padding-right: 800px; }
69
+ .prefix-11 { padding-left: 880px; }
70
+ .suffix-11 { padding-right: 880px; }
71
+
72
+ .left { float: left; }
73
+ .right { float: right; }
74
+
75
+ .center { text-align: center; }
76
+ .justify { text-align: justify; }
77
+
78
+ .clear
79
+ {
80
+ clear: both;
81
+ overflow: hidden;
82
+ visibility: hidden;
83
+ height: 0px;
84
+ width: 0px;
85
+ }
86
+
87
+ /* form */
88
+
89
+ .field_with_errors
90
+ {
91
+ display: inline;
92
+ }
93
+
94
+ .input
95
+ {
96
+ padding: 0px;
97
+ }
98
+
99
+ .input.url, .input.text, .input.email, .input.string, .input.phone, .input.password
100
+ {
101
+ padding: 0px 20px 0px 0px;
102
+ }
103
+
104
+ .block
105
+ {
106
+ padding: 4px 0px;
107
+ }
108
+
109
+ .hint
110
+ {
111
+ display: block;
112
+ color: #888;
113
+ margin: 2px 0px;
114
+ padding: 0px;
115
+ font-size: 12px;
116
+ font-weight: normal;
117
+ }
118
+
119
+ .error
120
+ {
121
+ display: block;
122
+ color: #C22;
123
+ margin: 2px 0px;
124
+ padding: 0px;
125
+ font-size: 12px;
126
+ font-weight: bolder;
127
+ }
128
+
129
+ label
130
+ {
131
+ display: inline;
132
+ color: #444;
133
+ margin: 2px 0px;
134
+ padding: 0px;
135
+ font-size: 14px;
136
+ font-weight: normal;
137
+ }
138
+
139
+ input[type="url"],
140
+ input[type="tel"],
141
+ input[type="text"],
142
+ input[type="email"],
143
+ input[type="password"],
144
+ textarea
145
+ {
146
+ width: 100%;
147
+ padding: 8px;
148
+ font-size: 16px;
149
+ font-weight: normal;
150
+ }
151
+
152
+ textarea
153
+ {
154
+ width: 100%;
155
+ padding: 8px;
156
+ font-size: 16px;
157
+ font-weight: normal;d
158
+ }
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ class ApplicationController < ActionController::Base
2
+ protect_from_forgery
3
+ end
@@ -0,0 +1,37 @@
1
+ class ContactsController < ApplicationController
2
+
3
+ respond_to :html
4
+
5
+ # GET /contacts
6
+ def index
7
+ @contacts = Contact.all
8
+ respond_with(@contacts)
9
+ end
10
+
11
+ # GET /contacts/new
12
+ def new
13
+ @contact = Contact.new
14
+ respond_with(@contact)
15
+ end
16
+
17
+ # GET /contacts/:id/edit
18
+ def edit
19
+ @contact = Contact.find(params[:id])
20
+ respond_with(@contact)
21
+ end
22
+
23
+ # POST /contacts
24
+ def create
25
+ @contact = Contact.create(params[:contact])
26
+ respond_with(@contact, :location => contacts_path)
27
+ end
28
+
29
+ # put /contacts
30
+ def update
31
+ @contact = Contact.find(params[:id])
32
+ @contact.attributes = params[:contact]
33
+ @contact.save
34
+ respond_with(@contact, :location => contacts_path)
35
+ end
36
+
37
+ 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,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module ContactsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module MainHelper
2
+ end
@@ -0,0 +1,17 @@
1
+ class Contact < ActiveRecord::Base
2
+
3
+ belongs_to :group
4
+
5
+ validates_presence_of :name
6
+ validates_presence_of :details
7
+ validates_presence_of :email
8
+ validates_presence_of :phone
9
+ validates_presence_of :url
10
+ validates_presence_of :group
11
+
12
+ validates_format_of :email, :with => /\A([^\s]+)@([^\s]+)\Z/i, :message => "is not valid"
13
+ validates_format_of :phone, :with => /\A[0-9\s\(\)\+\-]+\Z/i, :message => "is not valid"
14
+
15
+ has_attached :avatar
16
+
17
+ end
@@ -0,0 +1,7 @@
1
+ class Group < ActiveRecord::Base
2
+
3
+ has_many :contacts
4
+
5
+ validates_presence_of :name
6
+
7
+ end
@@ -0,0 +1,19 @@
1
+ <%= formula_form_for @contact do |form| %>
2
+
3
+ <%= form.input :name, :container => { :class => 'grid-12' }, :hint => "first and last name" %>
4
+
5
+ <%= form.input :details, :container => { :class => 'grid-12' }, :hint => "a detailed description" %>
6
+
7
+ <%= form.input :email, :container => { :class => 'grid-06' }, :hint => "sample@example.com" %>
8
+ <%= form.input :phone, :container => { :class => 'grid-06' }, :hint => "+01 (555) 555-5555" %>
9
+
10
+ <%= form.input :url, :label => "Website", :container => { :class => 'grid-12' }, :hint => "http://example.com/" %>
11
+
12
+ <%= form.input :avatar, :container => { :class => 'grid-12' } %>
13
+
14
+ <%= form.association :group, Group.all, :id, :name, :container => { :class => 'grid-12' },
15
+ :association => { :prompt => "-- Group --", :html => { :class => 'group' } } %>
16
+
17
+ <%= form.button 'Save', :container => { :class => 'grid-12' } %>
18
+
19
+ <% end %>
@@ -0,0 +1,4 @@
1
+ <div class="container">
2
+ <div class="grid-12"><h1>Edit</h1></div>
3
+ <%= render 'form' %>
4
+ </div>
@@ -0,0 +1,27 @@
1
+ <div class="container">
2
+ <div class="grid-12">
3
+
4
+ <h1>Contacts</h1>
5
+
6
+ <table>
7
+ <tr>
8
+ <th>Name</th>
9
+ <th></th>
10
+ <th></th>
11
+ </tr>
12
+
13
+ <% @contacts.each do |contact| %>
14
+ <tr>
15
+ <td><%= contact.name %></td>
16
+ <td><%= link_to 'Edit', edit_contact_path(contact) %></td>
17
+ <td><%= link_to 'Destroy', contact, :confirm => 'Are you sure?', :method => :delete %></td>
18
+ </tr>
19
+ <% end %>
20
+ </table>
21
+
22
+ <br />
23
+
24
+ <%= link_to 'New', new_contact_path %>
25
+
26
+ </div>
27
+ </div>
@@ -0,0 +1,4 @@
1
+ <div class="container">
2
+ <div class="grid-12"><h1>Edit</h1></div>
3
+ <%= render 'form' %>
4
+ </div>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Formula</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,9 @@
1
+ <div class="container">
2
+
3
+ <h1 class="grid-12">Formula</h1>
4
+
5
+ <ul class="grid-12">
6
+ <li><%= link_to 'Contacts', contacts_path %></li>
7
+ </ul>
8
+
9
+ </div>
@@ -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 "formula"
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
+