keynote-client 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +5 -1
- data/Guardfile +5 -0
- data/README.md +1 -1
- data/Rakefile +12 -2
- data/keynote-client.gemspec +6 -2
- data/lib/keynote-client.rb +5 -2
- data/lib/keynote/document.rb +0 -3
- data/lib/keynote/slide.rb +9 -6
- data/lib/keynote/theme.rb +0 -1
- data/lib/keynote/version.rb +1 -1
- data/spec/keynote/slide_spec.rb +108 -0
- data/spec/spec_helper.rb +20 -1
- metadata +74 -17
- data/spec/keynote/client_spec.rb +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a92dba499c9e0a5edd26ed9bd77af46c1334bc9
|
4
|
+
data.tar.gz: c7dff278572003d453b5662294b0e65ce8be7a27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e6d94f06400b706bfcaa31309691175344d57d486fc0d8770a8326e35d9380c941909a3988892603cfe63b4e8bfc16e30199f5b53931109ba80ffc0924785c5
|
7
|
+
data.tar.gz: 54987691c3b1a076055ab048693e6b5366afc641eb265308782d8029544082837e7e7912d1d2b2c0b6732a60b140bbb6c9aafe9f02a3aaf83b8f3a5750f5ad08
|
data/.travis.yml
CHANGED
data/Guardfile
ADDED
data/README.md
CHANGED
data/Rakefile
CHANGED
@@ -1,7 +1,17 @@
|
|
1
|
+
require 'bundler'
|
1
2
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
+
|
4
|
+
require 'rspec/core'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
3
14
|
|
4
15
|
RSpec::Core::RakeTask.new(:spec)
|
5
16
|
|
6
17
|
task :default => :spec
|
7
|
-
|
data/keynote-client.gemspec
CHANGED
@@ -18,9 +18,13 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.add_development_dependency "pry", "~> 0.10.1"
|
21
22
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
-
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "rspec", "~> 3.3.0"
|
25
|
+
spec.add_development_dependency "simplecov", "~> 0.10.0"
|
26
|
+
spec.add_development_dependency "coveralls", "~> 0.8.2"
|
27
|
+
spec.add_development_dependency "guard", "~> 2.13.0"
|
28
|
+
spec.add_development_dependency "guard-rspec", "~> 4.6.2"
|
24
29
|
spec.add_dependency "unindent", "~> 1.0"
|
25
|
-
spec.add_development_dependency "pry"
|
26
30
|
end
|
data/lib/keynote-client.rb
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'unindent'
|
2
|
+
|
3
3
|
require "keynote/document"
|
4
|
+
require "keynote/theme"
|
4
5
|
require "keynote/master_slide"
|
5
6
|
require "keynote/slide"
|
7
|
+
require 'keynote/slide_array'
|
8
|
+
require "keynote/version"
|
6
9
|
|
7
10
|
module Keynote
|
8
11
|
end
|
data/lib/keynote/document.rb
CHANGED
data/lib/keynote/slide.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'unindent'
|
2
1
|
require 'keynote/util'
|
3
2
|
|
4
3
|
module Keynote
|
@@ -19,7 +18,9 @@ module Keynote
|
|
19
18
|
:transition_properties,
|
20
19
|
)
|
21
20
|
|
22
|
-
def initialize(base_slide, arguments = {})
|
21
|
+
def initialize(base_slide = nil, arguments = {})
|
22
|
+
raise ArgumentError.new('base_slide is not given') unless base_slide
|
23
|
+
|
23
24
|
@base_slide = base_slide
|
24
25
|
arguments.each do |attr, val|
|
25
26
|
send("#{attr}=", val)
|
@@ -27,9 +28,10 @@ module Keynote
|
|
27
28
|
end
|
28
29
|
|
29
30
|
def title=(title)
|
31
|
+
title = title.gsub(/(\r\n|\r|\n)/) { '\\n' }
|
30
32
|
@title = title
|
31
|
-
return unless @document
|
32
|
-
|
33
|
+
return unless @document && @slide_number
|
34
|
+
|
33
35
|
result = eval_script <<-APPLE.unindent
|
34
36
|
var Keynote = Application("Keynote")
|
35
37
|
var doc = Keynote.documents.byId("#{@document.id}")
|
@@ -40,9 +42,10 @@ module Keynote
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def body=(body)
|
45
|
+
body = body.gsub(/(\r\n|\r|\n)/) { '\\n' }
|
43
46
|
@body = body
|
44
|
-
return unless @document
|
45
|
-
|
47
|
+
return unless @document && @slide_number
|
48
|
+
|
46
49
|
result = eval_script <<-APPLE.unindent
|
47
50
|
var Keynote = Application("Keynote")
|
48
51
|
var doc = Keynote.documents.byId("#{@document.id}")
|
data/lib/keynote/theme.rb
CHANGED
data/lib/keynote/version.rb
CHANGED
@@ -0,0 +1,108 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Keynote::Slide do
|
4
|
+
describe '#initialize' do
|
5
|
+
context 'when base_slide is not given' do
|
6
|
+
it 'raises an ArgumentError' do
|
7
|
+
expect { described_class.new }.to raise_error(ArgumentError)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'when base_slide is given' do
|
12
|
+
it 'returns Slide instance' do
|
13
|
+
slide = described_class.new('base_title', title: 'foo')
|
14
|
+
expect(slide).to be_a(described_class)
|
15
|
+
expect(slide.title).to eq('foo')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '#title=' do
|
21
|
+
subject { slide.title=('new_title') }
|
22
|
+
|
23
|
+
context 'when document is not set' do
|
24
|
+
let(:slide) { described_class.new('base_slide') }
|
25
|
+
|
26
|
+
it 'does not eval script to update Keynote' do
|
27
|
+
expect(slide).not_to receive(:eval_script)
|
28
|
+
subject
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when slide_number is not set'do
|
33
|
+
let(:slide) { described_class.new('base_slide', slide_number: 1) }
|
34
|
+
|
35
|
+
it 'does not eval script to update Keynote' do
|
36
|
+
expect(slide).not_to receive(:eval_script)
|
37
|
+
subject
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
context 'when both argument is set' do
|
42
|
+
let(:slide) do
|
43
|
+
described_class.new('base_slide',
|
44
|
+
document: Keynote::Document.new(id: 'some-document-id'),
|
45
|
+
slide_number: 1
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'evals script to update Keynote' do
|
50
|
+
allow(Open3).to receive(:capture2).with(/osascript -l JavaScript/).and_return(["", 1])
|
51
|
+
expect(slide).to receive(:eval_script).with(/new_title/)
|
52
|
+
subject
|
53
|
+
expect(slide.title).to eq('new_title')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#body=' do
|
59
|
+
subject { slide.body=(new_body) }
|
60
|
+
|
61
|
+
let(:new_body) { 'new_body' }
|
62
|
+
|
63
|
+
context 'when document is not set' do
|
64
|
+
let(:slide) { described_class.new('base_slide') }
|
65
|
+
|
66
|
+
it 'does not eval script to update Keynote' do
|
67
|
+
expect(slide).not_to receive(:eval_script)
|
68
|
+
subject
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
context 'when slide_number is not set'do
|
73
|
+
let(:slide) { described_class.new('base_slide', slide_number: 1) }
|
74
|
+
|
75
|
+
it 'does not eval script to update Keynote' do
|
76
|
+
expect(slide).not_to receive(:eval_script)
|
77
|
+
subject
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when document is set' do
|
82
|
+
let(:slide) do
|
83
|
+
described_class.new('base_slide',
|
84
|
+
document: Keynote::Document.new(id: 'some-document-id'),
|
85
|
+
slide_number: 1
|
86
|
+
)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'evals script to update Keynote' do
|
90
|
+
allow(Open3).to receive(:capture2).with(/osascript -l JavaScript/).and_return(["", 1])
|
91
|
+
expect(slide).to receive(:eval_script).with(/new_body/)
|
92
|
+
subject
|
93
|
+
expect(slide.body).to eq('new_body')
|
94
|
+
end
|
95
|
+
|
96
|
+
context 'and when new_body includes new-line character' do
|
97
|
+
let(:new_body) { 'new\nbody' }
|
98
|
+
|
99
|
+
it 'evals script to update Keynote with escaped new body' do
|
100
|
+
allow(Open3).to receive(:capture2).with(/osascript -l JavaScript/).and_return(["", 1])
|
101
|
+
expect(slide).to receive(:eval_script).with(/new\\nbody/)
|
102
|
+
subject
|
103
|
+
expect(slide.body).to eq('new\\nbody')
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,2 +1,21 @@
|
|
1
1
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
-
|
2
|
+
|
3
|
+
require 'simplecov'
|
4
|
+
require 'coveralls'
|
5
|
+
require 'keynote-client'
|
6
|
+
|
7
|
+
Bundler.setup(:default, :development)
|
8
|
+
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.color = true
|
11
|
+
config.tty = true
|
12
|
+
end
|
13
|
+
|
14
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
15
|
+
SimpleCov::Formatter::HTMLFormatter,
|
16
|
+
Coveralls::SimpleCov::Formatter
|
17
|
+
]
|
18
|
+
|
19
|
+
SimpleCov.start do
|
20
|
+
add_filter '/spec/'
|
21
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keynote-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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-12-
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: pry
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.10.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.10.1
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -42,44 +56,86 @@ dependencies:
|
|
42
56
|
name: rspec
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
44
58
|
requirements:
|
45
|
-
- - "
|
59
|
+
- - "~>"
|
46
60
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
61
|
+
version: 3.3.0
|
48
62
|
type: :development
|
49
63
|
prerelease: false
|
50
64
|
version_requirements: !ruby/object:Gem::Requirement
|
51
65
|
requirements:
|
52
|
-
- - "
|
66
|
+
- - "~>"
|
53
67
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
68
|
+
version: 3.3.0
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
70
|
+
name: simplecov
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
73
|
- - "~>"
|
60
74
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
62
|
-
type: :
|
75
|
+
version: 0.10.0
|
76
|
+
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
82
|
+
version: 0.10.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
84
|
+
name: coveralls
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.8.2
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.8.2
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: guard
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
72
100
|
requirements:
|
73
|
-
- - "
|
101
|
+
- - "~>"
|
74
102
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
103
|
+
version: 2.13.0
|
76
104
|
type: :development
|
77
105
|
prerelease: false
|
78
106
|
version_requirements: !ruby/object:Gem::Requirement
|
79
107
|
requirements:
|
80
|
-
- - "
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 2.13.0
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard-rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 4.6.2
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
81
123
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
124
|
+
version: 4.6.2
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: unindent
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '1.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '1.0'
|
83
139
|
description: keynote-client provides a high level API like ActiveRecord style to control
|
84
140
|
your Keynote.
|
85
141
|
email:
|
@@ -92,6 +148,7 @@ files:
|
|
92
148
|
- ".rspec"
|
93
149
|
- ".travis.yml"
|
94
150
|
- Gemfile
|
151
|
+
- Guardfile
|
95
152
|
- LICENSE.txt
|
96
153
|
- README.md
|
97
154
|
- Rakefile
|
@@ -104,7 +161,7 @@ files:
|
|
104
161
|
- lib/keynote/theme.rb
|
105
162
|
- lib/keynote/util.rb
|
106
163
|
- lib/keynote/version.rb
|
107
|
-
- spec/keynote/
|
164
|
+
- spec/keynote/slide_spec.rb
|
108
165
|
- spec/spec_helper.rb
|
109
166
|
homepage: https://github.com/katsuma/keynote-client
|
110
167
|
licenses:
|
@@ -131,5 +188,5 @@ signing_key:
|
|
131
188
|
specification_version: 4
|
132
189
|
summary: keynote client with high level API.
|
133
190
|
test_files:
|
134
|
-
- spec/keynote/
|
191
|
+
- spec/keynote/slide_spec.rb
|
135
192
|
- spec/spec_helper.rb
|