zip_dsl 1.3.4 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.idea/zip_dsl.iml CHANGED
@@ -9,6 +9,196 @@
9
9
  </configuration>
10
10
  </facet>
11
11
  </component>
12
+ <component name="ModuleRunConfigurationManager">
13
+ <configuration default="false" name="rake" type="RakeRunConfigurationType" factoryName="Rake">
14
+ <module name="zip_dsl" />
15
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
16
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
17
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
18
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
19
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
20
+ <envs />
21
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
22
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
23
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
24
+ <COVERAGE_PATTERN ENABLED="true">
25
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
26
+ </COVERAGE_PATTERN>
27
+ </EXTENSION>
28
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
29
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_NAME" VALUE="build" />
30
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ARGS" VALUE="" />
31
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_ATTACHED_TEST_FRAMEWORKS" VALUE="" />
32
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_TRACE" VALUE="false" />
33
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_DRYRUN" VALUE="false" />
34
+ <RAKE_RUN_CONFIG_SETTINGS_ID NAME="RAKE_TASK_OPTION_PREREQS" VALUE="false" />
35
+ <RunnerSettings RunnerId="RubyDebugRunner" />
36
+ <ConfigurationWrapper RunnerId="RubyDebugRunner" />
37
+ <method />
38
+ </configuration>
39
+ <configuration default="false" name="zip_writer" type="RubyRunConfigurationType" factoryName="Ruby" temporary="true">
40
+ <module name="zip_dsl" />
41
+ <RUBY_RUN_CONFIG NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
42
+ <RUBY_RUN_CONFIG NAME="WORK DIR" VALUE="$MODULE_DIR$/lib/zip_dsl" />
43
+ <RUBY_RUN_CONFIG NAME="SHOULD_USE_SDK" VALUE="false" />
44
+ <RUBY_RUN_CONFIG NAME="ALTERN_SDK_NAME" VALUE="" />
45
+ <RUBY_RUN_CONFIG NAME="myPassParentEnvs" VALUE="true" />
46
+ <envs />
47
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
48
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
49
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
50
+ <COVERAGE_PATTERN ENABLED="true">
51
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
52
+ </COVERAGE_PATTERN>
53
+ </EXTENSION>
54
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
55
+ <RUBY_RUN_CONFIG NAME="SCRIPT_PATH" VALUE="$MODULE_DIR$/lib/zip_dsl/zip_writer.rb" />
56
+ <RUBY_RUN_CONFIG NAME="SCRIPT_ARGS" VALUE="" />
57
+ <RunnerSettings RunnerId="RubyRunner" />
58
+ <ConfigurationWrapper RunnerId="RubyRunner" />
59
+ <method />
60
+ </configuration>
61
+ <configuration default="false" name="ZipDSL" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
62
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
63
+ <module name="zip_dsl" />
64
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
65
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
66
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
67
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
68
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
69
+ <envs>
70
+ <env name="JRUBY_OPTS" value="-X+O" />
71
+ </envs>
72
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
73
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
74
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
75
+ <COVERAGE_PATTERN ENABLED="true">
76
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
77
+ </COVERAGE_PATTERN>
78
+ </EXTENSION>
79
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
80
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
81
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/zip_dsl_spec.rb" />
82
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
83
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
84
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ZipDSL" />
85
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
86
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
87
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
88
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
89
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
90
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
91
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
92
+ <RunnerSettings RunnerId="RubyRunner" />
93
+ <ConfigurationWrapper RunnerId="RubyRunner" />
94
+ <method />
95
+ </configuration>
96
+ <configuration default="false" name="zip_dsl_spec" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
97
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
98
+ <module name="zip_dsl" />
99
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
100
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
101
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
102
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
103
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
104
+ <envs>
105
+ <env name="JRUBY_OPTS" value="-X+O" />
106
+ </envs>
107
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="true" />
108
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
109
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
110
+ <COVERAGE_PATTERN ENABLED="true">
111
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
112
+ </COVERAGE_PATTERN>
113
+ </EXTENSION>
114
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
115
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
116
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/zip_dsl_spec.rb" />
117
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
118
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
119
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="" />
120
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
121
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
122
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
123
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
124
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
125
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
126
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
127
+ <RunnerSettings RunnerId="RubyRunner" />
128
+ <ConfigurationWrapper RunnerId="RubyRunner" />
129
+ <method />
130
+ </configuration>
131
+ <configuration default="false" name="ZipDSL should display files in specified subdirectory: zip_dsl" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
132
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
133
+ <module name="zip_dsl" />
134
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
135
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
136
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
137
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
138
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
139
+ <envs>
140
+ <env name="JRUBY_OPTS" value="-X+O" />
141
+ </envs>
142
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
143
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
144
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
145
+ <COVERAGE_PATTERN ENABLED="true">
146
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
147
+ </COVERAGE_PATTERN>
148
+ </EXTENSION>
149
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
150
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
151
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/zip_dsl_spec.rb" />
152
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
153
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
154
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ZipDSL should display files in specified subdirectory" />
155
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
156
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
157
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
158
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
159
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
160
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
161
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
162
+ <RunnerSettings RunnerId="RubyRunner" />
163
+ <ConfigurationWrapper RunnerId="RubyRunner" />
164
+ <method />
165
+ </configuration>
166
+ <configuration default="false" name="ZipDSL#read: zip_dsl" type="RSpecRunConfigurationType" factoryName="RSpec" temporary="true">
167
+ <predefined_log_file id="RUBY_RSPEC" enabled="true" />
168
+ <module name="zip_dsl" />
169
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUBY_ARGS" VALUE="-e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)" />
170
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="WORK DIR" VALUE="$MODULE_DIR$" />
171
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SHOULD_USE_SDK" VALUE="false" />
172
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ALTERN_SDK_NAME" VALUE="" />
173
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="myPassParentEnvs" VALUE="true" />
174
+ <envs>
175
+ <env name="JRUBY_OPTS" value="-X+O" />
176
+ </envs>
177
+ <EXTENSION ID="BundlerRunConfigurationExtension" bundleExecEnabled="false" />
178
+ <EXTENSION ID="JRubyRunConfigurationExtension" NailgunExecEnabled="false" />
179
+ <EXTENSION ID="RubyCoverageRunConfigurationExtension" enabled="false" sample_coverage="true" track_test_folders="true" runner="rcov">
180
+ <COVERAGE_PATTERN ENABLED="true">
181
+ <PATTERN REGEXPS="/.rvm/" INCLUDED="false" />
182
+ </COVERAGE_PATTERN>
183
+ </EXTENSION>
184
+ <EXTENSION ID="org.jetbrains.plugins.ruby.motion.run.MotionSimulatorRunExtension" />
185
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TESTS_FOLDER_PATH" VALUE="" />
186
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_SCRIPT_PATH" VALUE="$MODULE_DIR$/spec/zip_dsl_spec.rb" />
187
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_RUNNER_PATH" VALUE="" />
188
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_FILE_MASK" VALUE="**/*_spec.rb" />
189
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_EXAMPLE_NAME" VALUE="ZipDSL#read" />
190
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="TEST_TEST_TYPE" VALUE="TEST_SCRIPT" />
191
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="SPEC_ARGS" VALUE="" />
192
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="RUNNER_VERSION" VALUE="" />
193
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="USE_CUSTOM_SPEC_RUNNER" VALUE="false" />
194
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="DRB" VALUE="false" />
195
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="ZEUS" VALUE="false" />
196
+ <RSPEC_RUN_CONFIG_SETTINGS_ID NAME="FULL_BACKTRACE" VALUE="false" />
197
+ <RunnerSettings RunnerId="RubyRunner" />
198
+ <ConfigurationWrapper RunnerId="RubyRunner" />
199
+ <method />
200
+ </configuration>
201
+ </component>
12
202
  <component name="NewModuleRootManager">
13
203
  <content url="file://$MODULE_DIR$" />
14
204
  <orderEntry type="inheritedJdk" />
data/CHANGES CHANGED
@@ -22,4 +22,8 @@
22
22
 
23
23
  == Version 1.3.4
24
24
 
25
- * Adding version to gemspec.
25
+ * Adding version to gemspec.
26
+
27
+ == Version 1.3.5
28
+
29
+ * Adding each_entry method.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Alexander Shvets
1
+ Copyright (c) 2013 Alexander Shvets
2
2
 
3
3
  MIT License
4
4
 
data/README.md CHANGED
@@ -1,4 +1,74 @@
1
- zip_dsl
2
- =======
1
+ # ZipDSL
3
2
 
4
- Library for working with zip file in DSL-way
3
+ Library for working with zip file in DSL-way
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'zip_dsl'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install zip_dsl
18
+
19
+ ## Usage
20
+
21
+ You can create new archive:
22
+
23
+ ```ruby
24
+ require 'zip_dsl'
25
+
26
+ from_dir = "."
27
+ to_dir = "build"
28
+ zip_file = "test.zip"
29
+
30
+ zip_builder = ZipDSL.new from_dir, to_dir, zip_file
31
+
32
+ zip_builder.build do
33
+ # files from 'from_dir'
34
+ file :name => "Gemfile"
35
+ file :name => "Rakefile", :to_dir => "my_config"
36
+ file :name => "spec/spec_helper.rb", :to_dir => "my_config"
37
+
38
+ # create empty directory
39
+ directory :to_dir => "my_config"
40
+
41
+ # copy from one directory to another
42
+ directory :from_dir => "spec", :to_dir => "my_spec"
43
+
44
+ # create zip entry from arbitrary source: string or StringIO
45
+ content :name => "README", :source => "My README file content"
46
+ end
47
+ ```
48
+
49
+ or update existing archive:
50
+
51
+ ```ruby
52
+ ...
53
+
54
+ zip_builder.update do
55
+ file :name => "README.md"
56
+ directory :from_dir => "lib"
57
+ end
58
+ ```
59
+
60
+ You can also display all entries from archive's folder:
61
+
62
+ ```ruby
63
+ ...
64
+
65
+ zip_builder.list("lib/zip_dsl")
66
+ ```
67
+
68
+ ## Contributing
69
+
70
+ 1. Fork it
71
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
72
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
73
+ 4. Push to the branch (`git push origin my-new-feature`)
74
+ 5. Create new Pull Request
@@ -1,3 +1,3 @@
1
1
  class ZipDSL
2
- VERSION = "1.3.4"
2
+ VERSION = "1.3.5"
3
3
  end
@@ -54,5 +54,13 @@ class ZipDSL
54
54
 
55
55
  evaluate_dsl(create_block, destroy_block, execute_block)
56
56
  end
57
+
58
+ def each_entry dir=".", &code
59
+ create_block = lambda { ZipReader.new(to_root, name) }
60
+ destroy_block = lambda {|reader| reader.close }
61
+ execute_block = lambda { |reader| reader.each_entry(dir, &code) }
62
+
63
+ evaluate_dsl(create_block, destroy_block, execute_block)
64
+ end
57
65
  end
58
66
 
@@ -56,6 +56,14 @@ class ZipReader
56
56
  entries
57
57
  end
58
58
 
59
+ def each_entry dir=".", &code
60
+ self.each do |entry|
61
+ if entry.name =~ /#{dir}/
62
+ code.call(entry)
63
+ end
64
+ end
65
+ end
66
+
59
67
  private
60
68
 
61
69
  def dir_entry? entry
data/spec/zip_dsl_spec.rb CHANGED
@@ -11,92 +11,115 @@ describe ZipDSL do
11
11
 
12
12
  subject { ZipDSL.new from_basedir, to_basedir, "test.zip" }
13
13
 
14
- after do
15
- delete_directory "build"
16
- end
17
-
18
- it "should create new zip file with files at particular folder" do
19
- subject.build do
20
- file :name => "Gemfile"
21
- file :name => "Rakefile", :to_dir => "my_config"
22
- file :name => "spec/spec_helper.rb", :to_dir => "my_config"
14
+ describe "#build" do
15
+ after do
16
+ delete_directory "build"
23
17
  end
24
18
 
25
- subject.entry_exist?("Gemfile").should be_true
26
- subject.entry_exist?("my_config/Rakefile").should be_true
27
- subject.entry_exist?("my_config/spec_helper.rb").should be_true
19
+ it "should create new zip file with files at particular folder" do
20
+ subject.build do
21
+ file :name => "Gemfile"
22
+ file :name => "Rakefile", :to_dir => "my_config"
23
+ file :name => "spec/spec_helper.rb", :to_dir => "my_config"
24
+ end
28
25
 
29
- subject.entries_size.should == 3
30
- end
26
+ subject.entry_exist?("Gemfile").should be_true
27
+ subject.entry_exist?("my_config/Rakefile").should be_true
28
+ subject.entry_exist?("my_config/spec_helper.rb").should be_true
31
29
 
32
- it "should create new zip file with file created from string" do
33
- subject.build do
34
- content :name => "README", :source => "My README file content"
30
+ subject.entries_size.should == 3
35
31
  end
36
32
 
37
- subject.entry_exist?("README").should be_true
38
- subject.entries_size.should == 1
39
- end
33
+ it "should create new zip file with file created from string" do
34
+ subject.build do
35
+ content :name => "README", :source => "My README file content"
36
+ end
40
37
 
41
- it "should create new zip file with file created from file" do
42
- src = File.open("#{from_basedir}/Rakefile")
43
- subject.build do
44
- content :name => "Rakefile", :source => src
38
+ subject.entry_exist?("README").should be_true
39
+ subject.entries_size.should == 1
45
40
  end
46
41
 
47
- subject.entry_exist?("Rakefile").should be_true
48
- subject.entries_size.should == 1
49
- end
42
+ it "should create new zip file with file created from file" do
43
+ src = File.open("#{from_basedir}/Rakefile")
44
+ subject.build do
45
+ content :name => "Rakefile", :source => src
46
+ end
50
47
 
51
- it "should create new zip file with new empty folder" do
52
- subject.build do
53
- directory :to_dir => "my_config"
48
+ subject.entry_exist?("Rakefile").should be_true
49
+ subject.entries_size.should == 1
54
50
  end
55
51
 
56
- subject.entry_exist?("my_config").should be_true
57
- subject.entries_size.should == 1
58
- end
52
+ it "should create new zip file with new empty folder" do
53
+ subject.build do
54
+ directory :to_dir => "my_config"
55
+ end
59
56
 
60
- it "should create new zip file with new folder" do
61
- subject.build do
62
- directory :from_dir => "spec", :to_dir => "my_config"
57
+ subject.entry_exist?("my_config").should be_true
58
+ subject.entries_size.should == 1
63
59
  end
64
60
 
65
- subject.entry_exist?("my_config").should be_true
66
- subject.entries_size.should > 1
67
- end
61
+ it "should create new zip file with new folder" do
62
+ subject.build do
63
+ directory :from_dir => "spec", :to_dir => "my_config"
64
+ end
68
65
 
69
- it "should update existing zip file" do
70
- subject.build do
71
- file :name => "Gemfile"
66
+ subject.entry_exist?("my_config").should be_true
67
+ subject.entries_size.should > 1
72
68
  end
69
+ end
73
70
 
74
- File.exist?("#{subject.to_root}/#{subject.name}").should be_true
75
- subject.entry_exist?("Gemfile").should be_true
71
+ describe "#update" do
72
+ it "should update existing zip file" do
73
+ subject.build do
74
+ file :name => "Gemfile"
75
+ end
76
76
 
77
- subject.update do
78
- file :name => "README.md"
79
- directory :from_dir => "lib"
80
- end
77
+ File.exist?("#{subject.to_root}/#{subject.name}").should be_true
78
+ subject.entry_exist?("Gemfile").should be_true
81
79
 
82
- subject.entry_exist?("Gemfile").should be_true
83
- subject.entry_exist?("README.md").should be_true
84
- subject.entry_exist?("lib/zip_dsl/version.rb").should be_true
80
+ subject.update do
81
+ file :name => "README.md"
82
+ directory :from_dir => "lib"
83
+ end
84
+
85
+ subject.entry_exist?("Gemfile").should be_true
86
+ subject.entry_exist?("README.md").should be_true
87
+ subject.entry_exist?("lib/zip_dsl/version.rb").should be_true
88
+ end
85
89
  end
86
90
 
87
- it "should display files in current directory" do
88
- subject.build do
89
- directory :from_dir => "spec"
91
+ describe "#list" do
92
+ it "should display files in current directory" do
93
+ subject.build do
94
+ directory :from_dir => "spec"
95
+ end
96
+
97
+ subject.list.should include "spec/spec_helper.rb"
90
98
  end
91
99
 
92
- subject.list.should include "spec/spec_helper.rb"
93
- end
100
+ it "should display files in specified subdirectory" do
101
+ subject.build do
102
+ directory :from_dir => "lib"
103
+ end
94
104
 
95
- it "should display files in specified subdirectory" do
96
- subject.build do
97
- directory :from_dir => "lib"
105
+ subject.list("lib/zip_dsl").first.should =~ %r{lib/zip_dsl/version.rb}
98
106
  end
107
+ end
99
108
 
100
- subject.list("lib/zip_dsl").first.should =~ %r{lib/zip_dsl/version.rb}
109
+ describe "#each_entry" do
110
+ it "should display files in specified subdirectory" do
111
+ subject.build do
112
+ directory :from_dir => "lib"
113
+ end
114
+
115
+ contents = []
116
+
117
+ subject.each_entry("lib/zip_dsl") do |content|
118
+ contents << content
119
+ end
120
+
121
+ contents.first.name.should == "lib/zip_dsl/version.rb"
122
+ contents.first.get_input_stream.read.should =~ %r{class ZipDSL}
123
+ end
101
124
  end
102
125
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zip_dsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Shvets
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zip
@@ -93,6 +93,7 @@ files:
93
93
  - .idea/encodings.xml
94
94
  - .idea/misc.xml
95
95
  - .idea/modules.xml
96
+ - .idea/runConfigurations/rake.xml
96
97
  - .idea/scopes/scope_settings.xml
97
98
  - .idea/vcs.xml
98
99
  - .idea/workspace.xml