playground 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/Gemfile +2 -0
- data/{Readme.markdownd → Readme.markdown} +0 -0
- data/lib/playground/cli.rb +8 -1
- data/lib/playground/generator.rb +24 -0
- data/lib/playground/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: 4d54d299c3750e6391ad6872fd688d3ce5385dd1
|
4
|
+
data.tar.gz: 309c4de1322d8d9351891c1ca5bbfdb42befe62a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e57e8caee3a835b56c22d2ede01e8cbf1e9baa00191a7d1d387caff7e281af41a1899b68f62ad983f718fd1eec9f83fb46b84ab6d9b284aeb8a355f742f8fa3
|
7
|
+
data.tar.gz: 4144c55783f86f342b4031fa53dc09b507894d69a2f5fcf7258f3ececd370f778ce7b728cf7fd8057fc758229b0bd87541aa598018022a6dbf416d38b0e53fc5
|
data/Gemfile
CHANGED
File without changes
|
data/lib/playground/cli.rb
CHANGED
@@ -3,9 +3,16 @@ require 'Playground'
|
|
3
3
|
|
4
4
|
module Playground
|
5
5
|
class Cli < Thor
|
6
|
-
desc 'generate
|
6
|
+
desc 'generate <input.markdown> <output.playground>', 'Generate a playground'
|
7
7
|
def generate(input, output)
|
8
8
|
Generator.new.generate(input, output)
|
9
9
|
end
|
10
|
+
|
11
|
+
desc 'new [output.playground]', 'Generate an empty playground and open it in Xcode'
|
12
|
+
option :ios
|
13
|
+
def new(path=nil)
|
14
|
+
platform = options[:ios] ? "iphonesimulator" : "macosx"
|
15
|
+
Generator.new.generate_empty(path, platform)
|
16
|
+
end
|
10
17
|
end
|
11
18
|
end
|
data/lib/playground/generator.rb
CHANGED
@@ -75,6 +75,30 @@ module Playground
|
|
75
75
|
|
76
76
|
File.write(@output + "/#{filename}", swift)
|
77
77
|
end
|
78
|
+
|
79
|
+
|
80
|
+
def generate_empty(path, platform)
|
81
|
+
if path.nil?
|
82
|
+
# Create playground using current date as name
|
83
|
+
time = Time.now.strftime "%Y%m%d-%H%M%S"
|
84
|
+
path = "/tmp/playgrounds/#{time}.playground"
|
85
|
+
end
|
86
|
+
# Add extension if not provided
|
87
|
+
path += ".playground" unless /.playground$/.match(path)
|
88
|
+
FileUtils.mkdir_p(path)
|
89
|
+
# Minimum xml so that Xcode recognizes it as a valid playground
|
90
|
+
contents_xcplayground = "<?xml version='1.0' encoding='UTF-8' standalone='yes'?><playground version='1.0' sdk='#{platform}'><sections><code source-file-name='section-1.swift'/></sections></playground>"
|
91
|
+
File.open(path + "/contents.xcplayground", 'w') {|f| f.write(contents_xcplayground) }
|
92
|
+
|
93
|
+
# Create the swift file
|
94
|
+
section1_swift = "// Playground - noun: a place where people can play\n\nimport #{platform=='macosx' ? 'Cocoa' : 'UIKit'}\n\nvar str = \"Hello, playground\""
|
95
|
+
File.open(path + "/section-1.swift", 'w') {|f| f.write(section1_swift) }
|
96
|
+
|
97
|
+
# Open with Xcode
|
98
|
+
if !system("open \"#{path}\" 2>/dev/null")
|
99
|
+
puts "There was an error opening #{path}"
|
100
|
+
end
|
101
|
+
end
|
78
102
|
|
79
103
|
private
|
80
104
|
|
data/lib/playground/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: playground
|
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
|
- Sam Soffes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redcarpet
|
@@ -50,7 +50,7 @@ files:
|
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE
|
52
52
|
- Rakefile
|
53
|
-
- Readme.
|
53
|
+
- Readme.markdown
|
54
54
|
- bin/playground
|
55
55
|
- lib/playground.rb
|
56
56
|
- lib/playground/cli.rb
|