keynote-client 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/lib/keynote/document.rb +54 -27
- data/lib/keynote/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4c4744a2aa2fb814a90ac556a0713e2eb774c9f2
|
4
|
+
data.tar.gz: 10a2e69dce31aede9cb96c6c340250a7dce40c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7885c96f7b91d6d5e89ff5d135d05c1745c8a911834eb10843725e7a74925cc947200cfd341fc025aeb3e97e40edc86ff815ee9c10f8a4c12076bdfd8678c938
|
7
|
+
data.tar.gz: b053a819f7e65aced80c6bf0ecac85c4db65606938b258e38ba3f2c947d9389519dd7449d0357cddf7142c26ff0de8fe6ad148ea95eddda925c674c20abf2964
|
data/README.md
CHANGED
@@ -8,6 +8,27 @@ Currently this project is in alpha stage. It supports these features.
|
|
8
8
|
- Appending a new slide with specified master slide
|
9
9
|
- Saving a document
|
10
10
|
|
11
|
+
## Install
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
gem keynote-client'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```sh
|
28
|
+
$ gem install keynote-client
|
29
|
+
```
|
30
|
+
|
31
|
+
|
11
32
|
## Usage
|
12
33
|
|
13
34
|
```ruby
|
@@ -25,7 +46,7 @@ themes = Theme.find_by(:all)
|
|
25
46
|
theme = Theme.find_by(name: 'ブラック').first
|
26
47
|
# #<Keynote::Theme:0x007fd9ec821748 @id="Application/Black/Standard", @name="ブラック">,
|
27
48
|
|
28
|
-
doc = Document.
|
49
|
+
doc = Document.create(theme: theme, file_path: '/path/to/foo.key')
|
29
50
|
# => #<Keynote::Document:0x007fbe03224228
|
30
51
|
# @auto_loop=false,
|
31
52
|
# @auto_play=false,
|
data/lib/keynote/document.rb
CHANGED
@@ -35,17 +35,15 @@ module Keynote
|
|
35
35
|
@width = arguments.has_key?(:wide) && arguments[:wide] ? WIDE_WIDTH : DEFAULT_WIDTH
|
36
36
|
@height = arguments.has_key?(:wide) && arguments[:wide] ? WIDE_HEIGHT : DEFAULT_HEIGHT
|
37
37
|
@file_path = arguments[:file_path]
|
38
|
-
|
39
|
-
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@
|
46
|
-
@
|
47
|
-
@maximum_idle_duration = result["maximumIdleDuration"]
|
48
|
-
@name = result["name"]
|
38
|
+
@id = arguments[:id]
|
39
|
+
@maximum_idle_duration = arguments[:maximumIdleDuration]
|
40
|
+
@current_slide = arguments[:currentSlide]
|
41
|
+
@slide_numbers_showing = arguments[:slideNumbersShowing]
|
42
|
+
@auto_loop = arguments[:autoLoop]
|
43
|
+
@auto_play = arguments[:autoPlay]
|
44
|
+
@auto_restart = arguments[:autoRestart]
|
45
|
+
@maximum_idle_duration = arguments[:maximumIdleDuration]
|
46
|
+
@name = arguments[:name]
|
49
47
|
end
|
50
48
|
|
51
49
|
def master_slides
|
@@ -170,26 +168,55 @@ module Keynote
|
|
170
168
|
|
171
169
|
def self.create(arguments = {})
|
172
170
|
theme = arguments[:theme] || Theme.default
|
173
|
-
width = arguments[:
|
174
|
-
height = arguments[:
|
171
|
+
width = arguments[:wide] ? WIDE_WIDTH : DEFAULT_WIDTH
|
172
|
+
height = arguments[:wide] ? WIDE_HEIGHT : DEFAULT_HEIGHT
|
175
173
|
|
176
|
-
eval_script <<-APPLE.unindent
|
174
|
+
result = eval_script <<-APPLE.unindent
|
177
175
|
var Keynote = Application("Keynote")
|
178
176
|
var theme = Keynote.themes.whose({ id: "#{theme.id}" }).first
|
179
|
-
Keynote.
|
180
|
-
|
181
|
-
JSON.stringify(
|
182
|
-
id: doc.id(),
|
183
|
-
height: doc.height(),
|
184
|
-
autoRestart: doc.autoRestart(),
|
185
|
-
maximumIdleDuration: doc.maximumIdleDuration(),
|
186
|
-
width: doc.width(),
|
187
|
-
slideNumbersShowing: doc.slideNumbersShowing(),
|
188
|
-
autoPlay: doc.autoPlay(),
|
189
|
-
autoLoop: doc.autoLoop(),
|
190
|
-
name: doc.name()
|
191
|
-
});
|
177
|
+
var doc = Keynote.Document({ documentTheme: theme, width: #{width}, height: #{height} });
|
178
|
+
Keynote.documents.push(doc);
|
179
|
+
JSON.stringify(doc.properties());
|
192
180
|
APPLE
|
181
|
+
|
182
|
+
self.new(symbolize_keys(result).merge(theme: theme, width: width, height: height))
|
183
|
+
end
|
184
|
+
|
185
|
+
def self.find_by(args)
|
186
|
+
raise ArgumentError.new('nil argument is given') unless args
|
187
|
+
|
188
|
+
if args.is_a?(Hash) && args.has_key?(:id)
|
189
|
+
conditions = ".whose({ id: '#{args[:id]}' })"
|
190
|
+
elsif args == :all
|
191
|
+
conditions = ''
|
192
|
+
else
|
193
|
+
raise ArgumentError.new('Unsupported argument is given')
|
194
|
+
end
|
195
|
+
|
196
|
+
results = eval_script <<-APPLE.unindent
|
197
|
+
var documents = Application("Keynote").documents#{conditions};
|
198
|
+
var results = [];
|
199
|
+
for(var i = 0, len = documents.length; i < len; i++) {
|
200
|
+
results.push(documents[i].properties());
|
201
|
+
}
|
202
|
+
JSON.stringify(results);
|
203
|
+
APPLE
|
204
|
+
|
205
|
+
return [] unless results
|
206
|
+
|
207
|
+
results.map do |result|
|
208
|
+
self.new(symbolize_keys(result))
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def self.current
|
213
|
+
self.find_by(:all).first
|
214
|
+
end
|
215
|
+
|
216
|
+
private
|
217
|
+
|
218
|
+
def self.symbolize_keys(hash)
|
219
|
+
Hash[hash.map { |k, v| [k.to_sym, v] }]
|
193
220
|
end
|
194
221
|
end
|
195
222
|
end
|
data/lib/keynote/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keynote-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ryo katsuma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.2.2
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: keynote client with high level API.
|