playground 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c814e1cb0877991640c51e0b369421f98616a83d
4
- data.tar.gz: cdfb0592b82703184a26be6795db6186cd708d4f
3
+ metadata.gz: 4d54d299c3750e6391ad6872fd688d3ce5385dd1
4
+ data.tar.gz: 309c4de1322d8d9351891c1ca5bbfdb42befe62a
5
5
  SHA512:
6
- metadata.gz: afdbf37d03c67444e2026baf0fd6a9d0032966dc9846bdb9c65ad530e2a2ed2aa4be10181f57ac97d2315a7cf9f45caeb1e8ed2f1cda24b08dbd6f35466563e9
7
- data.tar.gz: 898b4020df3e080d2f1da4cc929294bb6b3463ef646eb2be42bd4d57a9d5371986bbd2bf826eb6ecaa77dce6a45a724df67e661fd90275bbb51ccf3b193da84e
6
+ metadata.gz: 0e57e8caee3a835b56c22d2ede01e8cbf1e9baa00191a7d1d387caff7e281af41a1899b68f62ad983f718fd1eec9f83fb46b84ab6d9b284aeb8a355f742f8fa3
7
+ data.tar.gz: 4144c55783f86f342b4031fa53dc09b507894d69a2f5fcf7258f3ececd370f778ce7b728cf7fd8057fc758229b0bd87541aa598018022a6dbf416d38b0e53fc5
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
3
  gemspec
4
+
5
+ gem 'rake'
File without changes
@@ -3,9 +3,16 @@ require 'Playground'
3
3
 
4
4
  module Playground
5
5
  class Cli < Thor
6
- desc 'generate [input.markdown] [output.playground]', 'Generate a playground'
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
@@ -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
 
@@ -1,3 +1,3 @@
1
1
  module Playground
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
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.1
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-07-02 00:00:00.000000000 Z
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.markdownd
53
+ - Readme.markdown
54
54
  - bin/playground
55
55
  - lib/playground.rb
56
56
  - lib/playground/cli.rb