rails3_assist 0.3.3 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.3
1
+ 0.3.4
@@ -4,8 +4,8 @@ module Rails3::Assist::File
4
4
  module Application
5
5
  module Methods
6
6
  def insert_application_config statement=nil, &block
7
- statement = block ? yield : "config.#{statement}"
8
- File.insert_into application_file, statement, :after => 'Rails::Application', &block
7
+ statement = block ? yield : "config.#{statement}"
8
+ File.insert_into application_file, statement, :after => 'Rails::Application'
9
9
  end
10
10
  end
11
11
  include Methods
@@ -9,6 +9,7 @@ module Rails3::Assist::File
9
9
  end
10
10
 
11
11
  def insert_application_init place, statement=nil, &block
12
+ statement = block ? yield : statement
12
13
  File.insert_into environment_file, statement, place => /\w+::Application.initialize!/
13
14
  end
14
15
  end
@@ -36,6 +36,11 @@ module Rails3::Assist::File
36
36
  clean_gemfile_content = read_gem_file.gsub(/('|"|end)\s*gem/m, "\\1\ngem")
37
37
  File.open(gem_file, 'w') {|f| f.write(clean_gemfile_content) }
38
38
  end
39
+
40
+ def insert_into_routes route_stmt=nil, &block
41
+ statement = block ? yield : route_stmt
42
+ File.insert_into routes_file, route_stmt, :after => 'Application.routes.draw do'
43
+ end
39
44
 
40
45
  # read_application_file
41
46
  # append_to_application_file
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails3_assist}
8
- s.version = "0.3.3"
8
+ s.version = "0.3.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"]
12
- s.date = %q{2010-12-09}
12
+ s.date = %q{2010-12-20}
13
13
  s.description = %q{Basic file operation helpers for working with Rails 3 artifacts}
14
14
  s.email = %q{kmandrup@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -50,7 +50,7 @@ describe Rails3::Assist::File::Special do
50
50
  CLASS.append_to_#{name}_file do
51
51
  'hello'
52
52
  end
53
- content = CLASS.read_#{name}_file
53
+ content = CLASS.read_#{name}_file
54
54
  content.should match /hello$/
55
55
  end
56
56
  end
@@ -62,6 +62,22 @@ describe Rails3::Assist::File::Special do
62
62
  AppDir.new.gem_file.should match /Gemfile/
63
63
  end
64
64
  end
65
+
66
+ describe '#insert_into_routes' do
67
+ it 'should insert into block of Routes file' do
68
+ old_routes_content = AppDir.new.read_routes_file
69
+
70
+ routes_stmt = 'devise_for :users'
71
+
72
+ CLASS.insert_into_routes routes_stmt
73
+
74
+ AppDir.new.read_routes_file.should match /do\s*#{Regexp.escape(routes_stmt)}\s*/
75
+
76
+ File.overwrite CLASS.routes_file do
77
+ old_routes_content
78
+ end
79
+ end
80
+ end
65
81
 
66
82
  describe '#read_gem_file' do
67
83
  it 'should read the Gemfile' do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 3
9
- version: 0.3.3
8
+ - 4
9
+ version: 0.3.4
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-12-09 00:00:00 +01:00
17
+ date: 2010-12-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency