md2key 0.2.2 → 0.3.0

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: a90dab5ae69737096db830c13aeed095a899cd73
4
- data.tar.gz: 521966838c68de48467e6d556f46156ebeb11f65
3
+ metadata.gz: 68f197459ebaa8c0d704124fbabe5848342323a3
4
+ data.tar.gz: 73c7143f88078d5e8c755a7657c68d77bcabd5f3
5
5
  SHA512:
6
- metadata.gz: cb9ad56eaf3c265b54d65e860593ec7f4884ee722fcc8504d0a0021ebd2ec81227772a072d832c06ea748dcb0668ac993fd501166347e4717fd433baf9f26d2c
7
- data.tar.gz: 527cf4e72ece5bc34f7e4bd5eb3597022b74427cc4ccb16a6972e6a40539b80bd026729d412bfbef56d9ac101dba3e6274a6bf25100aee22769157d32465547f
6
+ metadata.gz: 92103cd03fb7421ba0f5a619257a7e29cfa2dc3589a38a3d9e3ba2cc64603fe0cd81d643a9d0062df5ce9e3025d3c033666b2ed841c87455849d7e7f5e6de882
7
+ data.tar.gz: da56aeb04ef8b4abfde8c3c5f0aef41f292bcc65b4c0a53fe515dbaf12da9d237c83ee0bcc4cd5b1bef65f8dc64c0cd4e0d3a55fb74ff9f4c141a895a4ca651e
@@ -1,3 +1,8 @@
1
+ # v0.3.0
2
+
3
+ - Extra slides are deleted automatically
4
+ - Md2key is changed not to fail even if a second slide does not exist
5
+
1
6
  # v0.2.2
2
7
 
3
8
  - Activate a template slide automatically
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Md2key
1
+ # md2key
2
2
 
3
3
  Convert your markdown to keynote.
4
4
 
@@ -12,12 +12,14 @@ module Md2key
12
12
 
13
13
  def generate_keynote!
14
14
  Keynote.activate
15
- Keynote.show_template_slide # to select a layout of slide
16
-
17
15
  Keynote.update_cover(@markdown.cover.title, @markdown.cover.lines.join('\n'))
16
+
17
+ Keynote.delete_extra_slides
18
+ Keynote.show_template_slide # to select a layout of slide
18
19
  @markdown.slides.each_with_index do |slide, index|
19
20
  Keynote.create_slide(slide.title, slide.lines.join('\n'))
20
21
  end
22
+
21
23
  Keynote.delete_template_slide
22
24
  end
23
25
  end
@@ -29,11 +29,28 @@ module Md2key
29
29
  # If you tell `make new slide`, your current slide's theme
30
30
  # will be used.
31
31
  def show_template_slide
32
+ create_slide('', '') if slides_count < 2
32
33
  tell_keynote(<<-APPLE.unindent)
33
34
  show slide #{TEMPLATE_SLIDE_INDEX}
34
35
  APPLE
35
36
  end
36
37
 
38
+ # All slides after a second slide are unnecessary and deleted.
39
+ def delete_extra_slides
40
+ tell_keynote(<<-APPLE.unindent)
41
+ set theSlides to slides of document 1
42
+ set n to #{slides_count}
43
+
44
+ repeat with theSlide in theSlides
45
+ if n > 2 then
46
+ delete slide n of document 1
47
+ end if
48
+
49
+ set n to n - 1
50
+ end repeat
51
+ APPLE
52
+ end
53
+
37
54
  def delete_template_slide
38
55
  tell_keynote(<<-APPLE.unindent)
39
56
  tell document 1
@@ -57,10 +74,21 @@ module Md2key
57
74
 
58
75
  private
59
76
 
77
+ def slides_count
78
+ tell_keynote(<<-APPLE.unindent).to_i
79
+ set n to 0
80
+ set theSlides to slides of document 1
81
+ repeat with theSlide in theSlides
82
+ set n to n + 1
83
+ end repeat
84
+ do shell script "echo " & n
85
+ APPLE
86
+ end
87
+
60
88
  def tell_keynote(script)
61
89
  lines = [
62
90
  'tell application "Keynote"',
63
- *script.split("\n").map { |l| l.prepend(' ') },
91
+ *script.split("\n"),
64
92
  'end tell',
65
93
  ]
66
94
  execute_applescript(lines.join("\n"))
@@ -70,7 +98,7 @@ module Md2key
70
98
  file = Tempfile.new('applescript')
71
99
  file.write(script)
72
100
  file.close
73
- system('osascript', file.path)
101
+ `osascript #{file.path}`.strip
74
102
  ensure
75
103
  file.delete
76
104
  end
@@ -1,3 +1,3 @@
1
1
  module Md2key
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-07 00:00:00.000000000 Z
11
+ date: 2015-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor