induction_cannon_01 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -3,7 +3,9 @@ source 'http://rubygems.org'
3
3
  gem 'rails', '3.0.5'
4
4
 
5
5
  gem 'mysql2'
6
- gem 'dragoon_system', :git => "git@github.com:toward7seas01/dragoon_system.git"
6
+ #gem 'dragoon_system', :git => "git@github.com:toward7seas01/dragoon_system.git"
7
+ #gem 'dragoon_system', :path => '~/dragoon_system'
8
+ gem 'dragoon_system', "0.1.3"
7
9
 
8
10
 
9
11
  group :development do
data/Gemfile.lock CHANGED
@@ -1,10 +1,3 @@
1
- GIT
2
- remote: git@github.com:toward7seas01/dragoon_system.git
3
- revision: 5cd9f705c69e646f065f4c46a346229a83bea422
4
- specs:
5
- dragoon_system (0.1.2)
6
- rails (~> 3.0.5)
7
-
8
1
  GEM
9
2
  remote: http://rubygems.org/
10
3
  specs:
@@ -62,6 +55,8 @@ GEM
62
55
  culerity (0.2.12)
63
56
  database_cleaner (0.6.0)
64
57
  diff-lcs (1.1.2)
58
+ dragoon_system (0.1.3)
59
+ rails (~> 3.0.5)
65
60
  erubis (2.6.6)
66
61
  abstract (>= 1.0.0)
67
62
  ffi (0.6.3)
@@ -148,7 +143,7 @@ DEPENDENCIES
148
143
  capybara (~> 0.4.0)
149
144
  cucumber-rails
150
145
  database_cleaner (~> 0.6.0)
151
- dragoon_system!
146
+ dragoon_system (= 0.1.3)
152
147
  jeweler (~> 1.5.1)
153
148
  launchy
154
149
  mysql2
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -1,3 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+
3
4
  end
@@ -0,0 +1,83 @@
1
+ class BlogsController < ApplicationController
2
+ # GET /blogs
3
+ # GET /blogs.xml
4
+ def index
5
+ @blogs = Blog.all
6
+
7
+ respond_to do |format|
8
+ format.html # index.html.erb
9
+ format.xml { render :xml => @blogs }
10
+ end
11
+ end
12
+
13
+ # GET /blogs/1
14
+ # GET /blogs/1.xml
15
+ def show
16
+ @blog = Blog.find(params[:id])
17
+
18
+ respond_to do |format|
19
+ format.html # show.html.erb
20
+ format.xml { render :xml => @blog }
21
+ end
22
+ end
23
+
24
+ # GET /blogs/new
25
+ # GET /blogs/new.xml
26
+ def new
27
+ @blog = Blog.new
28
+
29
+ respond_to do |format|
30
+ format.html # new.html.erb
31
+ format.xml { render :xml => @blog }
32
+ end
33
+ end
34
+
35
+ # GET /blogs/1/edit
36
+ def edit
37
+ @blog = Blog.find(params[:id])
38
+ end
39
+
40
+ # POST /blogs
41
+ # POST /blogs.xml
42
+ def create
43
+ @blog = Blog.new(params[:blog])
44
+
45
+ respond_to do |format|
46
+ if @blog.save
47
+ format.html { redirect_to(@blog, :notice => 'Blog was successfully created.') }
48
+ format.xml { render :xml => @blog, :status => :created, :location => @blog }
49
+ else
50
+ format.html { render :action => "new" }
51
+ format.xml { render :xml => @blog.errors, :status => :unprocessable_entity }
52
+ end
53
+ end
54
+ end
55
+
56
+ # PUT /blogs/1
57
+ # PUT /blogs/1.xml
58
+ def update
59
+ @blog = Blog.find(params[:id])
60
+
61
+ respond_to do |format|
62
+ if @blog.update_attributes(params[:blog])
63
+ format.html { redirect_to(@blog, :notice => 'Blog was successfully updated.') }
64
+ format.xml { head :ok }
65
+ else
66
+ format.html { render :action => "edit" }
67
+ format.xml { render :xml => @blog.errors, :status => :unprocessable_entity }
68
+ end
69
+ end
70
+ end
71
+
72
+ # DELETE /blogs/1
73
+ # DELETE /blogs/1.xml
74
+ def destroy
75
+ @blog = Blog.find(params[:id])
76
+ @blog.destroy
77
+
78
+ respond_to do |format|
79
+ format.html { redirect_to(blogs_url) }
80
+ format.xml { head :ok }
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,2 @@
1
+ module BlogsHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ class Blog < ActiveRecord::Base
2
+ belongs_to :user
3
+ end
data/app/models/user.rb CHANGED
@@ -1,2 +1,3 @@
1
1
  class User < ActiveRecord::Base
2
+ has_many :blogs
2
3
  end
@@ -0,0 +1,25 @@
1
+ <%= form_for(@blog) do |f| %>
2
+ <% if @blog.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@blog.errors.count, "error") %> prohibited this blog from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @blog.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :title %><br />
16
+ <%= f.text_field :title %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :content %><br />
20
+ <%= f.text_area :content %>
21
+ </div>
22
+ <div class="actions">
23
+ <%= f.submit %>
24
+ </div>
25
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing blog</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @blog %> |
6
+ <%= link_to 'Back', blogs_path %>
@@ -0,0 +1,25 @@
1
+ <h1>Listing blogs</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Title</th>
6
+ <th>Content</th>
7
+ <th></th>
8
+ <th></th>
9
+ <th></th>
10
+ </tr>
11
+
12
+ <% @blogs.each do |blog| %>
13
+ <tr>
14
+ <td><%= blog.title %></td>
15
+ <td><%= blog.content %></td>
16
+ <td><%= link_to 'Show', blog %></td>
17
+ <td><%= link_to 'Edit', edit_blog_path(blog) %></td>
18
+ <td><%= link_to 'Destroy', blog, :confirm => 'Are you sure?', :method => :delete %></td>
19
+ </tr>
20
+ <% end %>
21
+ </table>
22
+
23
+ <br />
24
+
25
+ <%= link_to 'New Blog', new_blog_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New blog</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', blogs_path %>
@@ -0,0 +1,15 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Title:</b>
5
+ <%= @blog.title %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Content:</b>
10
+ <%= @blog.content %>
11
+ </p>
12
+
13
+
14
+ <%= link_to 'Edit', edit_blog_path(@blog) %> |
15
+ <%= link_to 'Back', blogs_path %>
data/config/routes.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  InductionCannon01::Application.routes.draw do
2
+ resources :blogs
3
+
2
4
  resources :users
3
5
 
4
6
  # The priority is based upon order of creation:
@@ -0,0 +1,14 @@
1
+ class CreateBlogs < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :blogs do |t|
4
+ t.string :title
5
+ t.text :content
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :blogs
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ class AddUserIdToBlogs < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :blogs, :user_id, :integer
4
+ end
5
+
6
+ def self.down
7
+ remove_column :blogs, :user_id
8
+ end
9
+ end
data/db/schema.rb CHANGED
@@ -10,7 +10,15 @@
10
10
  #
11
11
  # It's strongly recommended to check this file into your version control system.
12
12
 
13
- ActiveRecord::Schema.define(:version => 20110301055018) do
13
+ ActiveRecord::Schema.define(:version => 20110302024844) do
14
+
15
+ create_table "blogs", :force => true do |t|
16
+ t.string "title"
17
+ t.text "content"
18
+ t.datetime "created_at"
19
+ t.datetime "updated_at"
20
+ t.integer "user_id"
21
+ end
14
22
 
15
23
  create_table "users", :force => true do |t|
16
24
  t.string "name"
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{induction_cannon_01}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["zhanyinan"]
@@ -28,10 +28,18 @@ Gem::Specification.new do |s|
28
28
  "Rakefile",
29
29
  "VERSION",
30
30
  "app/controllers/application_controller.rb",
31
+ "app/controllers/blogs_controller.rb",
31
32
  "app/controllers/users_controller.rb",
32
33
  "app/helpers/application_helper.rb",
34
+ "app/helpers/blogs_helper.rb",
33
35
  "app/helpers/users_helper.rb",
36
+ "app/models/blog.rb",
34
37
  "app/models/user.rb",
38
+ "app/views/blogs/_form.html.erb",
39
+ "app/views/blogs/edit.html.erb",
40
+ "app/views/blogs/index.html.erb",
41
+ "app/views/blogs/new.html.erb",
42
+ "app/views/blogs/show.html.erb",
35
43
  "app/views/layouts/application.html.erb",
36
44
  "app/views/users/_form.html.erb",
37
45
  "app/views/users/edit.html.erb",
@@ -54,12 +62,15 @@ Gem::Specification.new do |s|
54
62
  "config/locales/en.yml",
55
63
  "config/routes.rb",
56
64
  "db/migrate/20110301055018_create_users.rb",
65
+ "db/migrate/20110302022059_create_blogs.rb",
66
+ "db/migrate/20110302024844_add_user_id_to_blogs.rb",
57
67
  "db/schema.rb",
58
68
  "db/seeds.rb",
59
69
  "doc/README_FOR_APP",
60
70
  "induction_cannon_01.gemspec",
61
71
  "lib/induction_cannon_01.rb",
62
72
  "lib/tasks/.gitkeep",
73
+ "pkg/induction_cannon_01-0.0.1.gem",
63
74
  "public/404.html",
64
75
  "public/422.html",
65
76
  "public/500.html",
@@ -76,6 +87,7 @@ Gem::Specification.new do |s|
76
87
  "public/stylesheets/.gitkeep",
77
88
  "public/stylesheets/scaffold.css",
78
89
  "script/rails",
90
+ "spec/models/extra_spec.rb",
79
91
  "spec/models/user_spec.rb",
80
92
  "spec/spec_helper.rb",
81
93
  "vendor/plugins/.gitkeep"
@@ -86,6 +98,7 @@ Gem::Specification.new do |s|
86
98
  s.rubygems_version = %q{1.5.2}
87
99
  s.summary = %q{personal suit, base on dragoon_system}
88
100
  s.test_files = [
101
+ "spec/models/extra_spec.rb",
89
102
  "spec/models/user_spec.rb",
90
103
  "spec/spec_helper.rb"
91
104
  ]
@@ -96,7 +109,7 @@ Gem::Specification.new do |s|
96
109
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
97
110
  s.add_runtime_dependency(%q<rails>, ["= 3.0.5"])
98
111
  s.add_runtime_dependency(%q<mysql2>, [">= 0"])
99
- s.add_runtime_dependency(%q<dragoon_system>, [">= 0"])
112
+ s.add_runtime_dependency(%q<dragoon_system>, ["= 0.1.3"])
100
113
  s.add_development_dependency(%q<bundler>, ["~> 1.0.10"])
101
114
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
102
115
  s.add_development_dependency(%q<rspec-rails>, ["~> 2.5.0"])
@@ -104,7 +117,7 @@ Gem::Specification.new do |s|
104
117
  else
105
118
  s.add_dependency(%q<rails>, ["= 3.0.5"])
106
119
  s.add_dependency(%q<mysql2>, [">= 0"])
107
- s.add_dependency(%q<dragoon_system>, [">= 0"])
120
+ s.add_dependency(%q<dragoon_system>, ["= 0.1.3"])
108
121
  s.add_dependency(%q<bundler>, ["~> 1.0.10"])
109
122
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
110
123
  s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
@@ -113,7 +126,7 @@ Gem::Specification.new do |s|
113
126
  else
114
127
  s.add_dependency(%q<rails>, ["= 3.0.5"])
115
128
  s.add_dependency(%q<mysql2>, [">= 0"])
116
- s.add_dependency(%q<dragoon_system>, [">= 0"])
129
+ s.add_dependency(%q<dragoon_system>, ["= 0.1.3"])
117
130
  s.add_dependency(%q<bundler>, ["~> 1.0.10"])
118
131
  s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
119
132
  s.add_dependency(%q<rspec-rails>, ["~> 2.5.0"])
Binary file
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe User do
4
+ it 'helper' do
5
+ user = User.new
6
+ helpers = user.send(:helpers)
7
+ helpers.send(:link_to, "cool", "/").should == "<a href=\"/\">cool</a>"
8
+
9
+ end
10
+ end
@@ -1,14 +1,72 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe User do
4
- it 'regexp' do
5
- user1 = User.create(:info => "cool")
6
- user2 = User.create(:info => "hello")
4
+ describe 'regexp' do
5
+ it '01' do
6
+ user1 = User.create(:info => "cool")
7
+ user2 = User.create(:info => "hello")
7
8
 
8
- result = User.regexp(:info, "ll")
9
+ result = User.regexp(:info, "ll")
9
10
 
10
- result.should have(1).user
11
- result.first.should == user2
11
+ result.should have(1).user
12
+ result.first.should == user2
12
13
 
14
+ end
15
+
16
+ it '02' do
17
+ User.create(:info => "cool")
18
+ User.create(:info => "hello")
19
+
20
+ result = User.regexp(:info, "olo")
21
+
22
+ result.should have(0).user
23
+ end
13
24
  end
25
+
26
+ describe 'fuzzy search' do
27
+ it '01' do
28
+ user1 = User.create(:info => "cool")
29
+ user2 = User.create(:info => "hello")
30
+
31
+ result = User.fuzzy(User => {:info => "ll"})
32
+ result.should have(1).user
33
+ result.first.should == user2
34
+
35
+ end
36
+
37
+ it '02' do
38
+ User.create(:info => "cool")
39
+ User.create(:info => "hello")
40
+
41
+ result = User.fuzzy(User => {:info => "olo"})
42
+ result.should have(0).user
43
+
44
+ end
45
+
46
+ it '03' do
47
+ User.create(:info => "cool")
48
+ User.create(:info => "hello")
49
+
50
+ result = User.fuzzy(User => {:info => "l"})
51
+
52
+ User.all.should have(2).user
53
+ result.should have(2).user
54
+ end
55
+
56
+ it '04' do
57
+ user = User.create(:info => "cool")
58
+ User.create(:info => "hello")
59
+ user.blogs.create(:title => "yeah")
60
+
61
+ result = User.includes(:blogs).fuzzy(User => {:info => "lll"}, Blog => {:title => "y"})
62
+
63
+ result.should have(1).user
64
+ end
65
+
66
+
67
+
68
+
69
+ end
70
+
71
+
14
72
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: induction_cannon_01
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - zhanyinan
@@ -53,12 +53,14 @@ dependencies:
53
53
  version_requirements: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
- - - ">="
56
+ - - "="
57
57
  - !ruby/object:Gem::Version
58
- hash: 3
58
+ hash: 29
59
59
  segments:
60
60
  - 0
61
- version: "0"
61
+ - 1
62
+ - 3
63
+ version: 0.1.3
62
64
  prerelease: false
63
65
  type: :runtime
64
66
  requirement: *id003
@@ -145,10 +147,18 @@ files:
145
147
  - Rakefile
146
148
  - VERSION
147
149
  - app/controllers/application_controller.rb
150
+ - app/controllers/blogs_controller.rb
148
151
  - app/controllers/users_controller.rb
149
152
  - app/helpers/application_helper.rb
153
+ - app/helpers/blogs_helper.rb
150
154
  - app/helpers/users_helper.rb
155
+ - app/models/blog.rb
151
156
  - app/models/user.rb
157
+ - app/views/blogs/_form.html.erb
158
+ - app/views/blogs/edit.html.erb
159
+ - app/views/blogs/index.html.erb
160
+ - app/views/blogs/new.html.erb
161
+ - app/views/blogs/show.html.erb
152
162
  - app/views/layouts/application.html.erb
153
163
  - app/views/users/_form.html.erb
154
164
  - app/views/users/edit.html.erb
@@ -171,12 +181,15 @@ files:
171
181
  - config/locales/en.yml
172
182
  - config/routes.rb
173
183
  - db/migrate/20110301055018_create_users.rb
184
+ - db/migrate/20110302022059_create_blogs.rb
185
+ - db/migrate/20110302024844_add_user_id_to_blogs.rb
174
186
  - db/schema.rb
175
187
  - db/seeds.rb
176
188
  - doc/README_FOR_APP
177
189
  - induction_cannon_01.gemspec
178
190
  - lib/induction_cannon_01.rb
179
191
  - lib/tasks/.gitkeep
192
+ - pkg/induction_cannon_01-0.0.1.gem
180
193
  - public/404.html
181
194
  - public/422.html
182
195
  - public/500.html
@@ -193,6 +206,7 @@ files:
193
206
  - public/stylesheets/.gitkeep
194
207
  - public/stylesheets/scaffold.css
195
208
  - script/rails
209
+ - spec/models/extra_spec.rb
196
210
  - spec/models/user_spec.rb
197
211
  - spec/spec_helper.rb
198
212
  - vendor/plugins/.gitkeep
@@ -231,5 +245,6 @@ signing_key:
231
245
  specification_version: 3
232
246
  summary: personal suit, base on dragoon_system
233
247
  test_files:
248
+ - spec/models/extra_spec.rb
234
249
  - spec/models/user_spec.rb
235
250
  - spec/spec_helper.rb