rails3_artifactor 0.2.8 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,12 +7,12 @@ begin
7
7
  gem.email = "kmandrup@gmail.com"
8
8
  gem.homepage = "http://github.com/kristianmandrup/rails3_artifact_helper"
9
9
  gem.authors = ["Kristian Mandrup"]
10
- gem.add_development_dependency "rspec", ">= 2.0.0.rc"
10
+ gem.add_development_dependency "rspec", ">= 2.0"
11
11
 
12
- gem.add_dependency "rspec", ">= 2.0.0.rc"
12
+ gem.add_dependency "rspec", ">= 2.0.0"
13
13
  gem.add_dependency "require_all", "~> 1.2.0"
14
- gem.add_dependency "sugar-high", "~> 0.2.10"
15
- gem.add_dependency 'rails3_assist', "~> 0.2.10"
14
+ gem.add_dependency "sugar-high", "~> 0.3.0"
15
+ gem.add_dependency 'rails3_assist', "~> 0.3.0"
16
16
  gem.add_dependency 'migration_assist', "~> 0.1.4"
17
17
 
18
18
  # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.8
1
+ 0.3.0
@@ -5,15 +5,15 @@ module Rails3::Assist::Artifact
5
5
 
6
6
  module Helper
7
7
  def default_template_lang
8
- 'erb.html'
8
+ get_type :erb
9
9
  end
10
10
 
11
11
  def get_type type
12
12
  case type.to_s
13
13
  when 'erb'
14
- 'erb.html'
14
+ 'html.erb'
15
15
  when 'haml'
16
- 'haml.html'
16
+ 'html.haml'
17
17
  else
18
18
  type
19
19
  end
@@ -32,7 +32,6 @@ module Rails3::Assist::Artifact
32
32
  end
33
33
  end
34
34
 
35
- # TODO: Refactor all code below to make much more DRY !!!
36
35
  def view_file_name *args
37
36
  folder, action, type = get_view_args(args)
38
37
  File.expand_path File.join(DIR.view_dir, folder.to_s, "#{action}.#{type}")
@@ -45,7 +44,7 @@ module Rails3::Assist::Artifact
45
44
  when 1
46
45
  SingleArg.get_view_args *args
47
46
  else
48
- SingleArg.get_view_args *args
47
+ TwoArgs.get_view_args *args
49
48
  end
50
49
  end
51
50
  end
@@ -80,11 +79,20 @@ module Rails3::Assist::Artifact
80
79
 
81
80
  module HashArgs
82
81
  extend Rails3::Assist::Artifact::View::FileName::Helper
82
+
83
+ DIR = Rails3::Assist::Artifact::Directory
83
84
 
84
85
  # view_file(:folder => 'person', :action => :show, :type => :erb).should == /views\/person\/show\.html\.erb/
85
- def self.get_view_args hash
86
- folder = hash[:folder]
87
- action = hash[:action]
86
+ def self.get_view_args hash
87
+ try_folder = hash.keys.first
88
+ try_view_folder = File.expand_path(File.join(DIR.view_dir, try_folder.to_s))
89
+ if File.directory? try_view_folder
90
+ folder = try_folder
91
+ action = hash.values.first
92
+ else
93
+ folder = hash[:folder]
94
+ action = hash[:action]
95
+ end
88
96
  type = get_view_type(hash[:type])
89
97
  [folder, action, type]
90
98
  end
@@ -110,7 +118,7 @@ module Rails3::Assist::Artifact
110
118
  def self.get_view_args *args
111
119
  args = args.flatten
112
120
  arg2 = args[1]
113
- case arg2
121
+ res = case arg2
114
122
  when String, Symbol
115
123
  # view_file(:person, :show).should == /views\/person\/show\.html\.erb/
116
124
  # view_file('person/admin', :show, :type => :erb).should == /views\/person\/show\.html\.erb/
@@ -130,7 +138,7 @@ module Rails3::Assist::Artifact
130
138
  args = args.flatten
131
139
  folder = args.first.to_s
132
140
  action = args[1].to_s
133
- hash = args[2] if args.size > 2
141
+ hash = args[2] if args.size > 2
134
142
  type = get_view_type(hash ? hash[:type] : nil)
135
143
  [folder, action, type]
136
144
  end
@@ -16,13 +16,13 @@ module Rails3::Assist::Artifact
16
16
  true
17
17
  end
18
18
 
19
- def view_file name, *args
20
- view_file_name(name, args)
19
+ def view_file *args
20
+ view_file_name(args)
21
21
  end
22
22
 
23
23
  # CREATE
24
- def create_view name, *args, &block
25
- file_name = view_file_name(name, args)
24
+ def create_view *args, &block
25
+ file_name = view_file_name(args)
26
26
  dir = File.dirname(file_name)
27
27
  FileUtils.mkdir_p dir if !File.directory?(dir)
28
28
 
@@ -40,8 +40,8 @@ module Rails3::Assist::Artifact
40
40
  end
41
41
 
42
42
  # READ
43
- def read_view name, *args, &block
44
- file_name = view_file_name(name, args)
43
+ def read_view *args, &block
44
+ file_name = view_file_name(args)
45
45
  debug "reading from: #{file_name}"
46
46
  begin
47
47
  file = File.new(file_name)
@@ -69,8 +69,8 @@ module Rails3::Assist::Artifact
69
69
  end
70
70
 
71
71
  # DELETE
72
- def remove_view name, *args
73
- file = view_file_name(name, args)
72
+ def remove_view *args
73
+ file = view_file_name(args)
74
74
  FileUtils.rm_f(file) if File.exist?(file)
75
75
  end
76
76
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3_artifactor}
8
- s.version = "0.2.8"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kristian Mandrup"]
12
- s.date = %q{2010-10-07}
12
+ s.date = %q{2010-10-21}
13
13
  s.description = %q{Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -60,6 +60,8 @@ Gem::Specification.new do |s|
60
60
  "spec/fixtures.rb",
61
61
  "spec/fixtures/app/views/account/edit.erb.html",
62
62
  "spec/fixtures/app/views/account/edit.html.erb",
63
+ "spec/fixtures/app/views/layouts/application.erb.html",
64
+ "spec/fixtures/app/views/layouts/application.html.erb",
63
65
  "spec/rails3_artifactor/artifact/base_spec.rb",
64
66
  "spec/rails3_artifactor/artifact/crud/controller_spec.rb",
65
67
  "spec/rails3_artifactor/artifact/crud/helper_spec.rb",
@@ -129,26 +131,26 @@ Gem::Specification.new do |s|
129
131
  s.specification_version = 3
130
132
 
131
133
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
132
- s.add_development_dependency(%q<rspec>, [">= 2.0.0.rc"])
133
- s.add_runtime_dependency(%q<rspec>, [">= 2.0.0.rc"])
134
+ s.add_development_dependency(%q<rspec>, [">= 2.0"])
135
+ s.add_runtime_dependency(%q<rspec>, [">= 2.0.0"])
134
136
  s.add_runtime_dependency(%q<require_all>, ["~> 1.2.0"])
135
- s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.10"])
136
- s.add_runtime_dependency(%q<rails3_assist>, ["~> 0.2.10"])
137
+ s.add_runtime_dependency(%q<sugar-high>, ["~> 0.3.0"])
138
+ s.add_runtime_dependency(%q<rails3_assist>, ["~> 0.3.0"])
137
139
  s.add_runtime_dependency(%q<migration_assist>, ["~> 0.1.4"])
138
140
  else
139
- s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
140
- s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
141
+ s.add_dependency(%q<rspec>, [">= 2.0"])
142
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
141
143
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
142
- s.add_dependency(%q<sugar-high>, ["~> 0.2.10"])
143
- s.add_dependency(%q<rails3_assist>, ["~> 0.2.10"])
144
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
145
+ s.add_dependency(%q<rails3_assist>, ["~> 0.3.0"])
144
146
  s.add_dependency(%q<migration_assist>, ["~> 0.1.4"])
145
147
  end
146
148
  else
147
- s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
148
- s.add_dependency(%q<rspec>, [">= 2.0.0.rc"])
149
+ s.add_dependency(%q<rspec>, [">= 2.0"])
150
+ s.add_dependency(%q<rspec>, [">= 2.0.0"])
149
151
  s.add_dependency(%q<require_all>, ["~> 1.2.0"])
150
- s.add_dependency(%q<sugar-high>, ["~> 0.2.10"])
151
- s.add_dependency(%q<rails3_assist>, ["~> 0.2.10"])
152
+ s.add_dependency(%q<sugar-high>, ["~> 0.3.0"])
153
+ s.add_dependency(%q<rails3_assist>, ["~> 0.3.0"])
152
154
  s.add_dependency(%q<migration_assist>, ["~> 0.1.4"])
153
155
  end
154
156
  end
@@ -0,0 +1,3 @@
1
+
2
+ app layout
3
+
@@ -0,0 +1,16 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <title>App Layout</title>
6
+ <%= stylesheet_link_tag :all %>
7
+ <%= javascript_include_tag :defaults %>
8
+ <%= csrf_meta_tag %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
16
+
@@ -12,6 +12,25 @@ describe 'view API - symbols' do
12
12
  <h1><%= title %></h1>
13
13
  }
14
14
  end
15
+
16
+ create_view :layouts, :application do
17
+ %q{
18
+ <!DOCTYPE html>
19
+ <html>
20
+ <head>
21
+ <title>App Layout</title>
22
+ <%= stylesheet_link_tag :all %>
23
+ <%= javascript_include_tag :defaults %>
24
+ <%= csrf_meta_tag %>
25
+ </head>
26
+ <body>
27
+
28
+ <%= yield %>
29
+
30
+ </body>
31
+ </html>
32
+ }
33
+ end
15
34
  end
16
35
 
17
36
  after :each do
@@ -20,11 +39,24 @@ describe 'view API - symbols' do
20
39
 
21
40
  context "Non-existant view(s)" do
22
41
 
42
+ it "should read application layouts view" do
43
+ view_file_name(:layouts => :application).should match /html\.erb/
44
+ read_view(:layouts => :application).should match /App Layout/
45
+ read_view(:layouts, :application).should match /App Layout/
46
+ end
47
+
48
+ it "should insert into application layouts view" do
49
+ insert_into_view :layouts => :application, :after => '<body>' do
50
+ %Q{<p class="alert"><%= alert %></p>}
51
+ end
52
+ read_view(:layouts, :application).should match /<%= alert %>/
53
+ end
54
+
23
55
  it "should not fail trying to remove non-existant views" do
24
56
  remove_views :edit, :show, :folder => :person
25
57
  remove_artifacts :view, :edit, :show, :folder => :person
26
58
 
27
- remove_view :show, :folder => :person
59
+ remove_view :person => :show
28
60
  remove_artifact :view, :show, :folder => :person
29
61
  end
30
62
 
@@ -42,7 +74,7 @@ describe 'view API - symbols' do
42
74
  end
43
75
 
44
76
  it "should not read from non-existant view" do
45
- read_view :show, :folder => :person do |content|
77
+ read_view :person => :show do |content|
46
78
  fail "should not find person content!"
47
79
  end.should_not be_true
48
80
  end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 8
9
- version: 0.2.8
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-07 00:00:00 +02:00
17
+ date: 2010-10-21 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -28,9 +28,7 @@ dependencies:
28
28
  segments:
29
29
  - 2
30
30
  - 0
31
- - 0
32
- - rc
33
- version: 2.0.0.rc
31
+ version: "2.0"
34
32
  type: :development
35
33
  version_requirements: *id001
36
34
  - !ruby/object:Gem::Dependency
@@ -45,8 +43,7 @@ dependencies:
45
43
  - 2
46
44
  - 0
47
45
  - 0
48
- - rc
49
- version: 2.0.0.rc
46
+ version: 2.0.0
50
47
  type: :runtime
51
48
  version_requirements: *id002
52
49
  - !ruby/object:Gem::Dependency
@@ -74,9 +71,9 @@ dependencies:
74
71
  - !ruby/object:Gem::Version
75
72
  segments:
76
73
  - 0
77
- - 2
78
- - 10
79
- version: 0.2.10
74
+ - 3
75
+ - 0
76
+ version: 0.3.0
80
77
  type: :runtime
81
78
  version_requirements: *id004
82
79
  - !ruby/object:Gem::Dependency
@@ -89,9 +86,9 @@ dependencies:
89
86
  - !ruby/object:Gem::Version
90
87
  segments:
91
88
  - 0
92
- - 2
93
- - 10
94
- version: 0.2.10
89
+ - 3
90
+ - 0
91
+ version: 0.3.0
95
92
  type: :runtime
96
93
  version_requirements: *id005
97
94
  - !ruby/object:Gem::Dependency
@@ -162,6 +159,8 @@ files:
162
159
  - spec/fixtures.rb
163
160
  - spec/fixtures/app/views/account/edit.erb.html
164
161
  - spec/fixtures/app/views/account/edit.html.erb
162
+ - spec/fixtures/app/views/layouts/application.erb.html
163
+ - spec/fixtures/app/views/layouts/application.html.erb
165
164
  - spec/rails3_artifactor/artifact/base_spec.rb
166
165
  - spec/rails3_artifactor/artifact/crud/controller_spec.rb
167
166
  - spec/rails3_artifactor/artifact/crud/helper_spec.rb