sample_file 0.0.1
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/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +5 -0
- data/lib/files/image/sample.gif +0 -0
- data/lib/files/image/sample.jpg +0 -0
- data/lib/files/image/sample.png +0 -0
- data/lib/files/video/h264.mp4 +0 -0
- data/lib/sample_file.rb +24 -0
- data/lib/sample_file/base.rb +17 -0
- data/lib/sample_file/image.rb +22 -0
- data/lib/sample_file/version.rb +3 -0
- data/lib/sample_file/video.rb +13 -0
- data/sample_file.gemspec +25 -0
- data/spec/sample_file/image_spec.rb +23 -0
- data/spec/sample_file/video_spec.rb +5 -0
- data/spec/sample_file_spec.rb +32 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/support/sample_file.rb +37 -0
- metadata +135 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Maarten Claes
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# SampleFile
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'sample_file'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install sample_file
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/lib/sample_file.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "sample_file/version"
|
2
|
+
require "sample_file/base"
|
3
|
+
require "sample_file/image"
|
4
|
+
require "sample_file/video"
|
5
|
+
|
6
|
+
module SampleFile
|
7
|
+
class << self
|
8
|
+
def image(type='png')
|
9
|
+
Image.new.file(type)
|
10
|
+
end
|
11
|
+
|
12
|
+
def image_path(type='png')
|
13
|
+
Image.new.file_path(type)
|
14
|
+
end
|
15
|
+
|
16
|
+
def video(type='h264')
|
17
|
+
Video.new.file(type)
|
18
|
+
end
|
19
|
+
|
20
|
+
def video_path(type='h264')
|
21
|
+
Video.new.file_path(type)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module SampleFile
|
2
|
+
class Base
|
3
|
+
def file(type=nil)
|
4
|
+
File.open file_path(type)
|
5
|
+
end
|
6
|
+
|
7
|
+
def file_path(type=nil)
|
8
|
+
raise NotImplementedError, "#{self.class} does not implement the file_path method"
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def base_path
|
14
|
+
@base_path ||= File.expand_path File.join(File.dirname(__FILE__), '..', 'files')
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module SampleFile
|
2
|
+
class Image < Base
|
3
|
+
def file_path(type='png')
|
4
|
+
filename = filename_for_type(type)
|
5
|
+
File.join(image_dir_path, filename)
|
6
|
+
end
|
7
|
+
|
8
|
+
def file(type='png')
|
9
|
+
super
|
10
|
+
end
|
11
|
+
|
12
|
+
protected
|
13
|
+
|
14
|
+
def image_dir_path
|
15
|
+
File.join(base_path, 'image')
|
16
|
+
end
|
17
|
+
|
18
|
+
def filename_for_type(type)
|
19
|
+
"sample.#{type}"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/sample_file.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sample_file/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "sample_file"
|
8
|
+
spec.version = SampleFile::VERSION
|
9
|
+
spec.authors = ["Maarten Claes"]
|
10
|
+
spec.email = ["maartencls@gmail.com"]
|
11
|
+
spec.description = %q{Sample files for testing purposes}
|
12
|
+
spec.summary = %q{Sample files for testing purposes}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "ruby-imagespec", "~> 0.3.1"
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SampleFile::Image do
|
4
|
+
it_behaves_like "a sample file", %w(gif png jpg)
|
5
|
+
|
6
|
+
image_types = {
|
7
|
+
gif: 'image/gif',
|
8
|
+
png: 'image/png',
|
9
|
+
jpg: 'image/jpeg'
|
10
|
+
}
|
11
|
+
|
12
|
+
image_types.each_pair do |image_type, content_type|
|
13
|
+
context "when requesting a '#{image_type}' image" do
|
14
|
+
describe :file do
|
15
|
+
it "is of the correct content type" do
|
16
|
+
data = ImageSpec.new(subject.file(image_type))
|
17
|
+
data.content_type.should == content_type
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SampleFile do
|
4
|
+
|
5
|
+
describe :image do
|
6
|
+
it "should call #file on a new instance of Image" do
|
7
|
+
described_class::Image.any_instance.should_receive(:file)
|
8
|
+
described_class.image
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe :image_path do
|
13
|
+
it "should call #file_path on a new instance of Image" do
|
14
|
+
described_class::Image.any_instance.should_receive(:file_path)
|
15
|
+
described_class.image_path
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :video do
|
20
|
+
it "should call #file on a new instance of Video" do
|
21
|
+
described_class::Video.any_instance.should_receive(:file)
|
22
|
+
described_class.video
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe :video_path do
|
27
|
+
it "should call #file_path on a new instance of Video" do
|
28
|
+
described_class::Video.any_instance.should_receive(:file_path)
|
29
|
+
described_class.video_path
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
shared_examples_for 'a sample file' do |file_types=[]|
|
2
|
+
|
3
|
+
describe :file_path do
|
4
|
+
context "when no file type is provided" do
|
5
|
+
it "should point to an existing file" do
|
6
|
+
File.exists?(subject.file_path).should be_true
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
file_types.each do |type|
|
11
|
+
context "when file_type is #{type}" do
|
12
|
+
it "should point to an existing file" do
|
13
|
+
File.exists?(subject.file_path(type)).should be_true
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe :file do
|
20
|
+
context "when no file type is provided" do
|
21
|
+
it "opens a file using file_path" do
|
22
|
+
File.should_receive(:open).with(subject.file_path)
|
23
|
+
subject.file
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
file_types.each do |type|
|
28
|
+
context "when file_type is #{type}" do
|
29
|
+
it "opens a file using file_path" do
|
30
|
+
File.should_receive(:open).with(subject.file_path(type))
|
31
|
+
subject.file(type)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sample_file
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Maarten Claes
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: ruby-imagespec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.3.1
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.3.1
|
78
|
+
description: Sample files for testing purposes
|
79
|
+
email:
|
80
|
+
- maartencls@gmail.com
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE.txt
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- lib/files/image/sample.gif
|
91
|
+
- lib/files/image/sample.jpg
|
92
|
+
- lib/files/image/sample.png
|
93
|
+
- lib/files/video/h264.mp4
|
94
|
+
- lib/sample_file.rb
|
95
|
+
- lib/sample_file/base.rb
|
96
|
+
- lib/sample_file/image.rb
|
97
|
+
- lib/sample_file/version.rb
|
98
|
+
- lib/sample_file/video.rb
|
99
|
+
- sample_file.gemspec
|
100
|
+
- spec/sample_file/image_spec.rb
|
101
|
+
- spec/sample_file/video_spec.rb
|
102
|
+
- spec/sample_file_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
104
|
+
- spec/support/sample_file.rb
|
105
|
+
homepage: ''
|
106
|
+
licenses:
|
107
|
+
- MIT
|
108
|
+
post_install_message:
|
109
|
+
rdoc_options: []
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
|
+
none: false
|
120
|
+
requirements:
|
121
|
+
- - '>='
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '0'
|
124
|
+
requirements: []
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 1.8.25
|
127
|
+
signing_key:
|
128
|
+
specification_version: 3
|
129
|
+
summary: Sample files for testing purposes
|
130
|
+
test_files:
|
131
|
+
- spec/sample_file/image_spec.rb
|
132
|
+
- spec/sample_file/video_spec.rb
|
133
|
+
- spec/sample_file_spec.rb
|
134
|
+
- spec/spec_helper.rb
|
135
|
+
- spec/support/sample_file.rb
|