jhc 0.0.1 → 0.0.2

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.
Files changed (4) hide show
  1. data/Gemfile +1 -0
  2. data/VERSION +1 -1
  3. data/bin/jhc +14 -3
  4. metadata +17 -3
data/Gemfile CHANGED
@@ -10,4 +10,5 @@ group :development do
10
10
  gem "bundler", "~> 1.0.0"
11
11
  gem "jeweler", "~> 1.6.4"
12
12
  gem "rcov", ">= 0"
13
+ gem "nokogiri"
13
14
  end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/jhc CHANGED
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/ruby
2
2
  # inspired by http://d.hatena.ne.jp/hitode909/20110614/1308032945
3
- # TODO: -e option (extract body from url)
4
3
  require 'yaml'
5
4
  require 'erb'
6
5
  require 'optparse'
7
6
  require 'open-uri'
8
7
  require 'fileutils'
8
+ require 'rubygems'
9
+ require 'nokogiri'
9
10
 
10
11
  CONFIG = <<EOC
11
12
  ---
@@ -39,6 +40,12 @@ def main(args)
39
40
  end
40
41
  end
41
42
 
43
+ body = nil
44
+ if opt['extract']
45
+ doc = Nokogiri::HTML.parse(open('http://www.google.com').read)
46
+ body = doc.search('/html/body').to_s
47
+ end
48
+
42
49
  erb = <<-HTML
43
50
  <!DOCTYPE html>
44
51
  <html>
@@ -56,8 +63,12 @@ def main(args)
56
63
  <% end -%>
57
64
  <% end -%>
58
65
  </head>
59
- <body>
60
- </body>
66
+ <% if body -%>
67
+ <%= body %>
68
+ <% else -%>
69
+ <body>
70
+ </body>
71
+ <% end -%>
61
72
  </html>
62
73
  HTML
63
74
  html = ERB.new(erb, nil, '-').result(binding)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jhc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - tily
@@ -77,6 +77,20 @@ dependencies:
77
77
  prerelease: false
78
78
  type: :development
79
79
  requirement: *id004
80
+ - !ruby/object:Gem::Dependency
81
+ version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ name: nokogiri
91
+ prerelease: false
92
+ type: :development
93
+ requirement: *id005
80
94
  description: generate modern html scaffold
81
95
  email: tily05@gmail.com
82
96
  executables: