mrhyde-tools 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +0 -4
- data/Rakefile +2 -1
- data/bin/mrh +0 -0
- data/bin/mrhyde +0 -0
- data/lib/mrhyde.rb +2 -3
- data/lib/mrhyde/builder.rb +7 -3
- data/lib/mrhyde/cli/main.rb +3 -0
- data/lib/mrhyde/version.rb +1 -1
- data/test/test_builder.rb +2 -2
- data/test/test_install_theme.rb +1 -1
- data/test/test_url.rb +5 -0
- metadata +20 -15
- data/lib/mrhyde/config.rb +0 -60
- data/lib/mrhyde/wizard.rb +0 -88
- data/test/test_config.rb +0 -31
- data/test/test_wizard.rb +0 -50
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f12cb63c722e3cff55bf0744d02bd0eb071cb53
|
4
|
+
data.tar.gz: 7261bfea0eb19519ffb257a1497b4de74103cb0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4294554f67b38375e1b18b9d52df49a4da0834e73596997de1a3dfa0d2eabb56b6a96cccb4f1a0aecd169c6a8e39dd92249c8af9463f9da4699f3e6317c9d7e
|
7
|
+
data.tar.gz: 72ebbcb37e690c72e34bc7419cad942db7ee46547d1e38078cd1588b602d55aeb5d57fdc189aec0de679d777b8ad0280a361fa9d6482c7a57f4da5f0c11477c9
|
data/Manifest.txt
CHANGED
@@ -8,15 +8,11 @@ lib/mrhyde.rb
|
|
8
8
|
lib/mrhyde/builder.rb
|
9
9
|
lib/mrhyde/cli/main.rb
|
10
10
|
lib/mrhyde/cli/opts.rb
|
11
|
-
lib/mrhyde/config.rb
|
12
11
|
lib/mrhyde/tools.rb
|
13
12
|
lib/mrhyde/version.rb
|
14
|
-
lib/mrhyde/wizard.rb
|
15
13
|
test/helper.rb
|
16
14
|
test/scripts/starter.rb
|
17
15
|
test/scripts/starterii.rb
|
18
16
|
test/test_builder.rb
|
19
|
-
test/test_config.rb
|
20
17
|
test/test_install_theme.rb
|
21
18
|
test/test_url.rb
|
22
|
-
test/test_wizard.rb
|
data/Rakefile
CHANGED
data/bin/mrh
CHANGED
File without changes
|
data/bin/mrhyde
CHANGED
File without changes
|
data/lib/mrhyde.rb
CHANGED
@@ -8,13 +8,12 @@ require 'uri'
|
|
8
8
|
|
9
9
|
## 3rd party libs
|
10
10
|
require 'textutils' ## used for File.read_utf8
|
11
|
-
require 'drjekyll'
|
11
|
+
require 'drjekyll'
|
12
|
+
require 'quik' ## used for wizards, (open)config etc.
|
12
13
|
|
13
14
|
## our own code
|
14
15
|
require 'mrhyde/version' # note: let version always go first
|
15
|
-
require 'mrhyde/wizard'
|
16
16
|
require 'mrhyde/builder'
|
17
|
-
require 'mrhyde/config'
|
18
17
|
|
19
18
|
require 'mrhyde/cli/opts'
|
20
19
|
require 'mrhyde/cli/main'
|
data/lib/mrhyde/builder.rb
CHANGED
@@ -16,7 +16,7 @@ class Builder
|
|
16
16
|
end
|
17
17
|
|
18
18
|
|
19
|
-
include Wizard ## mixin helpers for say, ask, yes?, no?, select, etc.
|
19
|
+
include Quik::Wizard ## mixin helpers for say, ask, yes?, no?, select, etc.
|
20
20
|
|
21
21
|
def initialize( opts={} )
|
22
22
|
puts "starting new MrHyde script (sitefile) #{opts.inspect}; lets go"
|
@@ -39,7 +39,8 @@ class Builder
|
|
39
39
|
|
40
40
|
## themes_dir = "#{DrJekyll.root}/test/data"
|
41
41
|
## catalog = Catalog.new( "#{themes_dir}/themes.yml" )
|
42
|
-
url = "https://github.com/drjekyllthemes/themes/raw/master/
|
42
|
+
url = "https://github.com/drjekyllthemes/themes/raw/master/themes.yml"
|
43
|
+
puts "GET #{url}" ## todo - add color e.g. .bold.green
|
43
44
|
|
44
45
|
if test?
|
45
46
|
# do nothing; dry run
|
@@ -48,6 +49,9 @@ class Builder
|
|
48
49
|
theme = catalog.find( key )
|
49
50
|
if theme
|
50
51
|
pak = DrJekyll::Package.new( key, theme )
|
52
|
+
|
53
|
+
## todo/fix:
|
54
|
+
## add GET URL w/ color e.g. bright/bold green
|
51
55
|
pak.download
|
52
56
|
pak.unzip( "#{@output_dir}/#{key}" )
|
53
57
|
else
|
@@ -60,7 +64,7 @@ class Builder
|
|
60
64
|
|
61
65
|
def config( opts={} )
|
62
66
|
puts " handle config block"
|
63
|
-
c = OpenConfig.new
|
67
|
+
c = Quik::OpenConfig.new
|
64
68
|
yield( c )
|
65
69
|
## pp c
|
66
70
|
h = c.to_h
|
data/lib/mrhyde/cli/main.rb
CHANGED
@@ -57,6 +57,9 @@ def self.fetch_script( name )
|
|
57
57
|
text = File.read_utf8( local_script )
|
58
58
|
else ## fetch remote script
|
59
59
|
url = "https://github.com/mrhydescripts/scripts/raw/master/#{name}.rb"
|
60
|
+
|
61
|
+
puts "GET #{url}" ## todo - add color e.g. .bold.green
|
62
|
+
|
60
63
|
## assume utf8 text encoding for now
|
61
64
|
worker = Fetcher::Worker.new
|
62
65
|
text = worker.read_utf8!( url )
|
data/lib/mrhyde/version.rb
CHANGED
data/test/test_builder.rb
CHANGED
@@ -12,7 +12,7 @@ class TestBuilder < MiniTest::Test
|
|
12
12
|
|
13
13
|
def test_starter
|
14
14
|
|
15
|
-
$
|
15
|
+
$QUIK_WIZARD_IN = EchoIO.new( <<EOS )
|
16
16
|
Another Beautiful Static Site
|
17
17
|
H. J.
|
18
18
|
EOS
|
@@ -24,7 +24,7 @@ EOS
|
|
24
24
|
|
25
25
|
def test_starterii
|
26
26
|
|
27
|
-
$
|
27
|
+
$QUIK_WIZARD_IN = EchoIO.new( <<EOS )
|
28
28
|
Another Beautiful Static Site
|
29
29
|
http://example.github.io/repo
|
30
30
|
H. J.
|
data/test/test_install_theme.rb
CHANGED
data/test/test_url.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mrhyde-tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logutils
|
@@ -44,14 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 0.1.1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 0.1.1
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: quik
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.3'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: rdoc
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,18 +117,14 @@ files:
|
|
103
117
|
- lib/mrhyde/builder.rb
|
104
118
|
- lib/mrhyde/cli/main.rb
|
105
119
|
- lib/mrhyde/cli/opts.rb
|
106
|
-
- lib/mrhyde/config.rb
|
107
120
|
- lib/mrhyde/tools.rb
|
108
121
|
- lib/mrhyde/version.rb
|
109
|
-
- lib/mrhyde/wizard.rb
|
110
122
|
- test/helper.rb
|
111
123
|
- test/scripts/starter.rb
|
112
124
|
- test/scripts/starterii.rb
|
113
125
|
- test/test_builder.rb
|
114
|
-
- test/test_config.rb
|
115
126
|
- test/test_install_theme.rb
|
116
127
|
- test/test_url.rb
|
117
|
-
- test/test_wizard.rb
|
118
128
|
homepage: https://github.com/mrhydescripts/mrhyde
|
119
129
|
licenses:
|
120
130
|
- Public Domain
|
@@ -137,13 +147,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
147
|
version: '0'
|
138
148
|
requirements: []
|
139
149
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.2.3
|
141
151
|
signing_key:
|
142
152
|
specification_version: 4
|
143
153
|
summary: mrhyde - jekyll command line tool .:. static site quick starter script wizard
|
144
|
-
test_files:
|
145
|
-
- test/test_wizard.rb
|
146
|
-
- test/test_install_theme.rb
|
147
|
-
- test/test_builder.rb
|
148
|
-
- test/test_config.rb
|
149
|
-
- test/test_url.rb
|
154
|
+
test_files: []
|
data/lib/mrhyde/config.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
module MrHyde
|
4
|
-
|
5
|
-
##
|
6
|
-
# used for config block
|
7
|
-
# lets you access props (even nested) that don't yet exist
|
8
|
-
# and all props get stored in a hash
|
9
|
-
#
|
10
|
-
# e.g
|
11
|
-
# c = OpenConfig.new
|
12
|
-
# c.title = 'title'
|
13
|
-
# c.author.name = 'name'
|
14
|
-
|
15
|
-
# c.mrhyde.last_updated = Time.now
|
16
|
-
# c.mrhyde.title = 'title'
|
17
|
-
# c.mrhyde.name = 'name'
|
18
|
-
# c.mrhyde.theme = 'theme'
|
19
|
-
|
20
|
-
class OpenConfig
|
21
|
-
|
22
|
-
def initialize
|
23
|
-
@h = {}
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_h
|
27
|
-
h = {}
|
28
|
-
@h.each do |k,v|
|
29
|
-
if v.is_a? OpenConfig
|
30
|
-
h[ k ] = v.to_h
|
31
|
-
else
|
32
|
-
h[ k ] = v ## just pass along as is
|
33
|
-
end
|
34
|
-
end
|
35
|
-
h
|
36
|
-
end
|
37
|
-
|
38
|
-
def method_missing( m, *args, &block)
|
39
|
-
if m.to_s =~ /^(.*)=$/ ## setter
|
40
|
-
puts "config lookup (setter) >#{m}< #{m.class.name}, #{args.inspect}"
|
41
|
-
key = m[0..-2].to_s ## cut off trailing =
|
42
|
-
@h[ key ] = args[0].to_s # note: assume first arg is value for setter
|
43
|
-
# note: for now all values are strings (always use to_s)
|
44
|
-
else ## assume getter
|
45
|
-
## fix: add check for args?? must be 0 for getters??
|
46
|
-
## use else super to delegate non-getters??
|
47
|
-
puts "config lookup (getter) >#{m}< #{m.class.name}"
|
48
|
-
key = m.to_s
|
49
|
-
value = @h[ key ]
|
50
|
-
if value.nil?
|
51
|
-
puts " config add (nested) hash"
|
52
|
-
value = @h[ key ] = OpenConfig.new
|
53
|
-
end
|
54
|
-
value
|
55
|
-
end
|
56
|
-
end # method_missing
|
57
|
-
|
58
|
-
end # class OpenConfig
|
59
|
-
|
60
|
-
end # module MrHyde
|
data/lib/mrhyde/wizard.rb
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
|
4
|
-
## note:
|
5
|
-
## use global $MRHYDE_WIZARD_STDIN
|
6
|
-
## lets you redirect stdin for testing e.g $MRHYDE_WIZARD_STDIN = StringIO.new( 'test/n' )
|
7
|
-
$MRHYDE_WIZARD_IN = $stdin
|
8
|
-
|
9
|
-
|
10
|
-
module MrHyde
|
11
|
-
|
12
|
-
module Wizard ## use a different name e.g. WizardHelpers, FormHelpers, InputHelper, etc - why, why not??
|
13
|
-
|
14
|
-
def getstr ## use getstr to avoid conflict w/ gets (use better name? read_string, readline (already exists too), etc.?)
|
15
|
-
## note: gets will include trailing newline (user hits return to enter data)
|
16
|
-
## - use strip for now (remove leading and traling whitspaces) - might later just use chomp ? (jsut removes newlines)
|
17
|
-
$MRHYDE_WIZARD_IN.gets.strip
|
18
|
-
end
|
19
|
-
|
20
|
-
def say( text )
|
21
|
-
puts text
|
22
|
-
end
|
23
|
-
|
24
|
-
|
25
|
-
YES_REGEX = /y|yes|on|t|true/i ## support YAML true values - double check (YAML does NOT support t/f)
|
26
|
-
NO_REGEX = /n|no|off|f|false/i
|
27
|
-
|
28
|
-
def yes?( question ) ## defaults to yes - why, why not??
|
29
|
-
## todo: strip trailing question mark (?) if present (gets auto-included)
|
30
|
-
print( "Q: #{question} (y/n)? [y]: " )
|
31
|
-
str = getstr
|
32
|
-
if str.empty? || str =~ YES_REGEX
|
33
|
-
true
|
34
|
-
elsif str =~ NO_REGEX
|
35
|
-
false
|
36
|
-
else ## warn: unknown value??
|
37
|
-
true
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def no?( question ) ## defaults to yes - why, why not??
|
42
|
-
## todo: strip trailing question mark (?) if present (gets auto-included)
|
43
|
-
print( "Q: #{question} (y/n)? [n]: " )
|
44
|
-
str = getstr
|
45
|
-
if str.empty? || str =~ NO_REGEX
|
46
|
-
true
|
47
|
-
elsif str =~ YES_REGEX
|
48
|
-
false
|
49
|
-
else ## warn: unknown value??
|
50
|
-
true
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
|
-
def ask( question, default=nil )
|
56
|
-
## todo: strip trailing question mark (?) if present (gets auto-included)
|
57
|
-
if default
|
58
|
-
print( "Q: #{question}? [#{default}]: " )
|
59
|
-
else
|
60
|
-
print( "Q: #{question}?: " )
|
61
|
-
end
|
62
|
-
|
63
|
-
str = getstr
|
64
|
-
if default && str.empty? ## todo: best way to check for empty string?
|
65
|
-
str = default
|
66
|
-
end
|
67
|
-
str
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def select( title, options )
|
72
|
-
puts( "Q: #{title}: " )
|
73
|
-
options.each_with_index do |opt,i|
|
74
|
-
puts " #{i+1} - #{opt}"
|
75
|
-
end
|
76
|
-
print( " Your choice (1-#{options.size})? [1]: " )
|
77
|
-
str = getstr
|
78
|
-
if str.empty? ## todo: best way to check for empty string?
|
79
|
-
num = 0 ## default to first option for now
|
80
|
-
else
|
81
|
-
num = str.to_i ## note: defaults to 0 if cannot convert?
|
82
|
-
num -= 1 if num > 0 ## note: "convert" from 1-based to 0-based for ary; if invalid entry; default to 0
|
83
|
-
end
|
84
|
-
options[ num ]
|
85
|
-
end
|
86
|
-
|
87
|
-
end # module Wizard
|
88
|
-
end # module MrHyde
|
data/test/test_config.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_config.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestConfig < MiniTest::Test
|
12
|
-
|
13
|
-
def test_config
|
14
|
-
|
15
|
-
c = MrHyde::OpenConfig.new
|
16
|
-
c.title = 'title'
|
17
|
-
c.author.name = 'name'
|
18
|
-
|
19
|
-
c.mrhyde.last_updated = Time.now
|
20
|
-
c.mrhyde.title = 'title'
|
21
|
-
c.mrhyde.name = 'name'
|
22
|
-
c.mrhyde.theme = 'theme'
|
23
|
-
c.mrhyde.meta.info = 'test nested nested value'
|
24
|
-
|
25
|
-
pp c.to_h
|
26
|
-
|
27
|
-
assert true ## if we get here; everything is ok
|
28
|
-
end
|
29
|
-
|
30
|
-
|
31
|
-
end # class TestConfig
|
data/test/test_wizard.rb
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
###
|
4
|
-
# to run use
|
5
|
-
# ruby -I ./lib -I ./test test/test_wizard.rb
|
6
|
-
|
7
|
-
|
8
|
-
require 'helper'
|
9
|
-
|
10
|
-
|
11
|
-
class TestWizard < MiniTest::Test
|
12
|
-
|
13
|
-
include MrHyde::Wizard ## lets you use ask etc.
|
14
|
-
|
15
|
-
def test_ask
|
16
|
-
|
17
|
-
$MRHYDE_WIZARD_IN = EchoIO.new( <<EOS )
|
18
|
-
Another Beautiful Static Site
|
19
|
-
|
20
|
-
H. J.
|
21
|
-
|
22
|
-
2
|
23
|
-
n
|
24
|
-
y
|
25
|
-
EOS
|
26
|
-
|
27
|
-
say "Hello, Wizard!"
|
28
|
-
|
29
|
-
title = ask "What's your site's title", "Your Site Title"
|
30
|
-
assert_equal 'Another Beautiful Static Site', title
|
31
|
-
|
32
|
-
title = ask "What's your site's title", "Your Site Title"
|
33
|
-
assert_equal 'Your Site Title', title
|
34
|
-
|
35
|
-
name = ask "Your Name"
|
36
|
-
assert_equal 'H. J.', name
|
37
|
-
|
38
|
-
theme = select "Select your theme", ["Starter", "Bootstrap", "Minimal"]
|
39
|
-
assert_equal 'Starter', theme
|
40
|
-
|
41
|
-
theme = select "Select your theme", ["Starter", "Bootstrap", "Minimal"]
|
42
|
-
assert_equal 'Bootstrap', theme
|
43
|
-
|
44
|
-
assert_equal false, yes?( "Add to GitHub" )
|
45
|
-
assert_equal false, no?( "Add to GitHub" )
|
46
|
-
|
47
|
-
assert true ## if we get here; everything is ok
|
48
|
-
end
|
49
|
-
|
50
|
-
end # class TestWizard
|