file_mutate 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +20 -0
- data/README.textile +49 -0
- data/Rakefile +28 -0
- data/VERSION +1 -0
- data/file_mutate.gemspec +97 -0
- data/lib/file_mutate.rb +2 -0
- data/lib/file_mutate/append_content.rb +16 -0
- data/lib/file_mutate/delete.rb +28 -0
- data/lib/file_mutate/insert_content.rb +61 -0
- data/lib/file_mutate/mutate.rb +56 -0
- data/lib/file_mutate/overwrite_content.rb +16 -0
- data/lib/file_mutate/remove_content.rb +32 -0
- data/lib/file_mutate/replace_content.rb +44 -0
- data/lib/file_mutation.rb +46 -0
- data/spec/file_mutate/append_content_spec.rb +59 -0
- data/spec/file_mutate/delete_spec.rb +46 -0
- data/spec/file_mutate/insert_before_last_spec.rb +54 -0
- data/spec/file_mutate/insert_content_spec.rb +110 -0
- data/spec/file_mutate/overwrite_content_spec.rb +78 -0
- data/spec/file_mutate/remove_content_spec.rb +108 -0
- data/spec/file_mutate/replace_content_spec.rb +32 -0
- data/spec/fixtures/application_file.rb +6 -0
- data/spec/fixtures/class_file.rb +40 -0
- data/spec/fixtures/class_file.txt +0 -0
- data/spec/fixtures/content_file.txt +1 -0
- data/spec/fixtures/empty.txt +0 -0
- data/spec/fixtures/file.txt +1 -0
- data/spec/fixtures/non-empty.txt +3 -0
- data/spec/fixtures/routes_file.rb +97 -0
- data/spec/fixtures/search_file.txt +1 -0
- data/spec/spec_helper.rb +14 -0
- metadata +183 -0
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
File.file_mutate :replace_content
|
3
|
+
|
4
|
+
describe FileMutate do
|
5
|
+
let(:empty_file) { fixture_file 'empty.txt' }
|
6
|
+
let(:non_empty_file) { fixture_file 'non-empty.txt'}
|
7
|
+
let(:class_file) { fixture_file 'class_file.rb'}
|
8
|
+
let(:replace_file) { fixture_file 'file.txt' }
|
9
|
+
let(:file_to_delete) { fixture_file 'file_to_delete.txt' }
|
10
|
+
let(:routes_file) { fixture_file 'routes_file.rb' }
|
11
|
+
let(:app_file) { fixture_file 'application_file.rb' }
|
12
|
+
|
13
|
+
describe '#replace_content_from' do
|
14
|
+
let(:replace_file) { fixture_file 'file.txt' }
|
15
|
+
|
16
|
+
it "should replace content from existing file - class method" do
|
17
|
+
File.overwrite(replace_file) do
|
18
|
+
'Hello You'
|
19
|
+
end
|
20
|
+
File.replace_content_from replace_file, :where => 'You', :with => 'Me'
|
21
|
+
File.read(replace_file).should_not match /You/
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should remove content from existing file - instance method #replace_content' do
|
25
|
+
File.overwrite(replace_file) do
|
26
|
+
'Hello You'
|
27
|
+
end
|
28
|
+
File.new(replace_file).replace_content :where => 'You', :with => 'Me'
|
29
|
+
File.read(replace_file).should_not match /You/
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
{:with=>"New content"}
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
Hello Me
|
@@ -0,0 +1,97 @@
|
|
1
|
+
Fixtures::Application.routes.draw do
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
resources :users
|
40
|
+
|
41
|
+
# The priority is based upon order of creation:
|
42
|
+
# first created -> highest priority.
|
43
|
+
|
44
|
+
# Sample of regular route:
|
45
|
+
# match 'products/:id' => 'catalog#view'
|
46
|
+
# Keep in mind you can assign values other than :controller and :action
|
47
|
+
|
48
|
+
# Sample of named route:
|
49
|
+
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
|
50
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
51
|
+
|
52
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
53
|
+
# resources :products
|
54
|
+
|
55
|
+
# Sample resource route with options:
|
56
|
+
# resources :products do
|
57
|
+
# member do
|
58
|
+
# get 'short'
|
59
|
+
# post 'toggle'
|
60
|
+
# end
|
61
|
+
#
|
62
|
+
# collection do
|
63
|
+
# get 'sold'
|
64
|
+
# end
|
65
|
+
# end
|
66
|
+
|
67
|
+
# Sample resource route with sub-resources:
|
68
|
+
# resources :products do
|
69
|
+
# resources :comments, :sales
|
70
|
+
# resource :seller
|
71
|
+
# end
|
72
|
+
|
73
|
+
# Sample resource route with more complex sub-resources
|
74
|
+
# resources :products do
|
75
|
+
# resources :comments
|
76
|
+
# resources :sales do
|
77
|
+
# get 'recent', :on => :collection
|
78
|
+
# end
|
79
|
+
# end
|
80
|
+
|
81
|
+
# Sample resource route within a namespace:
|
82
|
+
# namespace :admin do
|
83
|
+
# # Directs /admin/products/* to Admin::ProductsController
|
84
|
+
# # (app/controllers/admin/products_controller.rb)
|
85
|
+
# resources :products
|
86
|
+
# end
|
87
|
+
|
88
|
+
# You can have the root of your site routed with "root"
|
89
|
+
# just remember to delete public/index.html.
|
90
|
+
# root :to => "welcome#index"
|
91
|
+
|
92
|
+
# See how all your routes lay out with "rake routes"
|
93
|
+
|
94
|
+
# This is a legacy wild controller route that's not recommended for RESTful applications.
|
95
|
+
# Note: This route will make all actions in every controller accessible via GET requests.
|
96
|
+
# match ':controller(/:action(/:id(.:format)))'
|
97
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Find this line right here!
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,183 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: file_mutate
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Kristian Mandrup
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-24 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: activesupport
|
16
|
+
requirement: &2154388260 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.0.1
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2154388260
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
requirement: &2154387780 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2154387780
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sugar-high
|
38
|
+
requirement: &2154387300 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.6.0
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *2154387300
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: sweetloader
|
49
|
+
requirement: &2154386820 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.1.0
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *2154386820
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: shoulda
|
60
|
+
requirement: &2154386340 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *2154386340
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &2154385860 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 2.4.1
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *2154385860
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: bundler
|
82
|
+
requirement: &2154385380 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.0.11
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *2154385380
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: jeweler
|
93
|
+
requirement: &2154384900 !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
96
|
+
- - ! '>='
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 1.6.4
|
99
|
+
type: :development
|
100
|
+
prerelease: false
|
101
|
+
version_requirements: *2154384900
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: rcov
|
104
|
+
requirement: &2154384420 !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: *2154384420
|
113
|
+
description: The file mutation DSL you always wish was included in Ruby
|
114
|
+
email: kmandrup@gmail.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files:
|
118
|
+
- LICENSE.txt
|
119
|
+
- README.textile
|
120
|
+
files:
|
121
|
+
- .document
|
122
|
+
- .rspec
|
123
|
+
- Gemfile
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.textile
|
126
|
+
- Rakefile
|
127
|
+
- VERSION
|
128
|
+
- file_mutate.gemspec
|
129
|
+
- lib/file_mutate.rb
|
130
|
+
- lib/file_mutate/append_content.rb
|
131
|
+
- lib/file_mutate/delete.rb
|
132
|
+
- lib/file_mutate/insert_content.rb
|
133
|
+
- lib/file_mutate/mutate.rb
|
134
|
+
- lib/file_mutate/overwrite_content.rb
|
135
|
+
- lib/file_mutate/remove_content.rb
|
136
|
+
- lib/file_mutate/replace_content.rb
|
137
|
+
- lib/file_mutation.rb
|
138
|
+
- spec/file_mutate/append_content_spec.rb
|
139
|
+
- spec/file_mutate/delete_spec.rb
|
140
|
+
- spec/file_mutate/insert_before_last_spec.rb
|
141
|
+
- spec/file_mutate/insert_content_spec.rb
|
142
|
+
- spec/file_mutate/overwrite_content_spec.rb
|
143
|
+
- spec/file_mutate/remove_content_spec.rb
|
144
|
+
- spec/file_mutate/replace_content_spec.rb
|
145
|
+
- spec/fixtures/application_file.rb
|
146
|
+
- spec/fixtures/class_file.rb
|
147
|
+
- spec/fixtures/class_file.txt
|
148
|
+
- spec/fixtures/content_file.txt
|
149
|
+
- spec/fixtures/empty.txt
|
150
|
+
- spec/fixtures/file.txt
|
151
|
+
- spec/fixtures/non-empty.txt
|
152
|
+
- spec/fixtures/routes_file.rb
|
153
|
+
- spec/fixtures/search_file.txt
|
154
|
+
- spec/spec_helper.rb
|
155
|
+
homepage: http://github.com/kristianmandrup/file_mutate
|
156
|
+
licenses:
|
157
|
+
- MIT
|
158
|
+
post_install_message:
|
159
|
+
rdoc_options: []
|
160
|
+
require_paths:
|
161
|
+
- lib
|
162
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
163
|
+
none: false
|
164
|
+
requirements:
|
165
|
+
- - ! '>='
|
166
|
+
- !ruby/object:Gem::Version
|
167
|
+
version: '0'
|
168
|
+
segments:
|
169
|
+
- 0
|
170
|
+
hash: 2589466820460003586
|
171
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ! '>='
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '0'
|
177
|
+
requirements: []
|
178
|
+
rubyforge_project:
|
179
|
+
rubygems_version: 1.8.8
|
180
|
+
signing_key:
|
181
|
+
specification_version: 3
|
182
|
+
summary: Adds file mutation DSL to any module or extends File class
|
183
|
+
test_files: []
|