md2key 0.4.1 → 0.4.2

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: 3bd96ffc0f4fefb99341bfed8c3f4f3c09ed3edb
4
- data.tar.gz: e8734c6294e3bfc804ca93be06cc7e9f954acbf2
3
+ metadata.gz: e830ebe50efe1de313b1293cb3a5f6f2e4c7944b
4
+ data.tar.gz: a5e61934898bc39b8bd1bf59ecdea062f871e0f2
5
5
  SHA512:
6
- metadata.gz: a6cbc4dea1091b64fcbcd5c70d4cbf824a313955bb4b15f12c9dd41e35c0a1b360834f753658459ffb4fc3f2651b71b8e6d4a3c2147a9b447d99edbc4c7b2e49
7
- data.tar.gz: d340cb217bdcbb479f84da983f3a9459bd12f61bf622a2439692ff190c6e496b85361b8113d37d17850d67704f4885371dd585d49e288b4af2d2ee5dcdecab88
6
+ metadata.gz: e82f90d69a2358795c691eb3c7b76b263b5755462826036e04dd10b98dfe25fec5e58f85ce466586440f7897cc3550e5826fd0d27425d85f81db235bbfcfb341
7
+ data.tar.gz: 77e78642f8125801b1648b1772e61c45ed27260175187e1e60aaf3553ce907dd6b24c63390ccca184af40d913cd4e7ac1585f9917205f0a477c8d38ba5a0f0b0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # v0.4.2
2
+
3
+ - Internal refactorings
4
+ - Drop unindent gem dependency
5
+
1
6
  # v0.4.1
2
7
 
3
8
  - Performance improvement
@@ -1,36 +1,36 @@
1
- require 'unindent'
2
-
3
1
  module Md2key
4
2
  class Keynote
3
+ COVER_SLIDE_INDEX = 1
4
+ TEMPLATE_SLIDE_INDEX = 2
5
5
  CODE_BACKGROUND_PATH = File.expand_path('../../assets/background.png', __dir__)
6
6
 
7
7
  class << self
8
8
  # You must provide a first slide as a cover slide.
9
- def update_cover(title, sub)
10
- execute_applescript(:void, :update_cover, title, sub)
9
+ def update_cover(title, content)
10
+ execute_applescript('update_slide', title, content, COVER_SLIDE_INDEX)
11
11
  end
12
12
 
13
13
  def ensure_template_slide_availability
14
14
  return if slides_count >= 2
15
- execute_applescript(:void, :ensure_template_slide_availability)
15
+ execute_applescript('create_empty_slide')
16
16
  end
17
17
 
18
18
  # All slides after a second slide are unnecessary and deleted.
19
19
  def delete_extra_slides
20
- execute_applescript(:void, :delete_extra_slides, slides_count)
20
+ execute_applescript('delete_extra_slides', slides_count)
21
21
  end
22
22
 
23
23
  def delete_template_slide
24
- execute_applescript(:void, :delete_template_slide)
24
+ execute_applescript('delete_slide', TEMPLATE_SLIDE_INDEX)
25
25
  end
26
26
 
27
27
  def create_slide(title, content)
28
- execute_applescript(:void, :create_slide, title, content)
28
+ execute_applescript('create_slide', title, content, TEMPLATE_SLIDE_INDEX)
29
29
  end
30
30
 
31
31
  # Insert image to the last slide
32
32
  def insert_image(path)
33
- execute_applescript(:void, :insert_image, slides_count, path)
33
+ execute_applescript('insert_image', slides_count, path, TEMPLATE_SLIDE_INDEX)
34
34
  end
35
35
 
36
36
  def insert_code(code)
@@ -43,34 +43,30 @@ module Md2key
43
43
  private
44
44
 
45
45
  def insert_code_background
46
- execute_applescript(:void, :insert_code_background, slides_count, CODE_BACKGROUND_PATH)
46
+ execute_applescript('insert_code_background', slides_count, CODE_BACKGROUND_PATH)
47
47
  end
48
48
 
49
49
  def activate_last_slide
50
- execute_applescript(:void, :activate_last_slide)
50
+ execute_applescript('activate_slide', slides_count)
51
51
  end
52
52
 
53
53
  def paste_clipboard
54
- execute_applescript(:void, :paste_clipboard)
54
+ execute_applescript('paste_clipboard')
55
55
  end
56
56
 
57
57
  def slides_count
58
- execute_applescript(:int, :slides_count)
58
+ execute_applescript('slides_count').to_i
59
59
  end
60
60
 
61
- def execute_applescript(type, script_name, *args)
62
- path = script_path(script_name.to_s)
63
- args.map! { |arg| "\"#{arg}\"" }
64
- command = "osascript #{path} #{args.join(' ')}"
65
- `#{command + ' > /dev/null'}` if type == :void
66
- `#{command}}`.to_i if type == :int
61
+ def execute_applescript(script_name, *args)
62
+ path = script_path(script_name)
63
+ `osascript #{path} "#{args.join('" "')}"`
67
64
  end
68
65
 
69
66
  def script_path(script_name)
70
- applescripts_path = File.expand_path('applescripts', __dir__)
71
- File.join(applescripts_path, "#{script_name}.applescript")
67
+ scripts_path = File.expand_path('../../scripts', __dir__)
68
+ File.join(scripts_path, "#{script_name}.scpt")
72
69
  end
73
-
74
70
  end
75
71
  end
76
72
  end
@@ -1,3 +1,3 @@
1
1
  module Md2key
2
- VERSION = "0.4.1"
2
+ VERSION = "0.4.2"
3
3
  end
data/md2key.gemspec CHANGED
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "thor", "~> 0.19"
21
- spec.add_dependency "unindent", "~> 1.0"
22
21
  spec.add_dependency "redcarpet", "~> 3.3"
23
22
  spec.add_dependency "oga", "~> 1.2"
24
23
  spec.add_development_dependency "bundler", "~> 1.10"
@@ -0,0 +1,13 @@
1
+ on run argv
2
+ set slideIndex to item 1 of argv as number
3
+
4
+ tell application "Keynote"
5
+ -- This can't be removed because using Cmd-v to paste.
6
+ activate
7
+
8
+ tell the front document
9
+ -- Workaround to focus on specified slide.
10
+ move slide slideIndex to before slide slideIndex
11
+ end tell
12
+ end tell
13
+ end run
@@ -0,0 +1,5 @@
1
+ tell application "Keynote"
2
+ tell the front document
3
+ make new slide
4
+ end
5
+ end tell
@@ -0,0 +1,20 @@
1
+ on run argv
2
+ set slideTitle to item 1 of argv
3
+ set slideBody to item 2 of argv
4
+ set templateIndex to item 3 of argv as number
5
+
6
+ tell application "Keynote"
7
+ tell the front document
8
+ -- Workaround to select correct master slide. In spite of master slide can be selected by name,
9
+ -- name property is not limited to be unique.
10
+ -- So move the focus to second slide and force "make new slide" to use the exact master slide.
11
+ move slide templateIndex to before slide templateIndex
12
+
13
+ set newSlide to make new slide
14
+ tell newSlide
15
+ set object text of default title item to slideTitle
16
+ set object text of default body item to slideBody
17
+ end tell
18
+ end tell
19
+ end tell
20
+ end run
@@ -0,0 +1,17 @@
1
+ on run argv
2
+ set slidesCount to item 1 of argv as number
3
+
4
+ tell application "Keynote"
5
+ tell the front document
6
+ set i to slidesCount
7
+
8
+ repeat with s in slides
9
+ if i > 2 then
10
+ delete slide i
11
+ end if
12
+
13
+ set i to i - 1
14
+ end repeat
15
+ end tell
16
+ end tell
17
+ end run
@@ -0,0 +1,9 @@
1
+ on run argv
2
+ set slideIndex to item 1 of argv as number
3
+
4
+ tell application "Keynote"
5
+ tell the front document
6
+ delete slide slideIndex
7
+ end tell
8
+ end tell
9
+ end run
@@ -0,0 +1,15 @@
1
+ on run argv
2
+ set lastIndex to item 1 of argv as number
3
+ set theImage to item 2 of argv as POSIX file
4
+
5
+ tell application "Keynote"
6
+ tell the front document
7
+ set docWidth to its width
8
+ set docHeight to its height
9
+
10
+ tell slide lastIndex
11
+ make new image with properties { opacity: 80, file: theImage, width: docWidth - 180, position: { 90, 240 } }
12
+ end tell
13
+ end tell
14
+ end tell
15
+ end run
@@ -0,0 +1,25 @@
1
+ on run argv
2
+ set lastIndex to item 1 of argv as number
3
+ set theImage to item 2 of argv as POSIX file
4
+ set templateIndex to item 3 of argv as number
5
+
6
+ tell application "Keynote"
7
+ tell the front document
8
+ set docWidth to its width
9
+ set docHeight to its height
10
+
11
+ -- Create temporary slide to fix the image size
12
+ tell slide templateIndex
13
+ set imgFile to make new image with properties { file: theImage, width: docWidth / 3 }
14
+ tell imgFile
15
+ set imgWidth to its width
16
+ set imgHeight to its width
17
+ end tell
18
+ end tell
19
+
20
+ tell slide lastIndex
21
+ make new image with properties { file: theImage, width: imgWidth, position: { docWidth - imgWidth - 60, docHeight / 2 - imgHeight / 2 } }
22
+ end tell
23
+ end tell
24
+ end tell
25
+ end run
@@ -0,0 +1,7 @@
1
+ tell application "Keynote"
2
+ tell application "System Events"
3
+ tell application process "Keynote"
4
+ keystroke "v" using { command down }
5
+ end tell
6
+ end tell
7
+ end tell
@@ -0,0 +1,10 @@
1
+ tell application "Keynote"
2
+ tell the front document
3
+ set n to 0
4
+ repeat with s in slides
5
+ set n to n + 1
6
+ end repeat
7
+ end tell
8
+
9
+ do shell script "echo " & n
10
+ end tell
@@ -0,0 +1,14 @@
1
+ on run argv
2
+ set slideTitle to item 1 of argv
3
+ set slideBody to item 2 of argv
4
+ set slideIndex to item 3 of argv as number
5
+
6
+ tell application "Keynote"
7
+ tell the front document
8
+ tell slide slideIndex
9
+ set object text of default title item to slideTitle
10
+ set object text of default body item to slideBody
11
+ end tell
12
+ end tell
13
+ end tell
14
+ end run
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md2key
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Takashi Kokubun
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0.19'
27
- - !ruby/object:Gem::Dependency
28
- name: unindent
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '1.0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '1.0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: redcarpet
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -124,16 +110,6 @@ files:
124
110
  - assets/background.png
125
111
  - bin/md2key
126
112
  - lib/md2key.rb
127
- - lib/md2key/applescripts/activate_last_slide.applescript
128
- - lib/md2key/applescripts/create_slide.applescript
129
- - lib/md2key/applescripts/delete_extra_slides.applescript
130
- - lib/md2key/applescripts/delete_template_slide.applescript
131
- - lib/md2key/applescripts/ensure_template_slide_availability.applescript
132
- - lib/md2key/applescripts/insert_code_background.applescript
133
- - lib/md2key/applescripts/insert_image.applescript
134
- - lib/md2key/applescripts/paste_clipboard.applescript
135
- - lib/md2key/applescripts/slides_count.applescript
136
- - lib/md2key/applescripts/update_cover.applescript
137
113
  - lib/md2key/cli.rb
138
114
  - lib/md2key/code.rb
139
115
  - lib/md2key/converter.rb
@@ -143,6 +119,16 @@ files:
143
119
  - lib/md2key/slide.rb
144
120
  - lib/md2key/version.rb
145
121
  - md2key.gemspec
122
+ - scripts/activate_slide.scpt
123
+ - scripts/create_empty_slide.scpt
124
+ - scripts/create_slide.scpt
125
+ - scripts/delete_extra_slides.scpt
126
+ - scripts/delete_slide.scpt
127
+ - scripts/insert_code_background.scpt
128
+ - scripts/insert_image.scpt
129
+ - scripts/paste_clipboard.scpt
130
+ - scripts/slides_count.scpt
131
+ - scripts/update_slide.scpt
146
132
  homepage: https://github.com/k0kubun/md2key
147
133
  licenses: []
148
134
  metadata: {}
@@ -1,14 +0,0 @@
1
- on run argv
2
- tell application "Keynote"
3
- activate
4
-
5
- tell the front document
6
- set n to 0
7
- repeat with s in slides
8
- set n to n + 1
9
- end repeat
10
-
11
- move slide n to before slide n
12
- end tell
13
- end tell
14
- end run
@@ -1,19 +0,0 @@
1
- -- First argument - title
2
- -- Second arument - content
3
- on run argv
4
- tell application "Keynote"
5
- tell the front document
6
- -- Workaround to select correct master slide. In spite of master slide can be selected by name,
7
- -- name property is not limited to be unique.
8
- -- So move the focus to second slide and force "make new slide" to use the exact master slide.
9
- set TEMPLATE_SLIDE_INDEX to 2
10
- move slide TEMPLATE_SLIDE_INDEX to before slide TEMPLATE_SLIDE_INDEX
11
-
12
- set newSlide to make new slide
13
- tell newSlide
14
- set object text of default title item to first item of argv
15
- set object text of default body item to second item of argv
16
- end tell
17
- end tell
18
- end tell
19
- end run
@@ -1,15 +0,0 @@
1
- -- First argument - slides count
2
- on run argv
3
- tell application "Keynote"
4
- set theSlides to slides of the front document
5
- set n to first item of argv as number
6
-
7
- repeat with theSlide in theSlides
8
- if n > 2 then
9
- delete slide n of the front document
10
- end if
11
-
12
- set n to n - 1
13
- end repeat
14
- end tell
15
- end run
@@ -1,6 +0,0 @@
1
- tell application "Keynote"
2
- set TEMPLATE_SLIDE_INDEX to 2
3
- tell the front document
4
- delete slide TEMPLATE_SLIDE_INDEX
5
- end tell
6
- end tell
@@ -1,5 +0,0 @@
1
- tell application "Keynote"
2
- tell the front document
3
- make new slide
4
- end
5
- end tell
@@ -1,17 +0,0 @@
1
- -- First argument - slides count
2
- -- Second argument - code background path
3
-
4
- on run argv
5
- tell application "Keynote"
6
- tell the front document
7
- set theSlide to slide (first item of argv as number)
8
- set theImage to second item of argv as POSIX file
9
- set docWidth to its width
10
- set docHeight to its height
11
-
12
- tell theSlide
13
- make new image with properties {opacity:80, file:theImage, width:docWidth - 180, position:{90, 240}}
14
- end tell
15
- end tell
16
- end tell
17
- end run
@@ -1,28 +0,0 @@
1
- -- First argument - slides count
2
- -- Second argument - POSIX path
3
- on run argv
4
- tell application "Keynote"
5
- tell the front document
6
- set TEMPLATE_SLIDE_INDEX to 2
7
-
8
- set slideNumber to first item of argv as number
9
- set theSlide to slide slideNumber
10
- set theImage to second item of argv as POSIX file
11
- set docWidth to its width
12
- set docHeight to its height
13
-
14
- -- Create temporary slide to fix the image size
15
- tell slide TEMPLATE_SLIDE_INDEX
16
- set imgFile to make new image with properties { file:theImage, width:docWidth / 3 }
17
- tell imgFile
18
- set imgWidth to its width
19
- set imgHeight to its width
20
- end tell
21
- end tell
22
-
23
- tell theSlide
24
- make new image with properties {file:theImage, width:imgWidth, position:{ docWidth - imgWidth - 60, docHeight / 2 - imgHeight / 2 } }
25
- end tell
26
- end tell
27
- end tell
28
- end run
@@ -1,7 +0,0 @@
1
- tell application "Keynote"
2
- tell application "System Events"
3
- tell application process "Keynote"
4
- keystroke "v" using { command down }
5
- end tell
6
- end tell
7
- end tell
@@ -1,8 +0,0 @@
1
- tell application "Keynote"
2
- set n to 0
3
- set theSlides to slides of the front document
4
- repeat with theSlide in theSlides
5
- set n to n + 1
6
- end repeat
7
- do shell script "echo " & n
8
- end tell
@@ -1,14 +0,0 @@
1
- -- First argument - title
2
- -- Second argument - sub
3
- on run argv
4
- tell application "Keynote"
5
- set COVER_SLIDE_INDEX to 1
6
-
7
- tell the front document
8
- tell slide COVER_SLIDE_INDEX
9
- set object text of default title item to first item of argv
10
- set object text of default body item to second item of argv
11
- end tell
12
- end tell
13
- end tell
14
- end run