mrhyde-tools 0.0.1 → 0.1.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2e557f30beeedfc546a63f1cae76cf2ae293073a
4
- data.tar.gz: 0cfd40a76e76745d8b107db1435f9484e16ad54f
3
+ metadata.gz: aae57c42c231ddd4cbf85848a18d5f43c98ece4f
4
+ data.tar.gz: b90daa336b9b14f682fbbaed03b5199d14ac8ade
5
5
  SHA512:
6
- metadata.gz: 4dc3215a4b822754dcc71b7777cf8acd76cf7d0e01973e8c617ea8d33269c2d9bc485ebfdf1040b855ac4f47ecf532d907c161ab848f921c5d25c395bac033fa
7
- data.tar.gz: 7467bd07855fcbabdd1c72e4087e339e2e6c3d058ccfd622d389401fa23b77dd73db1eec1acec0ab9d598fa0225b13647748084376ad95aa6e21de4f8ca57da1
6
+ metadata.gz: 80d28406f03ea41d492fb025a98eb1490a8fe665f4d0c3e88f2adbf99880b55074f1e2eb6770b308b798153d9d89cdf260594eb1424440581944963de05363b6
7
+ data.tar.gz: b170832289088da0ad4af8176ce6c589a645fbefc27e40e536536b7c2cb09ea245e40c73039f1d9d62b03d9b6dfd02cdcd610215df373f09b9a7e2f502d5b130
data/.gemtest ADDED
File without changes
data/Manifest.txt CHANGED
@@ -2,6 +2,21 @@ HISTORY.md
2
2
  Manifest.txt
3
3
  README.md
4
4
  Rakefile
5
+ bin/mrh
6
+ bin/mrhyde
5
7
  lib/mrhyde.rb
8
+ lib/mrhyde/builder.rb
9
+ lib/mrhyde/cli/main.rb
10
+ lib/mrhyde/cli/opts.rb
11
+ lib/mrhyde/config.rb
6
12
  lib/mrhyde/tools.rb
7
13
  lib/mrhyde/version.rb
14
+ lib/mrhyde/wizard.rb
15
+ test/helper.rb
16
+ test/scripts/starter.rb
17
+ test/scripts/starterii.rb
18
+ test/test_builder.rb
19
+ test/test_config.rb
20
+ test/test_install_theme.rb
21
+ test/test_url.rb
22
+ test/test_wizard.rb
data/README.md CHANGED
@@ -1,18 +1,113 @@
1
- # mrhyde
1
+ # mrh/mrhyde - static site quick starter script wizard
2
2
 
3
- static site quick starter scripts
3
+ jekyll command line tool
4
4
 
5
5
  * home :: [github.com/mrhydescripts/mrhyde](https://github.com/mrhydescripts/mrhyde)
6
6
  * bugs :: [github.com/mrhydescripts/mrhyde/issues](https://github.com/mrhydescripts/mrhyde/issues)
7
- * gem :: [rubygems.org/gems/mrhyde](https://rubygems.org/gems/mrhyde)
8
- * rdoc :: [rubydoc.info/gems/mrhyde](http://rubydoc.info/gems/mrhyde)
7
+ * gem :: [rubygems.org/gems/mrhyde-tools](https://rubygems.org/gems/mrhyde-tools)
8
+ * rdoc :: [rubydoc.info/gems/mrhyde-tools](http://rubydoc.info/gems/mrhyde-tools)
9
9
  * forum :: [wwwmake](http://groups.google.com/group/wwwmake)
10
10
 
11
11
 
12
12
  ## Usage
13
13
 
14
- to be done
14
+ The mrhyde-tools gem includes a command line tool that lets you
15
+ run static site quick starter scripts. Try:
15
16
 
17
+ ```
18
+ $ mrhyde --help # or
19
+ $ mrh -h
20
+ ```
21
+
22
+ Resulting in:
23
+
24
+ ```
25
+ NAME
26
+ mrh/mrhyde - jekyll command line tool .:. the static site quick starter script wizard
27
+
28
+ SYNOPSIS
29
+ mrhyde [global options] command [command options] [arguments...]
30
+
31
+ VERSION
32
+ 0.1.0
33
+
34
+ GLOBAL OPTIONS
35
+ --help - Show this message
36
+ --test, --dry_run - (Debug) Dry run; run script in simulation for testing
37
+ --verbose - (Debug) Show debug messages
38
+ --version - Display the program version
39
+
40
+ COMMANDS
41
+ new, n - Run static site quick starter script
42
+
43
+ help - Shows a list of commands or help for one command
44
+ test - (Debug) Test command suite
45
+ ```
46
+
47
+
48
+ ### Commands
49
+
50
+ [New Wizard](#new-wizard-command---new-n)
51
+
52
+ #### New Wizard Command - `new`, `n`
53
+
54
+ To run a static site quick starter wizard script
55
+ to download and install (unzip/unpack) a theme archive and configure
56
+ a static site ready-to-use. Try:
57
+
58
+
59
+ ```
60
+ $ mrhyde new starter # or
61
+ $ mrhyde n starter # or
62
+ $ mrh n starter
63
+ ```
64
+
65
+ This will download the `starter.rb` wizard script
66
+ from the [Mr. Hyde's Scripts](https://github.com/mrhydescripts/scripts) repo
67
+ and run through all steps e.g.:
68
+
69
+ ```
70
+ Welcome, before setting up your site Mr. Hyde will ask you some questions.
71
+
72
+ Q: What's your site's title? [Your Site Title]: Another Beautiful Static Site
73
+ Q: What's your name? [Henry Jekyll]: Edward Hyde
74
+ Q: Select your theme:
75
+ 1 - Starter
76
+ 2 - Bootstrap
77
+ 3 - Minimal
78
+ Your choice (1-3)? [1]: 2
79
+
80
+ Thanks! Ready-to-go. Stand back.
81
+
82
+ Downloading Dr. Jekyll's Bootstrap Theme...
83
+ Setting up Dr. Jeykll's Bootstrap Theme..
84
+ ...
85
+ Updating settings in _config.yml...
86
+ title: "Another Beautiful Static Site"
87
+ author.name: "Edward Hyde"
88
+ ...
89
+ Done.
90
+ ```
91
+
92
+ That's it. Now use:
93
+
94
+ ```
95
+ $ cd starter
96
+ $ jekyll serve
97
+ ```
98
+
99
+ And open up your new static site in your browser.
100
+
101
+
102
+
103
+ **More Quick Starter Wizard Scripts**
104
+
105
+ See the [Mr. Hyde's Scripts](https://github.com/mrhydescripts/scripts) library.
106
+
107
+
108
+ **More Themes**
109
+
110
+ See the [Dr. Jekyll's Themes](https://drjekyllthemes.github.io) directory.
16
111
 
17
112
 
18
113
 
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ Hoe.spec 'mrhyde-tools' do
5
5
 
6
6
  self.version = MrHyde::VERSION
7
7
 
8
- self.summary = "mrhyde - static site quick starter scripts"
8
+ self.summary = "mrhyde - jekyll command line tool .:. static site quick starter script wizard"
9
9
  self.description = summary
10
10
 
11
11
  self.urls = ['https://github.com/mrhydescripts/mrhyde']
@@ -18,6 +18,8 @@ Hoe.spec 'mrhyde-tools' do
18
18
  self.history_file = 'HISTORY.md'
19
19
 
20
20
  self.extra_deps = [
21
+ ['logutils'],
22
+ ['textutils'],
21
23
  ['drjekyll'],
22
24
  ]
23
25
 
data/bin/mrh ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mrhyde/tools'
4
+
5
+ MrHyde.main
data/bin/mrhyde ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mrhyde/tools'
4
+
5
+ MrHyde.main
data/lib/mrhyde.rb CHANGED
@@ -1,12 +1,30 @@
1
1
  # encoding: utf-8
2
2
 
3
+ ## stdlibs
3
4
  require 'pp'
5
+ require 'yaml'
6
+ require 'uri'
4
7
 
5
8
 
9
+ ## 3rd party libs
10
+ require 'textutils' ## used for File.read_utf8
11
+ require 'drjekyll'
12
+
6
13
  ## our own code
7
14
  require 'mrhyde/version' # note: let version always go first
15
+ require 'mrhyde/wizard'
16
+ require 'mrhyde/builder'
17
+ require 'mrhyde/config'
18
+
19
+ require 'mrhyde/cli/opts'
20
+ require 'mrhyde/cli/main'
21
+
8
22
 
23
+ module MrHyde
24
+ def self.main
25
+ exit Tool.new.run( ARGV )
26
+ end
27
+ end # module MrHyde
9
28
 
10
- pp MrHyde.banner
11
- pp MrHyde.root
12
29
 
30
+ MrHyde.main if __FILE__ == $0
@@ -0,0 +1,123 @@
1
+ #encoding: utf-8
2
+
3
+ module MrHyde
4
+
5
+ class Builder
6
+
7
+ def self.load_file( path, opts={} )
8
+ code = File.read_utf8( path )
9
+ self.load( code, opts )
10
+ end
11
+
12
+ def self.load( code, opts={} )
13
+ builder = Builder.new( opts )
14
+ builder.instance_eval( code )
15
+ builder
16
+ end
17
+
18
+
19
+ include Wizard ## mixin helpers for say, ask, yes?, no?, select, etc.
20
+
21
+ def initialize( opts={} )
22
+ puts "starting new MrHyde script (sitefile) #{opts.inspect}; lets go"
23
+
24
+ @test = opts[:dry_run] || opts[:test] || false
25
+ @output_dir = opts[:o] || '.'
26
+ end
27
+
28
+ ## "global" builder options
29
+ def test?() @test; end ## dry_run option (defaults to false)
30
+ def output_dir() @output_dir; end ## ouptput (root) dir (defaults to . e.g. working folder)
31
+
32
+
33
+ def install_theme( name, opts= {} )
34
+ puts " handle install_theme #{name}, #{opts.inspect}"
35
+
36
+ ## note for now assume name is key
37
+ ## e.g. always downcase (e.g. Starter => starter)
38
+ @theme_key = key = name.downcase
39
+
40
+ ## themes_dir = "#{DrJekyll.root}/test/data"
41
+ ## catalog = Catalog.new( "#{themes_dir}/themes.yml" )
42
+ url = "https://github.com/drjekyllthemes/themes/raw/master/o/themes.yml"
43
+
44
+ if test?
45
+ # do nothing; dry run
46
+ else
47
+ catalog = DrJekyll::Catalog.from_url( url )
48
+ theme = catalog.find( key )
49
+ if theme
50
+ pak = DrJekyll::Package.new( key, theme )
51
+ pak.download
52
+ pak.unzip( "#{@output_dir}/#{key}" )
53
+ else
54
+ ## todo: issue warning - why, why not??
55
+ fail "*** theme '#{key}' not found; sorry"
56
+ end
57
+ end
58
+ end
59
+
60
+
61
+ def config( opts={} )
62
+ puts " handle config block"
63
+ c = OpenConfig.new
64
+ yield( c )
65
+ ## pp c
66
+ h = c.to_h
67
+
68
+ ##
69
+ # check for site.url if present also
70
+ # add site.baseurl|path
71
+
72
+ site_url = h['url']
73
+
74
+ if site_url.nil? || site_url.empty? ## special case site_url is empty string ""
75
+ ## note: always add site url for now
76
+ ## todo/fix: warn if we overwrite "empty" site.url - why? why not?
77
+ h['url'] = 'http://example.com' # note: no trailing slash (/) e.g. example.com/
78
+ h['baseurl'] = '' # note: no trailing slash (/) e.g. /
79
+ h['path'] = '' # (better) alias for baseurl
80
+ else
81
+ ## site_baseurl = h['baseurl']
82
+ ## site_path = h['path']
83
+
84
+ ### calculate path/baseurl
85
+ url = URI.parse( site_url )
86
+ path = url.path.sub(/\/$/, '' ) ## note: cut off trailing slash if present e.g. '/' becomes ''
87
+
88
+ h['baseurl'] = path
89
+ h['path'] = path
90
+ ## todo/fix: warn if we overwrite baseurl/path we new values - why? why not?
91
+ end
92
+
93
+ pp h
94
+
95
+
96
+ if test?
97
+ ## do nothing; dry run
98
+ else
99
+ org = YAML.load_file( "#{@output_dir}/#{@theme_key}/_config.yml" )
100
+ pp org
101
+
102
+ ## for now always add props at the end
103
+ ## improve later (patch using regex etc. - why? why not?)
104
+
105
+ new_settings = YAML.dump( h )
106
+ ## note: cut off leading --- if present
107
+ new_settings = new_settings.sub( /^-{3}\s*/, '')
108
+
109
+ File.open( "#{@output_dir}/#{@theme_key}/_config.yml", "a" ) do |f|
110
+ f.puts
111
+ f.puts "######################################"
112
+ f.puts "### Mr Hyde's Settings"
113
+ f.puts
114
+ f.puts new_settings
115
+ end
116
+ end
117
+
118
+ end # method config
119
+
120
+ end # class Builder
121
+
122
+ end # module MrHyde
123
+
@@ -0,0 +1,149 @@
1
+ # encoding: utf-8
2
+
3
+ ### NOTE: wrap gli config into a class
4
+ ## see github.com/davetron5000/gli/issues/153
5
+
6
+ module MrHyde
7
+
8
+ class Tool
9
+ def initialize
10
+ LogUtils::Logger.root.level = :info # set logging level to info
11
+ end
12
+
13
+ def run( args )
14
+ puts MrHyde.banner
15
+ Toolii.run( args )
16
+ end
17
+ end
18
+
19
+ ## NOTE: gli added function are class methods (thus, wrap class Toolii in Tool for now)
20
+
21
+ class Toolii
22
+ extend GLI::App
23
+
24
+ def self.logger=(value) @@logger=value; end
25
+ def self.logger() @@logger; end
26
+
27
+ ## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
28
+ def self.opts=(value) @@opts = value; end
29
+ def self.opts() @@opts; end
30
+
31
+
32
+ logger = LogUtils::Logger.root
33
+ opts = Opts.new
34
+
35
+
36
+ program_desc 'jekyll command line tool .:. the static site quick starter script wizard'
37
+ version VERSION
38
+
39
+
40
+ ## desc 'Use only local (offline) cached data; no (online) remote network access'
41
+ ## switch [:l, :local], negatable: false
42
+
43
+ desc '(Debug) Show debug messages'
44
+ switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
45
+
46
+ desc '(Debug) Dry run; run script in simulation for testing'
47
+ switch [:test, :dry_run], negatable: false
48
+
49
+
50
+ def self.fetch_script( name )
51
+
52
+ ## first try local version in working folder
53
+
54
+ text = ''
55
+ local_script = "./#{name}.rb"
56
+ if File.exist?( local_script )
57
+ text = File.read_utf8( local_script )
58
+ else ## fetch remote script
59
+ url = "https://github.com/mrhydescripts/scripts/raw/master/#{name}.rb"
60
+ ## assume utf8 text encoding for now
61
+ worker = Fetcher::Worker.new
62
+ text = worker.read_utf8!( url )
63
+ end
64
+
65
+ text
66
+ end
67
+
68
+
69
+ desc "Run static site quick starter script"
70
+ arg_name 'NAME' # required theme name
71
+ command [:new,:n] do |c|
72
+
73
+ c.action do |g,o,args|
74
+
75
+ name = args[0] || 'starter'
76
+
77
+ script = fetch_script( name )
78
+ if opts.test?
79
+ puts "dry (test) run:"
80
+ Builder.load( script, test: true )
81
+ else
82
+ Builder.load( script )
83
+ end
84
+
85
+ puts 'Done.'
86
+ end # action
87
+ end # command setup
88
+
89
+
90
+
91
+ desc '(Debug) Test command suite'
92
+ command :test do |c|
93
+ c.action do |g,o,args|
94
+
95
+ puts "hello from test command"
96
+ puts "args (#{args.class.name}):"
97
+ pp args
98
+ puts "o (#{o.class.name}):"
99
+ pp o
100
+ puts "g (#{g.class.name}):"
101
+ pp g
102
+
103
+ LogUtils::Logger.root.debug 'test debug msg'
104
+ LogUtils::Logger.root.info 'test info msg'
105
+ LogUtils::Logger.root.warn 'test warn msg'
106
+
107
+ puts 'Done.'
108
+ end
109
+ end
110
+
111
+
112
+
113
+ pre do |g,c,o,args|
114
+ opts.merge_gli_options!( g )
115
+ opts.merge_gli_options!( o )
116
+
117
+ puts MrHyde.banner
118
+
119
+ if opts.verbose?
120
+ LogUtils::Logger.root.level = :debug
121
+ end
122
+
123
+ logger.debug "Executing #{c.name}"
124
+ true
125
+ end
126
+
127
+ post do |global,c,o,args|
128
+ logger.debug "Executed #{c.name}"
129
+ true
130
+ end
131
+
132
+
133
+ on_error do |e|
134
+ puts
135
+ puts "*** error: #{e.message}"
136
+
137
+ if opts.verbose?
138
+ puts e.backtrace
139
+ end
140
+
141
+ false # skip default error handling
142
+ end
143
+
144
+
145
+ ### exit run(ARGV) ## note: use Toolii.run( ARGV ) outside of class
146
+
147
+ end # class Toolii
148
+
149
+ end # module MrHyde
@@ -0,0 +1,33 @@
1
+ # encoding: utf-8
2
+
3
+ module MrHyde
4
+
5
+ class Opts
6
+
7
+ def merge_gli_options!( options = {} )
8
+ @test = true if options[:test] == true
9
+ @verbose = true if options[:verbose] == true
10
+ end
11
+
12
+
13
+ def verbose=(boolean) # add: alias for debug ??
14
+ @verbose = boolean
15
+ end
16
+
17
+ def verbose?
18
+ return false if @verbose.nil? # default verbose/debug flag is false
19
+ @verbose == true
20
+ end
21
+
22
+ def test=(boolean)
23
+ @test = boolean
24
+ end
25
+
26
+ def test?
27
+ return false if @test.nil? # default test/dry-run flag is false
28
+ @test == true
29
+ end
30
+
31
+ end # class Opts
32
+
33
+ end # module MrHyde
@@ -0,0 +1,60 @@
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
@@ -4,8 +4,8 @@
4
4
  module MrHyde
5
5
 
6
6
  MAJOR = 0
7
- MINOR = 0
8
- PATCH = 1
7
+ MINOR = 1
8
+ PATCH = 0
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
@@ -0,0 +1,88 @@
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/helper.rb ADDED
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+
3
+ ## minitest setup
4
+
5
+ require 'minitest/autorun'
6
+
7
+
8
+ class EchoIO
9
+ def initialize( buf )
10
+ @io = StringIO.new( buf )
11
+ end
12
+
13
+ def gets
14
+ str = @io.gets
15
+ puts "|>#{str.chomp}<|" ## remove newline (w/ chomp) in debug/echo output
16
+ str
17
+ end
18
+ end
19
+
20
+
21
+ ## our own code
22
+ require 'mrhyde'
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ puts "[debug] self.class.name #{self.class.name}"
5
+
6
+ name = "check setting local variable name"
7
+ puts "[debug] #{name}"
8
+
9
+ puts "pp self:"
10
+ pp self
11
+
12
+
13
+ ###############################################
14
+ # Mr. Hyde's Quick Start Static Site Script
15
+
16
+ say "Welcome, before setting up your site Mr. Hyde will ask you some questions."
17
+
18
+ title = ask "What's your site's title", "Your Site Title"
19
+
20
+ name = ask "What's your name", "Henry Jekyll"
21
+
22
+ say "Thanks! Ready-to-go. Stand back."
23
+
24
+ install_theme "Starter"
25
+
26
+ config do |c|
27
+ c.title = title
28
+ c.author.name = name
29
+
30
+ c.mrhyde.last_updated = Time.now
31
+ c.mrhyde.title = title
32
+ c.mrhyde.name = name
33
+ end
34
+
35
+ say "Done."
36
+
@@ -0,0 +1,39 @@
1
+ # encoding: utf-8
2
+
3
+
4
+ puts "[debug] self.class.name #{self.class.name}"
5
+
6
+ puts "pp self:"
7
+ pp self
8
+
9
+
10
+ ###############################################
11
+ # Mr. Hyde's Quick Start Static Site Script
12
+
13
+ say "Welcome, before setting up your site Mr. Hyde will ask you some questions."
14
+
15
+ title = ask "What's your site's title", "Your Site Title"
16
+
17
+ url = ask "What's your site's address (url)", "http://yoursite.com"
18
+
19
+ name = ask "What's your name", "Henry Jekyll"
20
+
21
+ theme = select "Select your theme", ["Starter", "Bootstrap", "Minimal"]
22
+
23
+ say "Thanks! Ready-to-go. Stand back."
24
+
25
+ install_theme theme
26
+
27
+ config do |c|
28
+ c.title = title
29
+ c.url = url
30
+ c.author.name = name
31
+
32
+ c.mrhyde.last_updated = Time.now
33
+ c.mrhyde.title = title
34
+ c.mrhyde.name = name
35
+ c.mrhyde.theme = theme
36
+ c.mrhyde.url = url
37
+ end
38
+
39
+ say "Done."
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_builder.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestBuilder < MiniTest::Test
12
+
13
+ def test_starter
14
+
15
+ $MRHYDE_WIZARD_IN = EchoIO.new( <<EOS )
16
+ Another Beautiful Static Site
17
+ H. J.
18
+ EOS
19
+
20
+ _ = MrHyde::Builder.load_file( "#{MrHyde.root}/test/scripts/starter.rb", test: true )
21
+
22
+ assert true ## if we get here; everything is ok
23
+ end
24
+
25
+ def test_starterii
26
+
27
+ $MRHYDE_WIZARD_IN = EchoIO.new( <<EOS )
28
+ Another Beautiful Static Site
29
+ http://example.github.io/repo
30
+ H. J.
31
+ 1
32
+ EOS
33
+
34
+ _ = MrHyde::Builder.load_file( "#{MrHyde.root}/test/scripts/starterii.rb", test: true )
35
+
36
+ assert true ## if we get here; everything is ok
37
+ end
38
+
39
+
40
+ end # class TestBuilder
@@ -0,0 +1,31 @@
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
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_install_theme.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestInstallTheme < MiniTest::Test
12
+
13
+ def test_starter
14
+
15
+ $MRHYDE_WIZARD_IN = EchoIO.new( <<EOS )
16
+ Another Beautiful Static Site
17
+ H. J.
18
+ EOS
19
+
20
+ _ = MrHyde::Builder.load_file( "#{MrHyde.root}/test/scripts/starter.rb", o: './o')
21
+
22
+ assert true ## if we get here; everything is ok
23
+ end
24
+
25
+ end # class TestInstallTheme
data/test/test_url.rb ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ ###
4
+ # to run use
5
+ # ruby -I ./lib -I ./test test/test_url.rb
6
+
7
+
8
+ require 'helper'
9
+
10
+
11
+ class TestUrl < MiniTest::Test
12
+
13
+ def test_clean_path
14
+ path = '/'
15
+ path = path.sub( /\/$/, '' )
16
+ assert_equal '', path
17
+
18
+ path = ''
19
+ path = path.sub( /\/$/, '' )
20
+ assert_equal '', path
21
+
22
+ path = '/test/'
23
+ path = path.sub( /\/$/, '' )
24
+ assert_equal '/test', path
25
+ end
26
+
27
+
28
+ def test_site_url
29
+
30
+ str = 'http://example.com'
31
+
32
+ url = URI.parse( str )
33
+
34
+ pp url
35
+
36
+ assert_equal 'example.com', url.host
37
+ assert_equal '', url.path
38
+ end
39
+
40
+ end # class TestUrl
@@ -0,0 +1,50 @@
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
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mrhyde-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
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-12 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logutils
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: textutils
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: drjekyll
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,22 +80,41 @@ dependencies:
52
80
  - - "~>"
53
81
  - !ruby/object:Gem::Version
54
82
  version: '3.13'
55
- description: mrhyde - static site quick starter scripts
83
+ description: mrhyde - jekyll command line tool .:. static site quick starter script
84
+ wizard
56
85
  email: wwwmake@googlegroups.com
57
- executables: []
86
+ executables:
87
+ - mrh
88
+ - mrhyde
58
89
  extensions: []
59
90
  extra_rdoc_files:
60
91
  - HISTORY.md
61
92
  - Manifest.txt
62
93
  - README.md
63
94
  files:
95
+ - ".gemtest"
64
96
  - HISTORY.md
65
97
  - Manifest.txt
66
98
  - README.md
67
99
  - Rakefile
100
+ - bin/mrh
101
+ - bin/mrhyde
68
102
  - lib/mrhyde.rb
103
+ - lib/mrhyde/builder.rb
104
+ - lib/mrhyde/cli/main.rb
105
+ - lib/mrhyde/cli/opts.rb
106
+ - lib/mrhyde/config.rb
69
107
  - lib/mrhyde/tools.rb
70
108
  - lib/mrhyde/version.rb
109
+ - lib/mrhyde/wizard.rb
110
+ - test/helper.rb
111
+ - test/scripts/starter.rb
112
+ - test/scripts/starterii.rb
113
+ - test/test_builder.rb
114
+ - test/test_config.rb
115
+ - test/test_install_theme.rb
116
+ - test/test_url.rb
117
+ - test/test_wizard.rb
71
118
  homepage: https://github.com/mrhydescripts/mrhyde
72
119
  licenses:
73
120
  - Public Domain
@@ -93,5 +140,10 @@ rubyforge_project:
93
140
  rubygems_version: 2.4.2
94
141
  signing_key:
95
142
  specification_version: 4
96
- summary: mrhyde - static site quick starter scripts
97
- test_files: []
143
+ 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