file_utils 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/cssxfire.xml +9 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/file_utils.iml +17 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +242 -0
- data/.rvmrc +4 -0
- data/CHANGES +5 -0
- data/Gemfile +9 -0
- data/README.md +4 -0
- data/Rakefile +29 -0
- data/file_utils.gemspec +18 -0
- data/lib/file_utils/directory_scanner.rb +57 -0
- data/lib/file_utils/file_utils.rb +53 -0
- data/lib/file_utils/version.rb +3 -0
- data/spec/directory_scanner_spec.rb +29 -0
- data/spec/spec_helper.rb +1 -0
- metadata +69 -0
data/.gitignore
ADDED
data/.idea/.name
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
file_utils
|
data/.idea/.rakeTasks
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Settings><!--This file was automatically generated by Ruby plugin.
|
3
|
+
You are allowed to:
|
4
|
+
1. Remove rake task
|
5
|
+
2. Add existing rake tasks
|
6
|
+
To add existing rake tasks automatically delete this file and reload the project.
|
7
|
+
--><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
|
data/.idea/cssxfire.xml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="CssXFireSettings">
|
4
|
+
<general autoClear="false" autoExpand="false" />
|
5
|
+
<strategy useRoutes="false" mediaReduce="false" fileReduce="false" currentDocumentsReduce="false" resolveVariables="true" resolveMixins="true" />
|
6
|
+
<routes />
|
7
|
+
</component>
|
8
|
+
</project>
|
9
|
+
|
data/.idea/encodings.xml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<module type="RUBY_MODULE" version="4">
|
3
|
+
<component name="NewModuleRootManager">
|
4
|
+
<content url="file://$MODULE_DIR$" />
|
5
|
+
<orderEntry type="inheritedJdk" />
|
6
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
7
|
+
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.1.3, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
8
|
+
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.1.3, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
9
|
+
<orderEntry type="library" scope="PROVIDED" name="metaclass (v0.0.1, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
10
|
+
<orderEntry type="library" scope="PROVIDED" name="mocha (v0.10.3, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
11
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec (v2.9.0, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
12
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-core (v2.9.0, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
13
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v2.9.1, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
14
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v2.9.0, RVM: ruby-1.9.3-p194 [file_utils]) [gem]" level="application" />
|
15
|
+
</component>
|
16
|
+
</module>
|
17
|
+
|
data/.idea/misc.xml
ADDED
data/.idea/modules.xml
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ProjectModuleManager">
|
4
|
+
<modules>
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/file_utils.iml" filepath="$PROJECT_DIR$/.idea/file_utils.iml" />
|
6
|
+
</modules>
|
7
|
+
</component>
|
8
|
+
</project>
|
9
|
+
|
data/.idea/vcs.xml
ADDED
data/.idea/workspace.xml
ADDED
@@ -0,0 +1,242 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project version="4">
|
3
|
+
<component name="ChangeListManager">
|
4
|
+
<list default="true" id="5aea4d68-4507-4177-a112-c280e0c8edfa" name="Default" comment="">
|
5
|
+
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
6
|
+
</list>
|
7
|
+
<ignored path="file_utils.iws" />
|
8
|
+
<ignored path=".idea/workspace.xml" />
|
9
|
+
<option name="TRACKING_ENABLED" value="true" />
|
10
|
+
<option name="SHOW_DIALOG" value="false" />
|
11
|
+
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
12
|
+
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
13
|
+
<option name="LAST_RESOLUTION" value="IGNORE" />
|
14
|
+
</component>
|
15
|
+
<component name="ChangesViewManager" flattened_view="true" show_ignored="false" />
|
16
|
+
<component name="CreatePatchCommitExecutor">
|
17
|
+
<option name="PATCH_PATH" value="" />
|
18
|
+
</component>
|
19
|
+
<component name="DaemonCodeAnalyzer">
|
20
|
+
<disable_hints />
|
21
|
+
</component>
|
22
|
+
<component name="FavoritesManager">
|
23
|
+
<favorites_list name="file_utils" />
|
24
|
+
</component>
|
25
|
+
<component name="FileEditorManager">
|
26
|
+
<leaf>
|
27
|
+
<file leaf-file-name=".rvmrc" pinned="false" current="false" current-in-tab="false">
|
28
|
+
<entry file="file://$PROJECT_DIR$/.rvmrc">
|
29
|
+
<provider selected="true" editor-type-id="text-editor">
|
30
|
+
<state line="3" column="27" selection-start="81" selection-end="81" vertical-scroll-proportion="0.0">
|
31
|
+
<folding />
|
32
|
+
</state>
|
33
|
+
</provider>
|
34
|
+
</entry>
|
35
|
+
</file>
|
36
|
+
<file leaf-file-name="Rakefile" pinned="false" current="true" current-in-tab="true">
|
37
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
38
|
+
<provider selected="true" editor-type-id="text-editor">
|
39
|
+
<state line="29" column="6" selection-start="489" selection-end="489" vertical-scroll-proportion="0.5899358">
|
40
|
+
<folding />
|
41
|
+
</state>
|
42
|
+
</provider>
|
43
|
+
</entry>
|
44
|
+
</file>
|
45
|
+
</leaf>
|
46
|
+
</component>
|
47
|
+
<component name="Git.Settings">
|
48
|
+
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
49
|
+
</component>
|
50
|
+
<component name="IdeDocumentHistory">
|
51
|
+
<option name="changedFiles">
|
52
|
+
<list>
|
53
|
+
<option value="$PROJECT_DIR$/.rvmrc" />
|
54
|
+
<option value="$PROJECT_DIR$/Rakefile" />
|
55
|
+
</list>
|
56
|
+
</option>
|
57
|
+
</component>
|
58
|
+
<component name="ProjectFrameBounds">
|
59
|
+
<option name="x" value="516" />
|
60
|
+
<option name="y" value="37" />
|
61
|
+
<option name="width" value="1588" />
|
62
|
+
<option name="height" value="1058" />
|
63
|
+
</component>
|
64
|
+
<component name="ProjectLevelVcsManager" settingsEditedManually="false">
|
65
|
+
<OptionsSetting value="true" id="Add" />
|
66
|
+
<OptionsSetting value="true" id="Remove" />
|
67
|
+
<OptionsSetting value="true" id="Checkout" />
|
68
|
+
<OptionsSetting value="true" id="Update" />
|
69
|
+
<OptionsSetting value="true" id="Status" />
|
70
|
+
<OptionsSetting value="true" id="Edit" />
|
71
|
+
<ConfirmationsSetting value="0" id="Add" />
|
72
|
+
<ConfirmationsSetting value="0" id="Remove" />
|
73
|
+
</component>
|
74
|
+
<component name="ProjectReloadState">
|
75
|
+
<option name="STATE" value="0" />
|
76
|
+
</component>
|
77
|
+
<component name="ProjectView">
|
78
|
+
<navigator currentView="ProjectPane" proportions="" version="1" splitterProportion="0.5">
|
79
|
+
<flattenPackages />
|
80
|
+
<showMembers />
|
81
|
+
<showModules />
|
82
|
+
<showLibraryContents />
|
83
|
+
<hideEmptyPackages />
|
84
|
+
<abbreviatePackageNames />
|
85
|
+
<autoscrollToSource />
|
86
|
+
<autoscrollFromSource />
|
87
|
+
<sortByType />
|
88
|
+
</navigator>
|
89
|
+
<panes>
|
90
|
+
<pane id="ProjectPane">
|
91
|
+
<subPane>
|
92
|
+
<PATH>
|
93
|
+
<PATH_ELEMENT>
|
94
|
+
<option name="myItemId" value="file_utils" />
|
95
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
96
|
+
</PATH_ELEMENT>
|
97
|
+
</PATH>
|
98
|
+
<PATH>
|
99
|
+
<PATH_ELEMENT>
|
100
|
+
<option name="myItemId" value="file_utils" />
|
101
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
102
|
+
</PATH_ELEMENT>
|
103
|
+
<PATH_ELEMENT>
|
104
|
+
<option name="myItemId" value="file_utils" />
|
105
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
106
|
+
</PATH_ELEMENT>
|
107
|
+
</PATH>
|
108
|
+
<PATH>
|
109
|
+
<PATH_ELEMENT>
|
110
|
+
<option name="myItemId" value="file_utils" />
|
111
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
|
112
|
+
</PATH_ELEMENT>
|
113
|
+
<PATH_ELEMENT>
|
114
|
+
<option name="myItemId" value="file_utils" />
|
115
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
116
|
+
</PATH_ELEMENT>
|
117
|
+
<PATH_ELEMENT>
|
118
|
+
<option name="myItemId" value="lib" />
|
119
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
120
|
+
</PATH_ELEMENT>
|
121
|
+
<PATH_ELEMENT>
|
122
|
+
<option name="myItemId" value="file_utils" />
|
123
|
+
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
|
124
|
+
</PATH_ELEMENT>
|
125
|
+
</PATH>
|
126
|
+
</subPane>
|
127
|
+
</pane>
|
128
|
+
<pane id="Scope" />
|
129
|
+
</panes>
|
130
|
+
</component>
|
131
|
+
<component name="RunManager">
|
132
|
+
<list size="0" />
|
133
|
+
<recent_temporary>
|
134
|
+
<list size="0" />
|
135
|
+
</recent_temporary>
|
136
|
+
</component>
|
137
|
+
<component name="ShelveChangesManager" show_recycled="false" />
|
138
|
+
<component name="ToolWindowManager">
|
139
|
+
<frame x="516" y="37" width="1588" height="1058" extended-state="0" />
|
140
|
+
<editor active="true" />
|
141
|
+
<layout>
|
142
|
+
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
143
|
+
<window_info id="CSS-X-Fire" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
144
|
+
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
|
145
|
+
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
|
146
|
+
<window_info id="jenkinsBrowser" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
147
|
+
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.25" sideWeight="0.67013526" order="0" side_tool="false" content_ui="combo" />
|
148
|
+
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
149
|
+
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
|
150
|
+
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
|
151
|
+
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
152
|
+
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
153
|
+
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
154
|
+
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
155
|
+
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
156
|
+
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
157
|
+
<window_info id="Messages" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.3298647" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
158
|
+
<window_info id="Commander" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
159
|
+
<window_info id="Hierarchy" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="2" side_tool="false" content_ui="combo" />
|
160
|
+
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
161
|
+
</layout>
|
162
|
+
</component>
|
163
|
+
<component name="VcsContentAnnotationSettings">
|
164
|
+
<option name="myLimit" value="2678400000" />
|
165
|
+
</component>
|
166
|
+
<component name="VcsManagerConfiguration">
|
167
|
+
<option name="OFFER_MOVE_TO_ANOTHER_CHANGELIST_ON_PARTIAL_COMMIT" value="true" />
|
168
|
+
<option name="CHECK_CODE_SMELLS_BEFORE_PROJECT_COMMIT" value="true" />
|
169
|
+
<option name="CHECK_NEW_TODO" value="true" />
|
170
|
+
<option name="myTodoPanelSettings">
|
171
|
+
<value>
|
172
|
+
<are-packages-shown value="false" />
|
173
|
+
<are-modules-shown value="false" />
|
174
|
+
<flatten-packages value="false" />
|
175
|
+
<is-autoscroll-to-source value="false" />
|
176
|
+
</value>
|
177
|
+
</option>
|
178
|
+
<option name="PERFORM_UPDATE_IN_BACKGROUND" value="true" />
|
179
|
+
<option name="PERFORM_COMMIT_IN_BACKGROUND" value="true" />
|
180
|
+
<option name="PERFORM_EDIT_IN_BACKGROUND" value="true" />
|
181
|
+
<option name="PERFORM_CHECKOUT_IN_BACKGROUND" value="true" />
|
182
|
+
<option name="PERFORM_ADD_REMOVE_IN_BACKGROUND" value="true" />
|
183
|
+
<option name="PERFORM_ROLLBACK_IN_BACKGROUND" value="false" />
|
184
|
+
<option name="CHECK_LOCALLY_CHANGED_CONFLICTS_IN_BACKGROUND" value="false" />
|
185
|
+
<option name="ENABLE_BACKGROUND_PROCESSES" value="false" />
|
186
|
+
<option name="CHANGED_ON_SERVER_INTERVAL" value="60" />
|
187
|
+
<option name="SHOW_ONLY_CHANGED_IN_SELECTION_DIFF" value="true" />
|
188
|
+
<option name="CHECK_COMMIT_MESSAGE_SPELLING" value="true" />
|
189
|
+
<option name="DEFAULT_PATCH_EXTENSION" value="patch" />
|
190
|
+
<option name="SHORT_DIFF_HORISONTALLY" value="true" />
|
191
|
+
<option name="SHORT_DIFF_EXTRA_LINES" value="2" />
|
192
|
+
<option name="SOFT_WRAPS_IN_SHORT_DIFF" value="true" />
|
193
|
+
<option name="INCLUDE_TEXT_INTO_PATCH" value="false" />
|
194
|
+
<option name="INCLUDE_TEXT_INTO_SHELF" value="false" />
|
195
|
+
<option name="CREATE_PATCH_EXPAND_DETAILS_DEFAULT" value="true" />
|
196
|
+
<option name="SHOW_FILE_HISTORY_DETAILS" value="true" />
|
197
|
+
<option name="SHOW_VCS_ERROR_NOTIFICATIONS" value="true" />
|
198
|
+
<option name="CHANGE_DETAILS_ON" value="false" />
|
199
|
+
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
|
200
|
+
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
|
201
|
+
<option name="LAST_COMMIT_MESSAGE" />
|
202
|
+
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
|
203
|
+
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
|
204
|
+
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
|
205
|
+
<option name="REFORMAT_BEFORE_PROJECT_COMMIT" value="false" />
|
206
|
+
<option name="REFORMAT_BEFORE_FILE_COMMIT" value="false" />
|
207
|
+
<option name="FILE_HISTORY_DIALOG_COMMENTS_SPLITTER_PROPORTION" value="0.8" />
|
208
|
+
<option name="FILE_HISTORY_DIALOG_SPLITTER_PROPORTION" value="0.5" />
|
209
|
+
<option name="ACTIVE_VCS_NAME" />
|
210
|
+
<option name="UPDATE_GROUP_BY_PACKAGES" value="false" />
|
211
|
+
<option name="UPDATE_GROUP_BY_CHANGELIST" value="false" />
|
212
|
+
<option name="SHOW_FILE_HISTORY_AS_TREE" value="false" />
|
213
|
+
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
|
214
|
+
</component>
|
215
|
+
<component name="XDebuggerManager">
|
216
|
+
<breakpoint-manager />
|
217
|
+
</component>
|
218
|
+
<component name="editorHistoryManager">
|
219
|
+
<entry file="file://$PROJECT_DIR$/.rvmrc">
|
220
|
+
<provider selected="true" editor-type-id="text-editor">
|
221
|
+
<state line="3" column="27" selection-start="81" selection-end="81" vertical-scroll-proportion="0.0">
|
222
|
+
<folding />
|
223
|
+
</state>
|
224
|
+
</provider>
|
225
|
+
</entry>
|
226
|
+
<entry file="file://$PROJECT_DIR$/.rvmrc">
|
227
|
+
<provider selected="true" editor-type-id="text-editor">
|
228
|
+
<state line="3" column="27" selection-start="81" selection-end="81" vertical-scroll-proportion="0.0">
|
229
|
+
<folding />
|
230
|
+
</state>
|
231
|
+
</provider>
|
232
|
+
</entry>
|
233
|
+
<entry file="file://$PROJECT_DIR$/Rakefile">
|
234
|
+
<provider selected="true" editor-type-id="text-editor">
|
235
|
+
<state line="29" column="6" selection-start="489" selection-end="489" vertical-scroll-proportion="0.5899358">
|
236
|
+
<folding />
|
237
|
+
</state>
|
238
|
+
</provider>
|
239
|
+
</entry>
|
240
|
+
</component>
|
241
|
+
</project>
|
242
|
+
|
data/.rvmrc
ADDED
data/CHANGES
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift File.expand_path("lib", File.dirname(__FILE__))
|
4
|
+
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
require "file_utils/version"
|
7
|
+
|
8
|
+
def version
|
9
|
+
FileUtils::VERSION
|
10
|
+
end
|
11
|
+
|
12
|
+
def project_name
|
13
|
+
File.basename(Dir.pwd)
|
14
|
+
end
|
15
|
+
|
16
|
+
task :build do
|
17
|
+
system "gem build #{project_name}.gemspec"
|
18
|
+
end
|
19
|
+
|
20
|
+
task :release => :build do
|
21
|
+
system "gem push #{project_name}-#{version}.gem"
|
22
|
+
end
|
23
|
+
|
24
|
+
RSpec::Core::RakeTask.new do |task|
|
25
|
+
task.pattern = 'spec/**/*_spec.rb'
|
26
|
+
task.verbose = false
|
27
|
+
end
|
28
|
+
|
29
|
+
|
data/file_utils.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '/lib/file_utils/version')
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "file_utils"
|
7
|
+
spec.summary = %q{Collection of methods to work with files and directories}
|
8
|
+
spec.description = %q{Collection of methods to work with files and directories}
|
9
|
+
spec.email = "alexander.shvets@gmail.com"
|
10
|
+
spec.authors = ["Alexander Shvets"]
|
11
|
+
spec.homepage = "http://github.com/shvets/file_utils"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($\)
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
spec.version = FileUtils::VERSION
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,57 @@
|
|
1
|
+
class DirectoryScanner
|
2
|
+
def scan dir, includes, excludes
|
3
|
+
files = []
|
4
|
+
|
5
|
+
scan_with_files dir, Array(includes), Array(excludes), files
|
6
|
+
|
7
|
+
normalize(files, dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def scan_with_files dir, includes, excludes, files
|
13
|
+
Dir.new(dir).each do |file_name|
|
14
|
+
if file_name != '.' and file_name != '..'
|
15
|
+
full_name = dir + '/' + file_name
|
16
|
+
|
17
|
+
if File.directory? full_name
|
18
|
+
if check_name(full_name, includes, excludes)
|
19
|
+
files << full_name
|
20
|
+
scan_with_files(full_name, includes, excludes, files)
|
21
|
+
end
|
22
|
+
else # file
|
23
|
+
if check_name(full_name, includes, excludes)
|
24
|
+
files << full_name
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def check_name name, includes, excludes
|
32
|
+
if includes.empty? and excludes.empty?
|
33
|
+
true
|
34
|
+
elsif includes.empty?
|
35
|
+
true unless match?(name, excludes)
|
36
|
+
elsif excludes.empty?
|
37
|
+
true if match?(name, includes)
|
38
|
+
else
|
39
|
+
true if match?(name, includes) and not match?(name, excludes)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def normalize list, dir
|
44
|
+
list.each_with_index do |name, index|
|
45
|
+
list[index] = name[dir.length+1..-1]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def match? name, list
|
50
|
+
list.each do |pattern|
|
51
|
+
return true if File.fnmatch(pattern, name) or name =~ /#{pattern}/
|
52
|
+
end
|
53
|
+
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module FileUtils
|
2
|
+
def process_dir dir, &code
|
3
|
+
Dir.foreach(dir) do |entry_name|
|
4
|
+
next if entry_name == '.' or entry_name == '..'
|
5
|
+
|
6
|
+
code.call(entry_name)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def substitute_vars file_name
|
11
|
+
template = ERB.new read_file(file_name)
|
12
|
+
|
13
|
+
template.result(binding)
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_to_file from, to
|
17
|
+
File.open(to, "w") do |file|
|
18
|
+
file.write(read_file(from))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def write_content_to_file content, to
|
23
|
+
File.open(to, "w") do |file|
|
24
|
+
file.write(content)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def read_file file_name
|
29
|
+
File.open(file_name).read
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_directory dir
|
33
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
34
|
+
end
|
35
|
+
|
36
|
+
def delete_directory dir
|
37
|
+
FileUtils.rm_rf dir
|
38
|
+
end
|
39
|
+
|
40
|
+
def pattern_to_files dir, pattern
|
41
|
+
Dir.glob("#{dir}/#{pattern}")
|
42
|
+
end
|
43
|
+
|
44
|
+
def copy_files from_dir, to_dir, pattern
|
45
|
+
create_directory to_dir
|
46
|
+
|
47
|
+
files = pattern_to_files from_dir, pattern
|
48
|
+
|
49
|
+
FileUtils.cp_r files, to_dir
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
require 'directory_scanner'
|
4
|
+
|
5
|
+
class FileUtilsTest
|
6
|
+
include FileUtils
|
7
|
+
end
|
8
|
+
|
9
|
+
describe DirectoryScanner do
|
10
|
+
|
11
|
+
it "should return files in particular dir" do
|
12
|
+
result = subject.scan "config"
|
13
|
+
|
14
|
+
result.should include "config/environments/development.rb"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should apply 'includes' filter" do
|
18
|
+
result = subject.scan "config", :includes => ".yml"
|
19
|
+
|
20
|
+
result.should include "config/database.yml"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should apply 'excludes' filter" do
|
24
|
+
result = subject.scan "config", :excludes => ".yml"
|
25
|
+
|
26
|
+
result.should_not include "config/database.yml"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
$: << File.expand_path(File.dirname(__FILE__) + '/../lib')
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: file_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Alexander Shvets
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-06-08 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Collection of methods to work with files and directories
|
15
|
+
email: alexander.shvets@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- .gitignore
|
21
|
+
- .idea/.name
|
22
|
+
- .idea/.rakeTasks
|
23
|
+
- .idea/cssxfire.xml
|
24
|
+
- .idea/encodings.xml
|
25
|
+
- .idea/file_utils.iml
|
26
|
+
- .idea/misc.xml
|
27
|
+
- .idea/modules.xml
|
28
|
+
- .idea/scopes/scope_settings.xml
|
29
|
+
- .idea/vcs.xml
|
30
|
+
- .idea/workspace.xml
|
31
|
+
- .rvmrc
|
32
|
+
- CHANGES
|
33
|
+
- Gemfile
|
34
|
+
- Gemfile.lock
|
35
|
+
- README.md
|
36
|
+
- Rakefile
|
37
|
+
- file_utils.gemspec
|
38
|
+
- lib/file_utils/directory_scanner.rb
|
39
|
+
- lib/file_utils/file_utils.rb
|
40
|
+
- lib/file_utils/version.rb
|
41
|
+
- spec/directory_scanner_spec.rb
|
42
|
+
- spec/spec_helper.rb
|
43
|
+
homepage: http://github.com/shvets/file_utils
|
44
|
+
licenses: []
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.23
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Collection of methods to work with files and directories
|
67
|
+
test_files:
|
68
|
+
- spec/directory_scanner_spec.rb
|
69
|
+
- spec/spec_helper.rb
|