wingtips 0.1.0 → 0.2.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: cd5429f39cdabf82c98b720de0920b7a6fedd089
4
- data.tar.gz: b5d697a68077b2b9c887d3f516fca620ccfcdedc
3
+ metadata.gz: b3067ec6dfd19a143b1e7917681d7e69505d22b5
4
+ data.tar.gz: fd6ee01d3dbeb0721c17488dbd153221e5b6d1de
5
5
  SHA512:
6
- metadata.gz: de4609a436f831be9af71febdff06fc086d2cc7a901c84137e65fe787aeba00237b5021ebc81365664af3bf753da4674ec50e7d65a2f3917d210a0ded9d1e640
7
- data.tar.gz: dc4b09eae42b9a318c13e79bad2358e5870071c29c98b1b5086bf88c69475a7c596dd8f38780e2fa3ab733b2e39dffdf9f82b95383109b021b1a8fde2c3e77c8
6
+ metadata.gz: 796dce4c1700cfaac15bc61049cc6f0dc91ba33d59e37faa08dcb2320e5f792724faf1169c2c4413bb1a7647e9c119f60923769509147bce20d3d2d1fe35467a
7
+ data.tar.gz: d70487b4354d4928adfe3586dfcfbc678ddeb0a3283fa2f2dcc0196f5cfdd6249217fda76c1eed6a8a51c5c7b49f8f60b64bebf8c444517fc19b7488b83549df
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/lib/wingtips.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'shoes'
2
2
  require 'shoes/highlighter'
3
3
 
4
+ require 'wingtips/hash_utils'
4
5
  require 'wingtips/version'
5
6
  require 'wingtips/slide'
6
7
  require 'wingtips/presentation'
@@ -2,16 +2,21 @@ module Wingtips
2
2
  class Configuration
3
3
  include DSL
4
4
 
5
- attr_reader :slide_classes, :app_options
5
+ attr_reader :slide_classes
6
6
 
7
7
  def initialize(path)
8
8
  self.class.current = self
9
- @app_options = {
10
- title: 'Presentation',
11
- fullscreen: true
9
+ @wingtips_options = {
10
+ app: {
11
+ title: 'Presentation',
12
+ fullscreen: true
13
+ },
14
+ templates: {}
12
15
  }
13
16
 
17
+
14
18
  full_path = File.expand_path(path)
19
+ load_options(full_path)
15
20
  load_templates full_path
16
21
  load_named_slides full_path
17
22
 
@@ -22,8 +27,37 @@ module Wingtips
22
27
  self.instance_eval(File.read(full_path))
23
28
  end
24
29
 
25
- def startup_options(opts={})
26
- @app_options.merge!(opts)
30
+ def load_options(full_path)
31
+ begin
32
+ @allow_unnamed_slides = true
33
+ self.instance_eval(File.read(full_path))
34
+ rescue NameError
35
+ @allow_unnamed_slides = false
36
+ # expected to hit the first slide class and then abort evaling
37
+ # the config file. This is necessary so we can have the options at the
38
+ # beginning of the config file while they are needed in the tamplates
39
+ # for instance. So what happens is:
40
+ # 1. read config (options should be on top)
41
+ # 2. error upon encountering the first class, continue in initialize
42
+ # 3. Load slides and templates (while options are already loaded)
43
+ # 4. eval the config file again (options are read again, shouldn't be
44
+ # a problem). This time no error as slide and template classes are
45
+ # loaded
46
+ # Yes there could be a separate options file, but it didn't feel right
47
+ # to have a config and an options file
48
+ end
49
+ end
50
+
51
+ def app_options
52
+ @wingtips_options[:app]
53
+ end
54
+
55
+ def template_options
56
+ @wingtips_options[:templates]
57
+ end
58
+
59
+ def wingtips_options(opts={})
60
+ HashUtils.deep_merge! @wingtips_options, opts
27
61
  end
28
62
 
29
63
  def slides(*slide_classes)
@@ -0,0 +1,19 @@
1
+ module Wingtips
2
+ module HashUtils
3
+ extend self
4
+
5
+ def deep_merge(hash1, hash2)
6
+ deep_merge!(hash1.dup, hash2)
7
+ end
8
+
9
+ def deep_merge!(hash1, hash2)
10
+ hash1.merge! hash2 do |_key, value1, value2|
11
+ if value1.respond_to?(:merge!) && value2.respond_to?(:merge!)
12
+ HashUtils.deep_merge! value1, value2
13
+ else
14
+ value2
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -9,12 +9,21 @@ module Wingtips
9
9
 
10
10
  Shoes.app(config.app_options) do
11
11
  @slides = slides
12
+ @wingtips_options = config.wingtips_options
13
+ @code_highlighting = Shoes::Highlighter::Markup::COLORS
14
+ if @wingtips_options[:code_highlighting]
15
+ @code_highlighting = @code_highlighting.merge @wingtips_options[:code_highlighting]
16
+ end
12
17
 
13
18
  def start
14
19
  setup_controls
15
20
  go_to_slide(0)
16
21
  end
17
22
 
23
+ def code_highlighting
24
+ @code_highlighting
25
+ end
26
+
18
27
  def on_slide_change(&block)
19
28
  @on_slide_change_block = block
20
29
  end
@@ -29,7 +38,7 @@ module Wingtips
29
38
 
30
39
  @current_slide_number = number.to_i
31
40
  slide_class = @slides[@current_slide_number]
32
- @current_slide = slide_class.new(app)
41
+ @current_slide = slide_class.new(app, @wingtips_options)
33
42
  @current_slide.show
34
43
  end
35
44
 
@@ -16,9 +16,10 @@ module Wingtips
16
16
 
17
17
  attr_reader :app
18
18
 
19
- def initialize(app)
19
+ def initialize(app, wingtips_options = {})
20
20
  @app = app
21
21
  @effects = []
22
+ @background_color = wingtips_options[:background_color]
22
23
  after_initialize
23
24
  end
24
25
 
@@ -28,6 +29,7 @@ module Wingtips
28
29
 
29
30
  def show
30
31
  @main_slot = stack height: app.height do
32
+ background @background_color if @background_color
31
33
  content
32
34
  end
33
35
  end
@@ -46,10 +48,11 @@ module Wingtips
46
48
  end
47
49
  end
48
50
 
49
- def code(string, demo_as_effect = false, &block)
51
+ def code(string, demo_as_effect = false, options = {}, &block)
50
52
  source = source_from string
51
53
  source = source.split("\n").map{|line| ' ' + line}.join("\n")
52
- highlighted_code = para *highlight(source), size: CODE_SIZE
54
+ opts = {size: CODE_SIZE}.merge options
55
+ highlighted_code = para *highlight(source, nil, @app.code_highlighting), opts
53
56
  add_demo_as_effect(source, &block) if demo_as_effect
54
57
  highlighted_code
55
58
  end
@@ -126,6 +129,7 @@ module Wingtips
126
129
  def scale_image_by(img, ratio)
127
130
  img.width = (img.width * ratio).to_i
128
131
  img.height = (img.height * ratio).to_i
132
+ img
129
133
  end
130
134
 
131
135
  def centered_title(string, opts={})
@@ -1,3 +1,3 @@
1
1
  module Wingtips
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,4 +1,24 @@
1
1
  # Arrange the order of your slides here
2
+ wingtips_options background_color: Shoes::COLORS[:white],
3
+ code_highlighting: {
4
+ comment: { stroke: "#887" },
5
+ keyword: { stroke: Shoes::COLORS[:navy], weight: 'bold' },
6
+ method: { stroke: Shoes::COLORS[:black], weight: 'bold' },
7
+ symbol: { stroke: Shoes::COLORS[:darkviolet], weight: 'bold' },
8
+ string: { stroke: Shoes::COLORS[:forestgreen], weight: 'bold' },
9
+ number: { stroke: Shoes::COLORS[:steelblue], weight: 'bold' },
10
+ regex: { stroke: "#000", fill: "#FFC" },
11
+ attribute: { stroke: Shoes::COLORS[:darkviolet], weight: 'bold' },
12
+ expr: { stroke: "#722", weight: 'bold' },
13
+ ident: { stroke: "#994c99", weight: 'bold' },
14
+ constant: { stroke: Shoes::COLORS[:darkviolet], weight: "bold" },
15
+ class: { stroke: Shoes::COLORS[:darkviolet], weight: "bold" },
16
+ matching: { stroke: "#ff0", weight: "bold" },
17
+ },
18
+ app: {
19
+ title: 'Wingtips introduction!'
20
+ }
21
+
2
22
  slides Hello, Bullets, DSLSlide, Images, FullScreenImage, FullyShownImage, Code,
3
23
  CodeExecute, HowDoesThisWork
4
24
 
@@ -10,6 +30,11 @@ code = <<-CODE
10
30
  class MyClass
11
31
  def fancy_method
12
32
  magic!
33
+ 5 + 5
34
+ :symbol
35
+ COLOR
36
+ OtherClass
37
+ @conference
13
38
  end
14
39
  end
15
40
  CODE
@@ -0,0 +1,93 @@
1
+ require 'wingtips'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
6
+ # this file to always be loaded, without a need to explicitly require it in any
7
+ # files.
8
+ #
9
+ # Given that it is always loaded, you are encouraged to keep this file as
10
+ # light-weight as possible. Requiring heavyweight dependencies from this file
11
+ # will add to the boot time of your test suite on EVERY test run, even for an
12
+ # individual file that may not need all of that loaded. Instead, consider making
13
+ # a separate helper file that requires the additional dependencies and performs
14
+ # the additional setup, and require it from the spec files that actually need
15
+ # it.
16
+ #
17
+ # The `.rspec` file also contains a few flags that are not defaults but that
18
+ # users commonly want.
19
+ #
20
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+ RSpec.configure do |config|
22
+ # rspec-expectations config goes here. You can use an alternate
23
+ # assertion/expectation library such as wrong or the stdlib/minitest
24
+ # assertions if you prefer.
25
+ config.expect_with :rspec do |expectations|
26
+ # This option will default to `true` in RSpec 4. It makes the `description`
27
+ # and `failure_message` of custom matchers include text for helper methods
28
+ # defined using `chain`, e.g.:
29
+ # be_bigger_than(2).and_smaller_than(4).description
30
+ # # => "be bigger than 2 and smaller than 4"
31
+ # ...rather than:
32
+ # # => "be bigger than 2"
33
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
34
+ end
35
+
36
+ # rspec-mocks config goes here. You can use an alternate test double
37
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
38
+ config.mock_with :rspec do |mocks|
39
+ # Prevents you from mocking or stubbing a method that does not exist on
40
+ # a real object. This is generally recommended, and will default to
41
+ # `true` in RSpec 4.
42
+ mocks.verify_partial_doubles = true
43
+ end
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Limits the available syntax to the non-monkey patched syntax that is
56
+ # recommended. For more details, see:
57
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
58
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
59
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
60
+ config.disable_monkey_patching!
61
+
62
+ # This setting enables warnings. It's recommended, but in some cases may
63
+ # be too noisy due to issues in dependencies.
64
+ config.warnings = true
65
+
66
+ # Many RSpec users commonly either run the entire suite or an individual
67
+ # file, and it's useful to allow more verbose output when running an
68
+ # individual spec file.
69
+ if config.files_to_run.one?
70
+ # Use the documentation formatter for detailed output,
71
+ # unless a formatter has already been configured
72
+ # (e.g. via a command-line flag).
73
+ config.default_formatter = 'doc'
74
+ end
75
+
76
+ # Print the 10 slowest examples and example groups at the
77
+ # end of the spec run, to help surface which specs are running
78
+ # particularly slow.
79
+ config.profile_examples = 10
80
+
81
+ # Run specs in random order to surface order dependencies. If you find an
82
+ # order dependency and want to debug it, you can fix the order by providing
83
+ # the seed, which is printed after each run.
84
+ # --seed 1234
85
+ config.order = :random
86
+
87
+ # Seed global randomization in this process using the `--seed` CLI option.
88
+ # Setting this allows you to use `--seed` to deterministically reproduce
89
+ # test failures related to randomization by passing the same `--seed` value
90
+ # as the one that triggered the failure.
91
+ Kernel.srand config.seed
92
+ =end
93
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Wingtips::HashUtils do
4
+ describe '.deep_merge' do
5
+ it 'merges non conflicting hashes okay' do
6
+ result = Wingtips::HashUtils.deep_merge({a: 1}, {b:2})
7
+ expect(result).to eq({a:1, b:2})
8
+ end
9
+
10
+ it 'resolves easy conflicts ok' do
11
+ result = Wingtips::HashUtils.deep_merge({a: 1}, {a: 20})
12
+ expect(result).to eq({a: 20})
13
+ end
14
+
15
+ it 'merges hashes fine one step down' do
16
+ result = Wingtips::HashUtils.deep_merge({app: {fullscreen: true}},
17
+ {app: {title: 'lala'}})
18
+ expect(result).to eq({app: {fullscreen: true, title: 'lala'}})
19
+ end
20
+
21
+ it 'merges them fine even 3 steps down' do
22
+ result = Wingtips::HashUtils.deep_merge({a: {b: {c: {d: 1, e: 5}}}},
23
+ {a: {b: {c: {d: 20, f: 9}}}})
24
+ expect(result).to eq({a: {b: {c: {d: 20, e: 5, f:9}}}})
25
+ end
26
+
27
+ it 'does not modify the first hash' do
28
+ first = {a: 5}
29
+ Wingtips::HashUtils.deep_merge first, {b: 7}
30
+ expect(first).to eq({a: 5})
31
+ end
32
+
33
+ it 'can merge with a frozen hash' do
34
+ frozen = {a: 7}.freeze
35
+ result = Wingtips::HashUtils.deep_merge frozen, {a: 20}
36
+ expect(result).to eq({a: 20})
37
+ end
38
+ end
39
+
40
+ describe '.deep_merge!' do
41
+ it 'modifies the first hash' do
42
+ first = {a: 5}
43
+ Wingtips::HashUtils.deep_merge! first, {b: 7}
44
+ expect(first).to eq({a: 5, b: 7})
45
+ end
46
+
47
+ it 'raises an error when trying to merge in a frozen hash' do
48
+ frozen = {a: 5}.freeze
49
+ expect {Wingtips::HashUtils.deep_merge! frozen, {a: 20}}.to raise_error
50
+ end
51
+ end
52
+ end
data/wingtips.gemspec CHANGED
@@ -6,7 +6,7 @@ require 'wingtips/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "wingtips"
8
8
  spec.version = Wingtips::VERSION
9
- spec.authors = ['Tobias Pfiffer', 'Jason R. Clark']
9
+ spec.authors = ['Tobias Pfeiffer', 'Jason R. Clark']
10
10
  spec.email = ['pragtob@gmail.com', 'jason@jasonrclark.net']
11
11
  spec.summary = %q{Presentation software for Shoes}
12
12
  spec.description = %q{Put your best foot forward, present with Shoes!}
@@ -19,9 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency "shoes", "~> 4.0.0.pre3"
22
- spec.add_dependency "shoes-highlighter", "~> 1.0.0"
22
+ spec.add_dependency "shoes-highlighter", "~> 1.0.1"
23
23
 
24
24
  spec.add_development_dependency "bundler", "~> 1.7"
25
25
  spec.add_development_dependency "rake", "~> 10.0"
26
26
  spec.add_development_dependency "pry", "~> 0.10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.2"
27
28
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wingtips
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Tobias Pfiffer
7
+ - Tobias Pfeiffer
8
8
  - Jason R. Clark
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-03-16 00:00:00.000000000 Z
12
+ date: 2015-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoes
@@ -31,12 +31,12 @@ dependencies:
31
31
  requirements:
32
32
  - - ~>
33
33
  - !ruby/object:Gem::Version
34
- version: 1.0.0
34
+ version: 1.0.1
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - ~>
38
38
  - !ruby/object:Gem::Version
39
- version: 1.0.0
39
+ version: 1.0.1
40
40
  prerelease: false
41
41
  type: :runtime
42
42
  - !ruby/object:Gem::Dependency
@@ -81,6 +81,20 @@ dependencies:
81
81
  version: 0.10.0
82
82
  prerelease: false
83
83
  type: :development
84
+ - !ruby/object:Gem::Dependency
85
+ name: rspec
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: '3.2'
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ~>
94
+ - !ruby/object:Gem::Version
95
+ version: '3.2'
96
+ prerelease: false
97
+ type: :development
84
98
  description: Put your best foot forward, present with Shoes!
85
99
  email:
86
100
  - pragtob@gmail.com
@@ -91,6 +105,7 @@ extensions: []
91
105
  extra_rdoc_files: []
92
106
  files:
93
107
  - .gitignore
108
+ - .rspec
94
109
  - .ruby-gemset
95
110
  - .ruby-version
96
111
  - Gemfile
@@ -101,6 +116,7 @@ files:
101
116
  - lib/wingtips.rb
102
117
  - lib/wingtips/configuration.rb
103
118
  - lib/wingtips/dsl.rb
119
+ - lib/wingtips/hash_utils.rb
104
120
  - lib/wingtips/presentation.rb
105
121
  - lib/wingtips/slide.rb
106
122
  - lib/wingtips/version.rb
@@ -111,6 +127,8 @@ files:
111
127
  - samples/wingtips_introduction/slides/how_does_this_work.rb
112
128
  - samples/wingtips_introduction/slides/my_slides.rb
113
129
  - samples/wingtips_introduction/templates/code_template.rb
130
+ - spec/spec_helper.rb
131
+ - spec/wingtips/hash_utils_spec.rb
114
132
  - wingtips.gemspec
115
133
  homepage: https://github.com/PragTob/wingtips
116
134
  licenses:
@@ -136,4 +154,6 @@ rubygems_version: 2.4.5
136
154
  signing_key:
137
155
  specification_version: 4
138
156
  summary: Presentation software for Shoes
139
- test_files: []
157
+ test_files:
158
+ - spec/spec_helper.rb
159
+ - spec/wingtips/hash_utils_spec.rb