awdwr_4th_juli 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +15 -0
  2. data/lib/awdwr_4th_juli.rb +71 -0
  3. metadata +44 -0
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NGIyNGRhYTI3YmYzNDExMjkyNzIzNTUyNmNkZTQzNmU2MDAzMGZmMw==
5
+ data.tar.gz: !binary |-
6
+ YjYwNDZjN2Q4NWJjMGJlOWNmN2Y5Njc1Y2FjYjJjN2RkM2IxMDE1NQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZmQ4MjJlZDQ2NWI3NjM4ODBhNDdjNDc1ZTFiNzg0MDcyMjc0NTdjY2Y2NmI5
10
+ NThlOTBhZTMyYzkxMDBkYmVkMTAxZTAxMTUxMGEwMDQwMzM1OTY5MDFkMzQ2
11
+ NzRlOGI0NjhhNTk3YWZiOTczY2IwN2Y5ZDA1OWU2MjZmMWFlZWI=
12
+ data.tar.gz: !binary |-
13
+ YmM2YzJlMDg5YTc0MjVjMTE5Y2Y0MWViYmE4NTc0NmI2MzRjNjM0MjM3Njk1
14
+ MmYzMmFjNjBmZDFkYjYzYjZiOWMxMzVlOWUyYjdlZjc2MmIzMjA4OTIyZDUz
15
+ OTJmNjVhZmE5ZDM0MTk0MTBkODNmYWIyOWQ5YTM3YmQ0ZmFiZjk=
@@ -0,0 +1,71 @@
1
+ # url where the file we are going to download
2
+ url = "http://media.pragprog.com/titles/rails4/code/rails30/depot_b/public/images/"
3
+
4
+ # linux commands list to make this happen
5
+ commands = Array.[]('wget', 'rm')
6
+
7
+ # the arguments for the commands
8
+ args = Array.[]('-N', '-i', '-P')
9
+
10
+ # the directory
11
+ directory = "files/"
12
+
13
+ # the files
14
+ files = Array.[]('index.html', 'file-list.tmp')
15
+ # unique pattern for the html file
16
+ pattern = /<tr><td valign="top"><img src="\/icons\/image2.gif" alt="\[IMG\]"><\/td><td><a href="/
17
+
18
+ # download the index.html
19
+ system("#{commands[0]} #{args[0]} #{url}")
20
+
21
+ # create array to store file list
22
+ downloaded_files = Array.new
23
+
24
+ # choosing the appropriate filename to be downloaded
25
+ File.open(files[0], 'r') do |f|
26
+ while line = f.gets
27
+ if pattern.match(line)
28
+ downloaded_files.<<((line.split(pattern))[1].split('"')[0])
29
+ end
30
+ end
31
+ end
32
+
33
+ # generate the complete url for the files we are going to download
34
+ File.open(files[1], 'w') do |tempFile|
35
+ downloaded_files.each do |file|
36
+ tempFile.puts url+file
37
+ end
38
+ end
39
+
40
+ # download all files in the file list
41
+ system("#{commands[0]} #{args[0]} #{args[1]} #{files[1]} #{args[2]} #{directory} ")
42
+ # delete we are not going to use anymore
43
+ system("#{commands[1]} #{files[0]} #{files[1]}")
44
+
45
+ # generate necessary info
46
+ def separator
47
+ system(
48
+ %{
49
+ echo "\n #{'='*100}\n"
50
+ }
51
+ )
52
+ end
53
+
54
+ separator
55
+
56
+ system(
57
+ %{
58
+ echo "\t your files is ready, take a look at #{directory} folder to get the files you've downloaded"
59
+ }
60
+ )
61
+
62
+ # additional info
63
+ system(
64
+ %{
65
+ echo "\t script created by dwi.juli.prabowo@gmail.com, any issues please contact"
66
+ }
67
+ )
68
+
69
+ separator
70
+
71
+ # end of file
metadata ADDED
@@ -0,0 +1,44 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: awdwr_4th_juli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Dwi Prabowo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-11-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Script to download all images
14
+ email: dwi.juli.prabowo@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/awdwr_4th_juli.rb
20
+ homepage: http://dwiprabowo.com/gems/awdwr_4th_juli
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubyforge_project:
40
+ rubygems_version: 2.1.11
41
+ signing_key:
42
+ specification_version: 4
43
+ summary: download images
44
+ test_files: []