microformats 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c0e2d46df6df0a2df0e8dfa27d33e61e1327d1f
4
- data.tar.gz: 0e1ad7b965a34f19fd3593f4740d93751c9ec022
3
+ metadata.gz: 782c4644eac7e969915cb788d5e93849653e94dc
4
+ data.tar.gz: d9e1cc5d37ee4115412431a6f56957abbfccc9b0
5
5
  SHA512:
6
- metadata.gz: f5dc7e236af033b40fdf763c2682588ed08fce8fe6e38fbfcd3c32512e978835e87865780ca667a979e275ce28afe656d9a554298cd2389a2ab4e53369b83c08
7
- data.tar.gz: 6a5f738f750ff5d66a444a86db2b2ba86771073c58ed215fbce9f91a5da95ff24170ef0318abb32f6ec2ab84c9caab1a3cd0b865a07c8526867bea1fe862a112
6
+ metadata.gz: 4f6ea2627813c51d87cd7bfd764c9f1966d0f0c5708023fd4a473c3aea157008b01df1a89f1d936f8b16c07dafb98e1f856151171f3fbcac1dfb8cf30faeae9f
7
+ data.tar.gz: 61d6557764e72d320679b683f9de610a24682aa55227a2b2d35b9d13b2ccbd21ebbd8dc466d33238dccdb6bbc8b79ed35a0eb66fc176aaf82d1152575797a70c
data/README.md CHANGED
@@ -34,9 +34,9 @@ Not Implemented:
34
34
 
35
35
  ## Current Version
36
36
 
37
- 4.0.1
37
+ 4.0.2
38
38
 
39
- ![Version 4.0.1](https://img.shields.io/badge/VERSION-4.0.1-green.svg)
39
+ ![Version 4.0.2](https://img.shields.io/badge/VERSION-4.0.2-green.svg)
40
40
 
41
41
 
42
42
  ## Requirements
@@ -122,6 +122,22 @@ collection.entry.author(:all)[1].name #=> "Brandon Edens"
122
122
 
123
123
  * `source` can be a URL, filepath, or HTML
124
124
 
125
+ ### Console utility
126
+
127
+ This gem also provides a command like script 'microformats' that will return the JSON equivalent
128
+ ```
129
+ microformats http://example.com
130
+ ```
131
+
132
+ You can give the microformats script a URL, filepath, or HTML
133
+
134
+ additionally, the script will accept input piped from stdin
135
+
136
+ ```
137
+ curl http://example.com | microformats
138
+ ```
139
+
140
+
125
141
 
126
142
  ## Ruby Gem release process
127
143
 
@@ -212,9 +228,8 @@ This uses a copy of [microformats tests repo](https://github.com/microformats/t
212
228
  To run specs
213
229
  ```
214
230
  rake spec
215
- ```
216
231
 
217
- ###Interactive
232
+ ### Interactive
218
233
 
219
234
  You can use the code interacively for testing but running
220
235
  ```
data/bin/microformats ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'microformats'
4
+ require 'json'
5
+
6
+ def print_usage
7
+ puts "Usage: microformats (URL, filepath, or HTML)"
8
+ end
9
+
10
+ def process_html(html)
11
+ collection = Microformats.parse(html)
12
+ puts JSON.pretty_generate(JSON[collection.to_json.to_s])
13
+ end
14
+
15
+ if STDIN.tty?
16
+ unless ARGV[0].nil?
17
+ process_html(ARGV[0])
18
+ else
19
+ print_usage
20
+ end
21
+ else
22
+ html = STDIN.read
23
+ unless html.nil?
24
+ process_html(html)
25
+ else
26
+ print_usage
27
+ end
28
+ end
@@ -5,11 +5,12 @@ module Microformats
5
5
  def initialize(relative, base: nil)
6
6
  @base = base
7
7
  @relative = relative
8
- @base.strip! unless @base.nil?
9
- @relative.strip! unless @relative.nil?
8
+ @base = base.strip unless base.nil?
9
+ @relative = relative.strip unless relative.nil?
10
10
  end
11
11
 
12
12
  def absolutize
13
+ return relative if base.nil?
13
14
  return base if relative.nil? or relative == ""
14
15
  return relative if relative =~ /^https?:\/\//
15
16
  return base + relative if relative =~ /^#/
@@ -1,3 +1,3 @@
1
1
  module Microformats
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.2"
3
3
  end
data/microformats.gemspec CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
13
13
  gem.homepage = "https://github.com/indieweb/microformats-ruby"
14
14
 
15
15
  gem.files = `git ls-files`.split($/)
16
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
+ gem.executables = ['microformats']
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microformats
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane Becker
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-05-18 00:00:00.000000000 Z
13
+ date: 2017-05-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: nokogiri
@@ -131,7 +131,8 @@ email:
131
131
  - veganstraightedge@gmail.com
132
132
  - jlsuttles@gmail.com
133
133
  - ben@thatmustbe.me
134
- executables: []
134
+ executables:
135
+ - microformats
135
136
  extensions: []
136
137
  extra_rdoc_files: []
137
138
  files:
@@ -143,6 +144,7 @@ files:
143
144
  - LICENSE.md
144
145
  - README.md
145
146
  - Rakefile
147
+ - bin/microformats
146
148
  - lib/microformats.rb
147
149
  - lib/microformats/absolute_uri.rb
148
150
  - lib/microformats/format_parser.rb