magic_reveal 2.6.1.2 → 2.6.1.4

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: 84bff9a97794cc7df8f37262cfa3c4e562917320
4
- data.tar.gz: 01bcd7986cd6e692917ac59f308e5dd0e30b37a5
3
+ metadata.gz: 1d26848d4efe7ddf18d1f06cf7466b705c990b33
4
+ data.tar.gz: eb2219d4d227d87c2f6031541cd953e029c7c8f7
5
5
  SHA512:
6
- metadata.gz: 688c0c2e4dbe2d9c404c17dcceefbbc77e92d284f1ba6eae3b8a4a030aa4b5c40ff16e96448ac4780b64b15eb722844f4ad948ceccc34ac30cf5f831d5599ace
7
- data.tar.gz: cfd91567e69b6e99de808966bd53202e93c7e94c1e166f73fcabcff4ddd246eee8d168d75b8e1f02e2d1aa971581143fa969505e3dcdb65f435eae4bff034a6f
6
+ metadata.gz: 285e3207220eef9ed03e789b96fbd2eaccabb9b4f16d1f5e2348a6233c82f3bf0ed11c009f62f95239895d61081d5848b4f5914ab8f5ef8625717dd5327c3b72
7
+ data.tar.gz: dd484b481a9a8834a9f538719c1581dc0ce057c9f858a0532ef7b171db569678d19056bb977926503e8d290f1a61c4776a164e9ce230a84e9cbd767d1f6c218f
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
- - 1.9.2
5
4
  - 2.0.0
5
+ - 2.1.1
data/Guardfile CHANGED
@@ -1,5 +1,20 @@
1
- guard :rspec, :cli => "--color --order default --format doc" do
2
- watch(%r{^spec/.+_spec\.rb$})
3
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
4
- watch('spec/spec_helper.rb') { "spec" }
1
+ group :red_green_refactor, halt_on_fail: true do
2
+ guard(
3
+ :rspec,
4
+ cmd: 'bundle exec rspec --color --order default --format doc',
5
+ failed_mode: :none,
6
+ all_on_start: true,
7
+ all_after_pass: true,
8
+ run_all: { cmd: 'bundle exec rspec --color --order random --format progress' }
9
+ ) do
10
+ watch(%r{^spec/.+_spec\.rb$})
11
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12
+ watch('spec/spec_helper.rb') { 'spec' }
13
+ watch(%r{^spec/integration/.+_spec\.rb$}) { 'spec' }
14
+ end
15
+
16
+ guard :rubocop, cli: 'lib spec -D', all_on_start: true do
17
+ watch(%r{^(lib|spec)/.+\.rb$})
18
+ watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
19
+ end
5
20
  end
data/README.md CHANGED
@@ -4,9 +4,11 @@ Magic Reveal makes creating presentations easy and fun.
4
4
 
5
5
  See it in action at the [demo/tutorial](http://docwhat.github.io/magic_reveal/)
6
6
 
7
+ [![Gem Version](https://badge.fury.io/rb/magic_reveal.png)](http://badge.fury.io/rb/magic_reveal)
7
8
  [![Build Status](https://secure.travis-ci.org/docwhat/magic_reveal.png?branch=master)](http://travis-ci.org/docwhat/magic_reveal)
8
9
  [![Dependencies](https://gemnasium.com/docwhat/magic_reveal.png?branch=master)](https://gemnasium.com/docwhat/magic_reveal)
9
10
  [![Coverage Status](https://coveralls.io/repos/docwhat/magic_reveal/badge.png?branch=master)](https://coveralls.io/r/docwhat/magic_reveal)
11
+ [![Code Climate](https://codeclimate.com/github/docwhat/magic_reveal.png)](https://codeclimate.com/github/docwhat/magic_reveal)
10
12
 
11
13
  ## Installation
12
14
 
@@ -20,7 +22,7 @@ the revision specific to Magic Reveal.
20
22
 
21
23
  ### Requirements
22
24
 
23
- * Ruby 1.9.2 or newer
25
+ * Ruby 1.9.3 or newer
24
26
  * A recent version of [Bundler](http://bundler.io/)
25
27
 
26
28
  <br/>
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
4
 
5
5
  require 'magic_reveal/cli'
6
6
 
@@ -1,4 +1,4 @@
1
- require "magic_reveal/version"
1
+ require 'magic_reveal/version'
2
2
 
3
3
  module MagicReveal
4
4
  class Error < StandardError; end
@@ -12,6 +12,7 @@ rescue LoadError
12
12
  end
13
13
 
14
14
  module MagicReveal
15
+ # The web application
15
16
  class App < Sinatra::Base
16
17
  if HAS_BETTER_ERRORS
17
18
  configure :development do
@@ -41,6 +42,5 @@ module MagicReveal
41
42
  config = ProjectConfig.new(Pathname.pwd + 'config.json')
42
43
  config.to_js
43
44
  end
44
-
45
45
  end
46
46
  end
@@ -8,6 +8,7 @@ require 'magic_reveal/index_libber'
8
8
  require 'magic_reveal/project_config'
9
9
 
10
10
  module MagicReveal
11
+ # Command line interface
11
12
  class Cli
12
13
  extend Forwardable
13
14
 
@@ -18,26 +19,28 @@ module MagicReveal
18
19
  attr_writer :creator
19
20
 
20
21
  # Helper method
21
- def self.run args=ARGV
22
- self.new.run args
22
+ def self.run(args = ARGV)
23
+ new.run args
23
24
  end
24
25
 
25
26
  # Action Classes
26
- def show_help
27
- puts "Usage: #{program_name} <command>"
28
- puts
29
- puts ' new <name>'
30
- puts ' Creates new presentation in directory <name>'
31
- puts
32
- puts ' force-reload'
33
- puts ' Refreshes the reveal.js files. WARNING: This may override customizations!'
34
- puts
35
- puts ' start [options]'
36
- puts ' Starts serving the presentation in the current directory'
37
- puts
38
- puts ' static'
39
- puts ' Creates a static index.html file from your slides'
40
- puts
27
+ def show_help # rubocop:disable MethodLength
28
+ puts <<-EOF
29
+ Usage: #{program_name} <command>
30
+ Magic reveal version: #{MagicReveal::VERSION}
31
+
32
+ new <name>
33
+ Creates new presentation in directory <name>
34
+
35
+ force-reload
36
+ Refreshes the reveal.js files. WARNING: This may override customizations!
37
+
38
+ start [options]
39
+ Starts serving the presentation in the current directory
40
+
41
+ static
42
+ Creates a static index.html file from your slides
43
+ EOF
41
44
  exit
42
45
  end
43
46
 
@@ -52,7 +55,7 @@ module MagicReveal
52
55
  exit
53
56
  end
54
57
 
55
- def create_static
58
+ def create_static # rubocop:disable MethodLength
56
59
  slides = Pathname.pwd + 'slides.md'
57
60
  markdown = SlideRenderer.markdown_renderer
58
61
  libber = IndexLibber.new
@@ -71,8 +74,8 @@ module MagicReveal
71
74
  end
72
75
 
73
76
  def avenge_programmer
74
- puts "The programmer messed up."
75
- puts "Please file a bug at https://github.com/docwhat/magic_reveal"
77
+ puts 'The programmer messed up.'
78
+ puts 'Please file a bug at https://github.com/docwhat/magic_reveal'
76
79
  exit 13
77
80
  end
78
81
 
@@ -80,14 +83,14 @@ module MagicReveal
80
83
  @options ||= Options.new
81
84
  end
82
85
 
83
- def run args=ARGV
86
+ def run(args = ARGV) # rubocop:disable MethodLength, CyclomaticComplexity
84
87
  options.parse args
85
88
 
86
89
  case command
87
90
  when :new
88
91
  creator.create_project(project)
89
92
  when :force_reload
90
- theyre_sure = (ask('This may overwrite customizations. Are you sure? (y/N) ') { |q| q.limit = 1; q.case = :downcase }) == 'y'
93
+ theyre_sure = (ask('This may overwrite customizations. Are you sure? (y/N) ') { |q| q.limit = 1; q.case = :downcase }) == 'y' # rubocop:disable Semicolon
91
94
  creator.update_project(Dir.getwd) if theyre_sure
92
95
  when :start
93
96
  start_server
@@ -1,16 +1,17 @@
1
1
  module MagicReveal
2
2
  class Cli
3
+ # Command line options
3
4
  class Options
4
5
  attr_accessor(
5
6
  :command,
6
- :project,
7
+ :project
7
8
  )
8
9
 
9
10
  def program_name
10
- @program_name ||= File.basename($0)
11
+ @program_name ||= File.basename($PROGRAM_NAME)
11
12
  end
12
13
 
13
- def parse args
14
+ def parse(args) # rubocop:disable MethodLength
14
15
  case args.first
15
16
  when 'new'
16
17
  if args.length != 2
@@ -9,16 +9,16 @@ module MagicReveal
9
9
  class Conductor
10
10
  attr_reader :url, :enable_warnings
11
11
 
12
- def initialize url=nil
12
+ def initialize(url = nil)
13
13
  self.url = url unless url.nil?
14
14
  end
15
15
 
16
- def url= url
16
+ def url=(url)
17
17
  @url = URI.parse url
18
18
  end
19
19
 
20
- def fetch save_path, limit = 5
21
- raise TooManyRedirects if limit <= 0
20
+ def fetch(save_path, limit = 5) # rubocop:disable MethodLength
21
+ fail TooManyRedirects if limit <= 0
22
22
  save_path = Pathname.new save_path
23
23
 
24
24
  request = Net::HTTP::Get.new url.path
@@ -32,13 +32,13 @@ module MagicReveal
32
32
  warn "redirected to #{url}" if enable_warnings
33
33
  fetch(save_path, limit - 1)
34
34
  else
35
- raise Error, "Huh? #{response.value}"
35
+ fail Error, "Huh? #{response.value}"
36
36
  end
37
37
  end
38
38
 
39
- def unpack zip_file, directory
39
+ def unpack(zip_file, directory)
40
40
  directory = Pathname.new directory
41
- raise Error, "Directory '#{directory}' already exists." if directory.exist?
41
+ fail Error, "Directory '#{directory}' already exists." if directory.exist?
42
42
 
43
43
  Archive::Zip.extract zip_file.to_s, directory.to_s
44
44
 
@@ -6,6 +6,7 @@ require 'magic_reveal/reveal_js_fetcher'
6
6
  require 'magic_reveal/project_config'
7
7
 
8
8
  module MagicReveal
9
+ # Creates the world!
9
10
  class Creator
10
11
  attr_reader :directory
11
12
  attr_writer :reveal_js_fetcher, :template_slides, :template_config_ru
@@ -32,7 +33,7 @@ module MagicReveal
32
33
  reveal_js_fetcher.save_important_parts_to(top_dir)
33
34
  end
34
35
 
35
- def create_project(project)
36
+ def create_project(project) # rubocop:disable MethodLength
36
37
  top_dir = directory + project
37
38
  gemfile = top_dir + 'Gemfile'
38
39
 
@@ -1,10 +1,11 @@
1
1
  require 'sys/admin'
2
2
 
3
3
  module MagicReveal
4
+ # figures out the author's identity
4
5
  class Identifier
5
6
  attr_accessor :sys_admin
6
7
 
7
- def initialize sys_admin=nil
8
+ def initialize(sys_admin = nil)
8
9
  @sys_admin = sys_admin || Sys::Admin
9
10
  end
10
11
 
@@ -7,20 +7,20 @@ module MagicReveal
7
7
  class IndexLibber
8
8
  attr_reader :html
9
9
 
10
- def initialize html_text=nil
10
+ def initialize(html_text = nil)
11
11
  if html_text.nil?
12
12
  template_path = Pathname.new(__FILE__).dirname + 'template.html'
13
13
  html_text = template_path.read
14
14
  end
15
15
  @html = Nokogiri::HTML(html_text, &:noblanks)
16
16
  # Add autogenerated comment
17
- #html.children.first.add_previous_sibling(Nokogiri::XML::Comment.new("Generated at #{Time.now}"))
17
+ # html.children.first.add_previous_sibling(Nokogiri::XML::Comment.new("Generated at #{Time.now}"))
18
18
  html.root.children.first.before Nokogiri::XML::Comment.new(html, "Generated at #{Time.now}")
19
19
  end
20
20
 
21
- def set_meta name, content
21
+ def set_meta(name, content)
22
22
  meta = html.at_css("meta[@name='#{name}']")
23
- if !meta
23
+ unless meta
24
24
  meta = Nokogiri::XML::Node.new('meta', html)
25
25
  meta[:name] = name
26
26
 
@@ -30,22 +30,22 @@ module MagicReveal
30
30
  meta[:content] = content
31
31
  end
32
32
 
33
- def title= title
33
+ def title=(title)
34
34
  html.title = title
35
35
  end
36
36
 
37
- def author= author
37
+ def author=(author)
38
38
  set_meta 'author', author
39
39
  end
40
40
 
41
- def description= description
41
+ def description=(description)
42
42
  set_meta 'description', description
43
43
  end
44
44
 
45
- def theme= theme
45
+ def theme=(theme)
46
46
  # <link rel="stylesheet" href="css/theme/default.css" id="theme">
47
- node = html.at_css("link#theme")
48
- if !node
47
+ node = html.at_css('link#theme')
48
+ unless node
49
49
  node = Nokogiri::XML::Node.new('link', html)
50
50
  node[:id] = 'theme'
51
51
  node[:rel] = 'stylesheet'
@@ -56,7 +56,7 @@ module MagicReveal
56
56
  node[:href] = "css/theme/#{theme}.css"
57
57
  end
58
58
 
59
- def slides= text
59
+ def slides=(text)
60
60
  slides = Nokogiri::HTML.fragment(text).children
61
61
  container = html.at_css('div.reveal div.slides')
62
62
  container.children = slides
@@ -64,21 +64,30 @@ module MagicReveal
64
64
  self.title = headers.first.text unless headers.nil? || headers.empty?
65
65
  end
66
66
 
67
- def add_github_forkme project
68
- a = Nokogiri::XML::Node.new('a', html)
69
- a[:class] = 'fork-me'
70
- a[:style] = 'display: none;'
71
- a[:href] = "https://github.com/#{project}"
72
- img = Nokogiri::XML::Node.new('img', html)
73
- img[:style] = "position: absolute; top: 0; right: 0; border: 0;"
74
- img[:src]="https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67"
75
- img[:alt] = "Fork me on GitHub"
67
+ def github_banner_img
68
+ Nokogiri::XML::Node.new('img', html).tap do |img|
69
+ img[:style] = 'position: absolute; top: 0; right: 0; border: 0;'
70
+ img[:src] = 'https://a248.e.akamai.net/camo.github.com/e6bef7a091f5f3138b8cd40bc3e114258dd68ddf/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f7265645f6161303030302e706e67'
71
+ img[:alt] = 'Fork me on GitHub'
72
+ end
73
+ end
74
+
75
+ def github_fork_link(project)
76
+ Nokogiri::XML::Node.new('a', html).tap do |a|
77
+ a[:class] = 'fork-me'
78
+ a[:style] = 'display: none;'
79
+ a[:href] = "https://github.com/#{project}"
80
+ end
81
+ end
82
+
83
+ def add_github_forkme(project)
84
+ a = github_fork_link project
76
85
  script = Nokogiri::XML::Node.new('script', html)
77
86
  script.content = "if( !navigator.userAgent.match( /iphone|ipod|android|ipad|blackberry/gi ) && !!document.querySelector ) { document.querySelector('.fork-me' ).style.display = 'block'; }"
78
87
 
79
88
  parent = (body = html.at('body')) ? body : html.root
80
89
  parent << a
81
- a << img
90
+ a << github_banner_img
82
91
  parent << script
83
92
  end
84
93
 
@@ -2,13 +2,20 @@ require 'pathname'
2
2
  require 'json'
3
3
 
4
4
  module MagicReveal
5
+ # A Project's configuration
5
6
  class ProjectConfig
6
7
  DEFAULT_TEMPLATE = File.expand_path('../template-config.json', __FILE__)
8
+ DEPENDENCY_ENABLER_JS = {
9
+ 'highlight' => '{ src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } }',
10
+ 'zoom' => '{ src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } }',
11
+ 'notes' => '{ src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }'
12
+ }
13
+
7
14
  attr_reader :json
8
15
 
9
- def initialize io_or_path
16
+ def initialize(io_or_path)
10
17
  io = io_or_path.respond_to?(:read) ? io_or_path : Pathname.new(io_or_path)
11
- @json = JSON::load(io.read)
18
+ @json = JSON.load(io.read)
12
19
  end
13
20
 
14
21
  def dependencies
@@ -16,22 +23,16 @@ module MagicReveal
16
23
  # you always want this
17
24
  out << '{ src: "lib/js/classList.js", condition: function() { return !document.body.classList; } }'
18
25
 
19
- if json['plugins'].include? 'highlight'
20
- out << '{ src: "plugin/highlight/highlight.js", async: true, callback: function() { hljs.initHighlightingOnLoad(); } }'
21
- end
22
- if json['plugins'].include? 'zoom'
23
- out << '{ src: "plugin/zoom-js/zoom.js", async: true, condition: function() { return !!document.body.classList; } }'
24
- end
25
- if json['plugins'].include? 'notes'
26
- out << '{ src: "plugin/notes/notes.js", async: true, condition: function() { return !!document.body.classList; } }'
26
+ DEPENDENCY_ENABLER_JS.keys.each do |plugin|
27
+ out << DEPENDENCY_ENABLER_JS[plugin] if json['plugins'].include?(plugin)
27
28
  end
28
29
 
29
30
  "\"dependencies\": [\n#{out.join(",\n")}\n]"
30
31
  end
31
32
 
32
- def to_js
33
+ def to_js # rubocop:disable MethodLength
33
34
  var = []
34
- keys = json.keys.reject { |k| ['dependencies', 'github'].include?(k) }
35
+ keys = json.keys.reject { |k| %w{ 'dependencies', 'github' }.include?(k) }
35
36
  keys.each do |key|
36
37
  value = json[key]
37
38
  var << " #{key}: #{value.to_json}"
@@ -39,10 +40,10 @@ module MagicReveal
39
40
 
40
41
  out = []
41
42
  out << "/* Generated at #{Time.now} */"
42
- out << "var config = {"
43
+ out << 'var config = {'
43
44
  out << "#{var.join(",\n")},\n#{dependencies}"
44
45
  out << "\n};"
45
- out << "Reveal.initialize(config);"
46
+ out << 'Reveal.initialize(config);'
46
47
  out.join("\n")
47
48
  end
48
49
  end
@@ -3,11 +3,12 @@ require 'magic_reveal/version'
3
3
  require 'magic_reveal/conductor'
4
4
 
5
5
  module MagicReveal
6
+ # Fetches Reveal.js
6
7
  class RevealJsFetcher
7
8
  attr_reader :version
8
9
  attr_writer :conductor
9
10
 
10
- def initialize(version=REVEAL_JS_VERSION)
11
+ def initialize(version = REVEAL_JS_VERSION)
11
12
  @version = version
12
13
  end
13
14
 
@@ -36,7 +37,7 @@ module MagicReveal
36
37
  Dir.mktmpdir do |tmpdir|
37
38
  tmp_reveal_dir = Pathname(tmpdir) + 'reveal.js'
38
39
  save_to(tmp_reveal_dir.to_s)
39
- tmp_reveal_dir.children.select(&:directory?).reject{|c| %w[test].include? c.basename.to_s}.each do |dir|
40
+ tmp_reveal_dir.children.select(&:directory?).reject { |c| %w[test].include? c.basename.to_s }.each do |dir|
40
41
  FileUtils.cp_r(dir.to_s, reveal_dir.to_s)
41
42
  end
42
43
  end