minotaur 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad01d217b06eea96666bcdcb4c434623ddba89a8
4
+ data.tar.gz: 63a08ba1129822f290a17ef54d8b7fdf60734dd3
5
+ SHA512:
6
+ metadata.gz: c7609f266a84959df5f89dba25031fa2559c5e11dbadbebb05655a72ad9681cacaef329e4e3eded92666960b8d01bdfa4e7745984be85625b20b3cf60413c740
7
+ data.tar.gz: b50ad432dfddfd09b7f0325f67f8eb22f794b99a740080558da0a7861b09bc8e10e86915b30dd199700e68d3191ef6c868cbc3d51371269f04e6e22dd0c36199
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
@@ -0,0 +1,34 @@
1
+ Contributing
2
+ ============
3
+
4
+ We love pull requests. Here's a quick guide:
5
+
6
+ 1. Fork the repo.
7
+ 2. Run the tests. We only take pull requests with passing tests, and it's great
8
+ to know that you have a clean slate: `bundle && rspec`
9
+ 3. Add a test for your change. Only refactoring and documentation changes
10
+ require no new tests. If you are adding functionality or fixing a bug, we need
11
+ a test!
12
+ 4. Make the test pass.
13
+ 5. Make sure your changes adhere to the
14
+ [thoughtbot Style Guide](https://github.com/thoughtbot/guides/tree/master/style)
15
+ 6. Push to your fork and submit a Pull Request.
16
+ 7. At this point you're waiting on us. We like to at least comment on, if not
17
+ accept, Pull Requests within three business days (and, typically, one business
18
+ day). We may suggest some changes or improvements or alternatives.
19
+
20
+ Modified Sandi Metz Rules
21
+ -------------------------
22
+
23
+ These rules apply to new code and to changes to existing code. Even if you're
24
+ just adding one line, if you bump a class or method over the respective limit,
25
+ you will need to refactor to stay within these guidelines. We _really_ like
26
+ Liliputian code.
27
+
28
+ 1. Your classes can be no longer than a hundred lines of code.
29
+ 2. Your methods can be no longer than five lines of code.
30
+ 3. You can require no more than four parameters and you can't just make it one
31
+ big hash i.e., hash options are parameters.
32
+ 4. Rules are meant to be broken if by breaking them you produce better code.
33
+ [where "better code" is validated by explaining why you want to break the
34
+ rule to the person reviewing your pull request.]
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in minotaur.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Caleb Thompson
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.
@@ -0,0 +1,14 @@
1
+ # Minotaur
2
+
3
+ Extract images, videos, and iframes from html strings.
4
+
5
+ ![William Blake's image of the Minotaur to illustrate Inferno
6
+ XII](http://upload.wikimedia.org/wikipedia/commons/d/db/Blake_Dante_Hell_XII.jpg)
7
+
8
+ ## Usage
9
+
10
+ ```ruby
11
+ html = # download or build an html string
12
+ Minotaur::Document.new(html).preview_elements
13
+ # => ['<img>', '<video></video>', '<iframe></iframe>']
14
+ ```
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+ require 'minotaur/version'
3
+ require 'minotaur/document'
4
+
5
+ module Minotaur
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,18 @@
1
+ require 'nokogiri'
2
+ require 'pry'
3
+
4
+ module Minotaur
5
+ class Document
6
+ def initialize(html)
7
+ @html = Nokogiri::HTML(html)
8
+ end
9
+
10
+ def preview_elements
11
+ html.css('img, video, iframe').map(&:to_s)
12
+ end
13
+
14
+ private
15
+
16
+ attr_accessor :html
17
+ end
18
+ end
@@ -0,0 +1,3 @@
1
+ module Minotaur
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'minotaur/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'minotaur'
8
+ spec.version = Minotaur::VERSION
9
+ spec.authors = ['Caleb Thompson']
10
+ spec.email = ['cjaysson@gmail.com']
11
+ spec.description = <<-DESCRIPTION
12
+ If all the ways I have been along were marked on a map and joined up with a
13
+ line, it might represent a minotaur.
14
+ DESCRIPTION
15
+ spec.summary = 'it might represent a minotaur'
16
+ spec.homepage = 'https://github.com/calebthompson/minotaur'
17
+ spec.license = 'MIT'
18
+ spec.required_ruby_version = '>= 2.0.0'
19
+
20
+ spec.files = `git ls-files`.split($/)
21
+ spec.test_files = spec.files.grep(%r{^spec/})
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.requirements << 'libxml2'
25
+ spec.requirements << 'libxslt'
26
+
27
+ spec.add_dependency 'nokogiri'
28
+
29
+ spec.add_development_dependency 'bundler', '~> 1.3'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'pry'
32
+ spec.add_development_dependency 'rspec'
33
+ end
@@ -0,0 +1,37 @@
1
+ require 'spec_helper'
2
+
3
+ describe Minotaur::Document, 'preview_elements' do
4
+ it 'is empty for an empty string' do
5
+ document = Minotaur::Document.new('')
6
+
7
+ expect(document.preview_elements).to be_empty
8
+ end
9
+
10
+ it 'finds a video tag' do
11
+ html = '<video></video>'
12
+ document = Minotaur::Document.new(html)
13
+
14
+ expect(document.preview_elements).to eq [html]
15
+ end
16
+
17
+ it 'finds an iframe tag' do
18
+ html = '<iframe></iframe>'
19
+ document = Minotaur::Document.new(html)
20
+
21
+ expect(document.preview_elements).to eq [html]
22
+ end
23
+
24
+ it 'finds an image tag' do
25
+ html = '<img alt="Learn-ralph-small" src="/assets/learn/learn-ralph-small@2x.png" width="68" height="68">'
26
+ document = Minotaur::Document.new(html)
27
+
28
+ expect(document.preview_elements).to eq [html]
29
+ end
30
+
31
+ it 'finds ‘em all together' do
32
+ html = %w(<img> <iframe></iframe> <video></video>)
33
+ document = Minotaur::Document.new(html.join)
34
+
35
+ expect(document.preview_elements).to match_array html
36
+ end
37
+ end
@@ -0,0 +1 @@
1
+ require 'minotaur'
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: minotaur
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Caleb Thompson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-04-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: |2
84
+ If all the ways I have been along were marked on a map and joined up with a
85
+ line, it might represent a minotaur.
86
+ email:
87
+ - cjaysson@gmail.com
88
+ executables: []
89
+ extensions: []
90
+ extra_rdoc_files: []
91
+ files:
92
+ - .gitignore
93
+ - CONTRIBUTING.md
94
+ - Gemfile
95
+ - LICENSE
96
+ - README.md
97
+ - Rakefile
98
+ - lib/minotaur.rb
99
+ - lib/minotaur/document.rb
100
+ - lib/minotaur/version.rb
101
+ - minotaur.gemspec
102
+ - spec/minotaur/document_spec.rb
103
+ - spec/spec_helper.rb
104
+ homepage: https://github.com/calebthompson/minotaur
105
+ licenses:
106
+ - MIT
107
+ metadata: {}
108
+ post_install_message:
109
+ rdoc_options: []
110
+ require_paths:
111
+ - lib
112
+ required_ruby_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - '>='
115
+ - !ruby/object:Gem::Version
116
+ version: 2.0.0
117
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ requirements:
123
+ - libxml2
124
+ - libxslt
125
+ rubyforge_project:
126
+ rubygems_version: 2.0.0
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: it might represent a minotaur
130
+ test_files:
131
+ - spec/minotaur/document_spec.rb
132
+ - spec/spec_helper.rb