dummy_files 0.0.10 → 0.0.11

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.10
1
+ 0.0.11
data/dummy_files.gemspec CHANGED
@@ -1,46 +1,44 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{dummy_files}
8
- s.version = "0.0.10"
8
+ s.version = "0.0.11"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jordi Noguera"]
12
- s.date = %q{2010-07-13}
12
+ s.date = %q{2011-02-17}
13
13
  s.description = %q{Pull urls of random images/files from google searches to generate sample data.}
14
14
  s.email = %q{jordinoguera83@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.rdoc"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
- ".gitignore",
22
- ".project",
23
- "LICENSE",
24
- "README.rdoc",
25
- "Rakefile",
26
- "VERSION",
27
- "dummy_files.gemspec",
28
- "lib/dummy_files.rb",
29
- "test/helper.rb",
30
- "test/test_dummy_files.rb"
21
+ ".project",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "dummy_files.gemspec",
27
+ "lib/dummy_files.rb",
28
+ "test/helper.rb",
29
+ "test/test_dummy_files.rb",
30
+ "tools/console"
31
31
  ]
32
32
  s.homepage = %q{http://github.com/jordinl/dummy_files}
33
- s.rdoc_options = ["--charset=UTF-8"]
34
33
  s.require_paths = ["lib"]
35
- s.rubygems_version = %q{1.3.7}
34
+ s.rubygems_version = %q{1.5.2}
36
35
  s.summary = %q{URLs for sample data generation}
37
36
  s.test_files = [
38
37
  "test/helper.rb",
39
- "test/test_dummy_files.rb"
38
+ "test/test_dummy_files.rb"
40
39
  ]
41
40
 
42
41
  if s.respond_to? :specification_version then
43
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
44
42
  s.specification_version = 3
45
43
 
46
44
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
data/lib/dummy_files.rb CHANGED
@@ -8,17 +8,19 @@ module DummyFiles
8
8
  def self.get(number = 100, keyword = "me", content = "face")
9
9
  max = [number / 10, 1].max
10
10
  nokogiri = (1..max).map{ Nokogiri::HTML(open_page(keyword, content)) }
11
- nokogiri.map{ |n| n.search("img").map{ |x| x["src"] }.select{ |x| x.include?(":http://") }.map{ |x| "http://" + x.split(":http://")[1] } }.flatten[0, number]
11
+ nokogiri.map do |n|
12
+ n.search("a img").map{ |x| x["src"].split(":http://")[1] }.compact.map(&:to_url)
13
+ end.flatten[0, number]
12
14
  end
13
15
 
14
16
  private
15
17
 
16
- def self.get_url(keyword, content)
17
- "http://www.google.com/images?q=#{keyword}&hl=en&safe=active&gbv=2&tbs=isch:1" +
18
+ def self.get_url(keyword = 'me', content = 'face')
19
+ "http://www.google.com/images?q=#{keyword}&hl=en&safe=active&biw=1280&bih=653&gbv=1&as_st=y&tbs=isch:1" +
18
20
  if content == "any"
19
- "&source=lnt&sa=X&ei=80w5TID9F4KUjAfe1t36Aw&ved=0CDMQpwU&start=#{(1..850).random}&ndsp=20"
21
+ "&ei=Mq9dTciKKsmytAa9lKTKCg&start=#{(1..850)}&sa=N"
20
22
  else
21
- ",itp:face&source=lnt&sa=X&ei=S005TMaOBYKUjAeE2N36Aw&ved=0CAwQpwU4FA&start=#{(1..850).random}&ndsp=20"
23
+ ",itp:face&ei=cq5dTe7UFomLswajlbDXCg&start=#{(1..850).random}&sa=N"
22
24
  end
23
25
  end
24
26
 
@@ -77,3 +79,9 @@ class Range
77
79
  first + rand(last)
78
80
  end
79
81
  end
82
+
83
+ class String
84
+ def to_url
85
+ "http://" + self
86
+ end
87
+ end
data/tools/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'nokogiri'
4
+
5
+ @file = 'lib/dummy_files.rb'
6
+
7
+ require @file
8
+
9
+ def reload!
10
+ load @file
11
+ end
12
+
13
+ require 'irb'
14
+ require 'irb/completion'
15
+ IRB.start
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dummy_files
3
3
  version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease: false
4
+ hash: 9
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 10
10
- version: 0.0.10
9
+ - 11
10
+ version: 0.0.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jordi Noguera
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-07-13 00:00:00 +01:00
18
+ date: 2011-02-17 00:00:00 +00:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -59,7 +59,6 @@ extra_rdoc_files:
59
59
  - README.rdoc
60
60
  files:
61
61
  - .document
62
- - .gitignore
63
62
  - .project
64
63
  - LICENSE
65
64
  - README.rdoc
@@ -69,13 +68,14 @@ files:
69
68
  - lib/dummy_files.rb
70
69
  - test/helper.rb
71
70
  - test/test_dummy_files.rb
71
+ - tools/console
72
72
  has_rdoc: true
73
73
  homepage: http://github.com/jordinl/dummy_files
74
74
  licenses: []
75
75
 
76
76
  post_install_message:
77
- rdoc_options:
78
- - --charset=UTF-8
77
+ rdoc_options: []
78
+
79
79
  require_paths:
80
80
  - lib
81
81
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  requirements: []
100
100
 
101
101
  rubyforge_project:
102
- rubygems_version: 1.3.7
102
+ rubygems_version: 1.5.2
103
103
  signing_key:
104
104
  specification_version: 3
105
105
  summary: URLs for sample data generation
data/.gitignore DELETED
@@ -1,21 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC