rails3_artifactor 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,9 @@ 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.beta.19"
10
+ gem.add_development_dependency "rspec", "~> 2.0.0"
11
+
12
+ gem.add_dependency "rspec", "~> 2.0.0"
11
13
  gem.add_dependency "require_all", "~> 1.1.0"
12
14
  gem.add_dependency "sugar-high", "~> 0.2.3"
13
15
  gem.add_dependency 'rails3_assist', "~> 0.2.4"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.1.4
@@ -13,6 +13,7 @@ module Rails3::Assist::Artifact
13
13
  end
14
14
 
15
15
  Rails3::Assist.artifacts.each do |name|
16
+ plural_name = name.to_s.pluralize
16
17
  class_eval %{
17
18
  module #{name.to_s.camelize}
18
19
  include Rails3::Assist::BaseHelper
@@ -23,12 +24,13 @@ module Rails3::Assist::Artifact
23
24
  end
24
25
  end
25
26
 
26
- def has_#{name.to_s.pluralize}? *names
27
- names.flatten.each do |name|
27
+ def has_#{plural_name}? *names
28
+ names.to_strings.each do |name|
28
29
  return false if !has_#{name}? name
29
30
  end
30
31
  true
31
32
  end
33
+ alias_method :#{plural_name}_files?, :has_#{plural_name}?
32
34
 
33
35
  def has_#{name}? name, &block
34
36
  begin
@@ -39,6 +41,14 @@ module Rails3::Assist::Artifact
39
41
  yield if block && found
40
42
  found
41
43
  end
44
+ alias_method :has_#{name}_file?, :has_#{name}?
45
+ alias_method :#{name}_file?, :has_#{name}?
46
+
47
+ def #{name}_file name, &block
48
+ found = existing_file_name(name, :#{name}).path
49
+ yield found if block && found
50
+ found
51
+ end
42
52
 
43
53
  def create_#{name} name, options={}, &block
44
54
  create_artifact(name, set(options, :#{name}), &block)
@@ -56,9 +66,24 @@ module Rails3::Assist::Artifact
56
66
  remove_artifact name, :#{name}
57
67
  end
58
68
 
59
- def remove_#{name}s *names
69
+ def remove_#{plural_name} *names
60
70
  remove_artifacts :#{name}, *names
61
- end
71
+ end
72
+
73
+ def remove_all_#{plural_name}
74
+ Rails3::Assist::Artifact::Files.#{name}_files.each{|f| ::File.delete_file! f}
75
+ end
76
+ alias_method :delete_all_#{plural_name}, :remove_all_#{plural_name}
77
+
78
+ def remove_#{plural_name} *names
79
+ return remove_all_#{plural_name} if names.empty?
80
+ names.to_strings.each do |name|
81
+ ::File.delete #{name}_file(name)
82
+ end
83
+ end
84
+ alias_method :delete_#{plural_name}, :remove_#{plural_name}
85
+ alias_method :remove_#{name}, :remove_#{plural_name}
86
+ alias_method :delete_#{name}, :remove_#{plural_name}
62
87
 
63
88
  multi_aliases_for :#{name}
64
89
  end
@@ -1,3 +1,4 @@
1
+ require 'rspec/core'
1
2
  require 'rails3_artifactor/rspec/macro'
2
3
 
3
4
  RSpec.configure do |config|
@@ -1,3 +1,5 @@
1
+ # Rails3::Assist::UseMacro
2
+
1
3
  module Rails3::Assist
2
4
  module UseMacro
3
5
  def use_orm orm
@@ -21,6 +23,10 @@ module Rails3::Assist
21
23
  begin
22
24
  module_name = "Rails3::Assist::#{type.to_s.camelize}"
23
25
  include module_name.constantize
26
+ if [:files, :directory].include? type
27
+ module_name = "Rails3::Assist::Artifact::#{type.to_s.camelize}"
28
+ include module_name.constantize
29
+ end
24
30
  rescue
25
31
  raise ArgumentError, "Unregistered Rails3 assist library: #{type}, #{module_name}"
26
32
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3_artifactor}
8
- s.version = "0.1.3"
8
+ s.version = "0.1.4"
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"]
@@ -55,9 +55,10 @@ Gem::Specification.new do |s|
55
55
  "spec/fixtures/app/helpers/account_helper.rb",
56
56
  "spec/fixtures/app/mailers/account_mailer.rb",
57
57
  "spec/fixtures/app/models/account.rb",
58
+ "spec/fixtures/app/models/account_observer.rb",
58
59
  "spec/fixtures/app/views/account/edit.html.erb",
59
60
  "spec/fixtures/app/views/account/show.html.erb",
60
- "spec/fixtures/db/migrations/20100904095012_create_account.rb",
61
+ "spec/fixtures/db/migrations/20100913162614_create_account.rb",
61
62
  "spec/rails3_artifactor/artifact/base_spec.rb",
62
63
  "spec/rails3_artifactor/artifact/crud/controller_spec.rb",
63
64
  "spec/rails3_artifactor/artifact/crud/helper_spec.rb",
@@ -94,7 +95,8 @@ Gem::Specification.new do |s|
94
95
  "spec/fixtures/app/helpers/account_helper.rb",
95
96
  "spec/fixtures/app/mailers/account_mailer.rb",
96
97
  "spec/fixtures/app/models/account.rb",
97
- "spec/fixtures/db/migrations/20100904095012_create_account.rb",
98
+ "spec/fixtures/app/models/account_observer.rb",
99
+ "spec/fixtures/db/migrations/20100913162614_create_account.rb",
98
100
  "spec/fixtures.rb",
99
101
  "spec/rails3_artifactor/artifact/base_spec.rb",
100
102
  "spec/rails3_artifactor/artifact/crud/controller_spec.rb",
@@ -128,18 +130,21 @@ Gem::Specification.new do |s|
128
130
  s.specification_version = 3
129
131
 
130
132
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
131
- s.add_development_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
133
+ s.add_development_dependency(%q<rspec>, ["~> 2.0.0"])
134
+ s.add_runtime_dependency(%q<rspec>, ["~> 2.0.0"])
132
135
  s.add_runtime_dependency(%q<require_all>, ["~> 1.1.0"])
133
136
  s.add_runtime_dependency(%q<sugar-high>, ["~> 0.2.3"])
134
137
  s.add_runtime_dependency(%q<rails3_assist>, ["~> 0.2.4"])
135
138
  else
136
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
139
+ s.add_dependency(%q<rspec>, ["~> 2.0.0"])
140
+ s.add_dependency(%q<rspec>, ["~> 2.0.0"])
137
141
  s.add_dependency(%q<require_all>, ["~> 1.1.0"])
138
142
  s.add_dependency(%q<sugar-high>, ["~> 0.2.3"])
139
143
  s.add_dependency(%q<rails3_assist>, ["~> 0.2.4"])
140
144
  end
141
145
  else
142
- s.add_dependency(%q<rspec>, ["~> 2.0.0.beta.19"])
146
+ s.add_dependency(%q<rspec>, ["~> 2.0.0"])
147
+ s.add_dependency(%q<rspec>, ["~> 2.0.0"])
143
148
  s.add_dependency(%q<require_all>, ["~> 1.1.0"])
144
149
  s.add_dependency(%q<sugar-high>, ["~> 0.2.3"])
145
150
  s.add_dependency(%q<rails3_assist>, ["~> 0.2.4"])
@@ -1,3 +1,6 @@
1
1
  class AccountHelper
2
- {:type=>:helper, :content=>{:content=>{:type=>:helper, :content=>"\n def index\n end\n "}}}
2
+
3
+ def index
4
+ end
5
+
3
6
  end
@@ -1,6 +1,6 @@
1
1
  class AccountMailer < ActionMailer::Base
2
-
3
- def mail_it
4
- end
5
-
2
+ # goodbye
3
+ # hello
4
+ def mail_it
5
+ end
6
6
  end
@@ -0,0 +1,8 @@
1
+ class AccountObserver < ActiveRecord::Observer
2
+ # goodbye
3
+ # hello
4
+
5
+ def index
6
+ end
7
+
8
+ end
@@ -1,3 +1,4 @@
1
1
  # hello
2
+ # goodbye
2
3
  def index
3
4
  end
@@ -0,0 +1,11 @@
1
+ class CreateAccount < ActiveRecord::Migration
2
+ # goodbye
3
+ # hello
4
+
5
+ def self.up
6
+ end
7
+
8
+ def self.down
9
+ end
10
+
11
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'rspec'
2
- require 'rspec/autorun'
1
+ require 'rspec/core'
2
+ # require 'autotest/rspec2'
3
3
  require 'rails3_artifactor'
4
4
  require 'code-spec'
5
5
  require 'fixtures'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 3
9
- version: 0.1.3
8
+ - 4
9
+ version: 0.1.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -29,15 +29,28 @@ dependencies:
29
29
  - 2
30
30
  - 0
31
31
  - 0
32
- - beta
33
- - 19
34
- version: 2.0.0.beta.19
32
+ version: 2.0.0
35
33
  type: :development
36
34
  version_requirements: *id001
37
35
  - !ruby/object:Gem::Dependency
38
- name: require_all
36
+ name: rspec
39
37
  prerelease: false
40
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ segments:
44
+ - 2
45
+ - 0
46
+ - 0
47
+ version: 2.0.0
48
+ type: :runtime
49
+ version_requirements: *id002
50
+ - !ruby/object:Gem::Dependency
51
+ name: require_all
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
41
54
  none: false
42
55
  requirements:
43
56
  - - ~>
@@ -48,11 +61,11 @@ dependencies:
48
61
  - 0
49
62
  version: 1.1.0
50
63
  type: :runtime
51
- version_requirements: *id002
64
+ version_requirements: *id003
52
65
  - !ruby/object:Gem::Dependency
53
66
  name: sugar-high
54
67
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
56
69
  none: false
57
70
  requirements:
58
71
  - - ~>
@@ -63,11 +76,11 @@ dependencies:
63
76
  - 3
64
77
  version: 0.2.3
65
78
  type: :runtime
66
- version_requirements: *id003
79
+ version_requirements: *id004
67
80
  - !ruby/object:Gem::Dependency
68
81
  name: rails3_assist
69
82
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
71
84
  none: false
72
85
  requirements:
73
86
  - - ~>
@@ -78,7 +91,7 @@ dependencies:
78
91
  - 4
79
92
  version: 0.2.4
80
93
  type: :runtime
81
- version_requirements: *id004
94
+ version_requirements: *id005
82
95
  description: Helpers for handling Rails 3 artifacts in general, such as CRUD operations etc.
83
96
  email: kmandrup@gmail.com
84
97
  executables: []
@@ -127,9 +140,10 @@ files:
127
140
  - spec/fixtures/app/helpers/account_helper.rb
128
141
  - spec/fixtures/app/mailers/account_mailer.rb
129
142
  - spec/fixtures/app/models/account.rb
143
+ - spec/fixtures/app/models/account_observer.rb
130
144
  - spec/fixtures/app/views/account/edit.html.erb
131
145
  - spec/fixtures/app/views/account/show.html.erb
132
- - spec/fixtures/db/migrations/20100904095012_create_account.rb
146
+ - spec/fixtures/db/migrations/20100913162614_create_account.rb
133
147
  - spec/rails3_artifactor/artifact/base_spec.rb
134
148
  - spec/rails3_artifactor/artifact/crud/controller_spec.rb
135
149
  - spec/rails3_artifactor/artifact/crud/helper_spec.rb
@@ -192,7 +206,8 @@ test_files:
192
206
  - spec/fixtures/app/helpers/account_helper.rb
193
207
  - spec/fixtures/app/mailers/account_mailer.rb
194
208
  - spec/fixtures/app/models/account.rb
195
- - spec/fixtures/db/migrations/20100904095012_create_account.rb
209
+ - spec/fixtures/app/models/account_observer.rb
210
+ - spec/fixtures/db/migrations/20100913162614_create_account.rb
196
211
  - spec/fixtures.rb
197
212
  - spec/rails3_artifactor/artifact/base_spec.rb
198
213
  - spec/rails3_artifactor/artifact/crud/controller_spec.rb
@@ -1,4 +0,0 @@
1
- class CreateAccount < ActiveRecord::Migration
2
- # hello
3
- {:type=>:migration, :content=>"\n def self.up\n end\n\n def self.down\n end\n "}
4
- end