fakerama 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
@@ -0,0 +1,21 @@
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
data/Gemfile ADDED
@@ -0,0 +1,14 @@
1
+ # A sample Gemfile
2
+ source "http://rubygems.org"
3
+
4
+ gem "faker", "~> 0.3.1"
5
+ gem "actionpack"
6
+ gem "activesupport"
7
+
8
+ # gem "rails"
9
+ group :development do
10
+ gem 'jeweler', '~> 1.4.0'
11
+ gem "rspec", "~> 2.0.0.beta.22"
12
+ gem "rake"
13
+ end
14
+
@@ -0,0 +1,62 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ abstract (1.0.0)
5
+ actionpack (3.0.0)
6
+ activemodel (= 3.0.0)
7
+ activesupport (= 3.0.0)
8
+ builder (~> 2.1.2)
9
+ erubis (~> 2.6.6)
10
+ i18n (~> 0.4.1)
11
+ rack (~> 1.2.1)
12
+ rack-mount (~> 0.6.12)
13
+ rack-test (~> 0.5.4)
14
+ tzinfo (~> 0.3.23)
15
+ activemodel (3.0.0)
16
+ activesupport (= 3.0.0)
17
+ builder (~> 2.1.2)
18
+ i18n (~> 0.4.1)
19
+ activesupport (3.0.0)
20
+ builder (2.1.2)
21
+ diff-lcs (1.1.2)
22
+ erubis (2.6.6)
23
+ abstract (>= 1.0.0)
24
+ faker (0.3.1)
25
+ gemcutter (0.6.1)
26
+ git (1.2.5)
27
+ i18n (0.4.1)
28
+ jeweler (1.4.0)
29
+ gemcutter (>= 0.1.0)
30
+ git (>= 1.2.5)
31
+ rubyforge (>= 2.0.0)
32
+ json_pure (1.4.6)
33
+ rack (1.2.1)
34
+ rack-mount (0.6.13)
35
+ rack (>= 1.0.0)
36
+ rack-test (0.5.6)
37
+ rack (>= 1.0)
38
+ rake (0.8.7)
39
+ rspec (2.0.0.beta.22)
40
+ rspec-core (= 2.0.0.beta.22)
41
+ rspec-expectations (= 2.0.0.beta.22)
42
+ rspec-mocks (= 2.0.0.beta.22)
43
+ rspec-core (2.0.0.beta.22)
44
+ rspec-expectations (2.0.0.beta.22)
45
+ diff-lcs (>= 1.1.2)
46
+ rspec-mocks (2.0.0.beta.22)
47
+ rspec-core (= 2.0.0.beta.22)
48
+ rspec-expectations (= 2.0.0.beta.22)
49
+ rubyforge (2.0.4)
50
+ json_pure (>= 1.1.7)
51
+ tzinfo (0.3.23)
52
+
53
+ PLATFORMS
54
+ ruby
55
+
56
+ DEPENDENCIES
57
+ actionpack
58
+ activesupport
59
+ faker (~> 0.3.1)
60
+ jeweler (~> 1.4.0)
61
+ rake
62
+ rspec (~> 2.0.0.beta.22)
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Steve England
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,17 @@
1
+ = fakerama
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 Steve England. See LICENSE for details.
@@ -0,0 +1,41 @@
1
+ require "bundler"
2
+ Bundler.setup(:default, :development)
3
+ require "rspec/core/rake_task"
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "fakerama"
9
+ gem.summary = %Q{Create website content using Faker}
10
+ gem.description = %Q{Create website content using Faker. Incudes html content generation and stock files that can be used in your specs and or scripts}
11
+ gem.email = "steve@wearebeef.co.uk"
12
+ gem.homepage = "http://github.com/stengland/fakerama"
13
+ gem.authors = ["Steve England"]
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ gem.add_dependency 'faker'
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::GemcutterTasks.new
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
21
+ end
22
+
23
+ RSpec::Core::RakeTask.new(:spec)
24
+
25
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
26
+ spec.rcov = true
27
+ end
28
+
29
+ task :spec => :check_dependencies
30
+
31
+ task :default => :spec
32
+
33
+ require 'rake/rdoctask'
34
+ Rake::RDocTask.new do |rdoc|
35
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
36
+
37
+ rdoc.rdoc_dir = 'rdoc'
38
+ rdoc.title = "fakerama #{version}"
39
+ rdoc.rdoc_files.include('README*')
40
+ rdoc.rdoc_files.include('lib/**/*.rb')
41
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,3 @@
1
+ Example Document
2
+
3
+ hello@wearebeef.co.uk
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,7 @@
1
+ require 'faker'
2
+ require 'active_support/core_ext/string/output_safety'
3
+ require 'active_support/concern'
4
+ require 'action_view/helpers/capture_helper'
5
+ require 'action_view/helpers/tag_helper'
6
+ require 'fakerama/content'
7
+ require 'fakerama/asset'
@@ -0,0 +1,36 @@
1
+ module Fakerama
2
+ class Asset
3
+
4
+ # Configure files avaiable here
5
+ FILES = {
6
+ 'Advert' => ["banner.jpg", "mpu.jpg", "skyscraper.jpg", "small.jpg"],
7
+ 'Audio' => ["mp3.mp3", "ogg.ogg", "wav.wav"],
8
+ 'Document' => ["doc.doc", "pages.pages", "pdf.pdf", "txt.txt", "xls.xls"],
9
+ 'Flash' => ["fla.fla", "swf.swf"],
10
+ 'Photo' => ['portrait.jpg', 'landscape.jpg']
11
+ }
12
+
13
+ class << self
14
+ private
15
+ def new_file(filename)
16
+ File.new(File.expand_path(File.join(File.dirname(__FILE__),'..','..','assets',folder_name,filename)))
17
+ end
18
+
19
+ def folder_name
20
+ name.split('::').last.downcase
21
+ end
22
+ end
23
+
24
+
25
+ FILES.each_pair do |klass,files|
26
+ const_set(klass, Class.new(Asset) do
27
+ files.each do |file|
28
+ singleton_class.instance_eval do
29
+ define_method(file.split('.').first) { new_file(file) }
30
+ end
31
+ end
32
+ end)
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,44 @@
1
+ module Fakerama
2
+ class Content
3
+ class << self
4
+ include ActionView::Helpers::TagHelper
5
+
6
+ def headings(range = 1..6)
7
+ range.map do |size|
8
+ [filled_tag("h#{size}"), paragraph].join
9
+ end.to_s
10
+ end
11
+
12
+ def list(*args)
13
+ list_type = (args.first.to_s == 'ol') ? 'ol' : 'ul'
14
+ items = args.last.to_i.times.map do |i|
15
+ content_tag( :li, Faker::Lorem.sentence )
16
+ end
17
+ content_tag(list_type, items, {}, false)
18
+ end
19
+
20
+ def paragraphs(count=1)
21
+ count.times.map do
22
+ content_tag( :p, Faker::Lorem.paragraph )
23
+ end.to_s
24
+ end
25
+
26
+ alias :paragraph :paragraphs
27
+
28
+ def filled_tag(tag_name, type = :sentence, count = 3)
29
+ content_tag( tag_name, Faker::Lorem.send(type, count))
30
+ end
31
+
32
+ def content
33
+ [paragraphs(3),
34
+ headings(2..5),
35
+ filled_tag(:blockquote),
36
+ paragraph,
37
+ list(:ol, 5),
38
+ paragraph,
39
+ list(:ul, 3),
40
+ paragraphs(4)].shuffle.join
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ require File.expand_path('spec/spec_helper')
4
+
5
+ describe Fakerama::Asset do
6
+
7
+ it "should have some adverts" do
8
+ Fakerama::Asset::Advert.mpu.path.should =~ /mpu\.jpg$/
9
+ end
10
+
11
+ it "should have some photos" do
12
+ Fakerama::Asset::Photo.landscape.path.should =~ /landscape\.jpg$/
13
+ end
14
+
15
+
16
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe Fakerama::Content do
4
+ it "should create html headings" do
5
+ Fakerama::Content.headings(2..4).should =~ /<h2>/
6
+ Fakerama::Content.headings(2..4).should_not =~ /<h1>/
7
+ end
8
+
9
+ it "should create html lists" do
10
+ # Default ul
11
+ html = Fakerama::Content.list(4)
12
+ html.should match(/<ul>/)
13
+ html.should match(/(<li>.*){4}/)
14
+ html.should_not match(/(<li>.*){5}/)
15
+ # ol
16
+ html = Fakerama::Content.list(:ol, 4)
17
+ html.should_not match(/<ul>/)
18
+ html.should match(/<ol>/)
19
+ html.should match(/<li>/)
20
+ # ul
21
+ html = Fakerama::Content.list(:ul, 4)
22
+ html.should match(/<ul>/)
23
+ html.should match(/<li>/)
24
+ end
25
+
26
+ it "should create html paragraphs" do
27
+ html = Fakerama::Content.paragraphs(4)
28
+ html.should match(/(<p>.*){4}/)
29
+ html.should_not match(/(<p>.*){5}/)
30
+ end
31
+
32
+ it "should create other tags filled with content" do
33
+ Fakerama::Content.filled_tag('blockquote').should match(/<blockquote>.*<\/blockquote>/)
34
+ end
35
+
36
+ it "should generate content" do
37
+ Fakerama::Content.content
38
+ end
39
+ end
@@ -0,0 +1,5 @@
1
+ require 'fakerama'
2
+ require 'rspec'
3
+
4
+ Rspec.configure do |config|
5
+ end
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fakerama
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Steve England
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-08 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ prerelease: false
24
+ name: rspec
25
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ">="
29
+ - !ruby/object:Gem::Version
30
+ hash: 13
31
+ segments:
32
+ - 1
33
+ - 2
34
+ - 9
35
+ version: 1.2.9
36
+ requirement: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ type: :runtime
39
+ prerelease: false
40
+ name: faker
41
+ version_requirements: &id002 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ hash: 3
47
+ segments:
48
+ - 0
49
+ version: "0"
50
+ requirement: *id002
51
+ description: Create website content using Faker. Incudes html content generation and stock files that can be used in your specs and or scripts
52
+ email: steve@wearebeef.co.uk
53
+ executables: []
54
+
55
+ extensions: []
56
+
57
+ extra_rdoc_files:
58
+ - LICENSE
59
+ - README.rdoc
60
+ files:
61
+ - .document
62
+ - .gitignore
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - LICENSE
66
+ - README.rdoc
67
+ - Rakefile
68
+ - VERSION
69
+ - assets/advert/banner.jpg
70
+ - assets/advert/mpu.jpg
71
+ - assets/advert/skyscraper.jpg
72
+ - assets/advert/small.jpg
73
+ - assets/audio/mp3.mp3
74
+ - assets/audio/ogg.ogg
75
+ - assets/audio/wav.wav
76
+ - assets/document/doc.doc
77
+ - assets/document/pages.pages
78
+ - assets/document/pdf.pdf
79
+ - assets/document/txt.txt
80
+ - assets/document/xls.xls
81
+ - assets/flash/fla.fla
82
+ - assets/flash/swf.swf
83
+ - assets/photo/landscape.jpg
84
+ - assets/photo/portrait.jpg
85
+ - lib/fakerama.rb
86
+ - lib/fakerama/asset.rb
87
+ - lib/fakerama/content.rb
88
+ - spec/asset_spec.rb
89
+ - spec/content_spec.rb
90
+ - spec/spec_helper.rb
91
+ has_rdoc: true
92
+ homepage: http://github.com/stengland/fakerama
93
+ licenses: []
94
+
95
+ post_install_message:
96
+ rdoc_options:
97
+ - --charset=UTF-8
98
+ require_paths:
99
+ - lib
100
+ required_ruby_version: !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ hash: 3
106
+ segments:
107
+ - 0
108
+ version: "0"
109
+ required_rubygems_version: !ruby/object:Gem::Requirement
110
+ none: false
111
+ requirements:
112
+ - - ">="
113
+ - !ruby/object:Gem::Version
114
+ hash: 3
115
+ segments:
116
+ - 0
117
+ version: "0"
118
+ requirements: []
119
+
120
+ rubyforge_project:
121
+ rubygems_version: 1.3.7
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Create website content using Faker
125
+ test_files:
126
+ - spec/asset_spec.rb
127
+ - spec/content_spec.rb
128
+ - spec/spec_helper.rb