longbow 0.1.0 → 0.1.1

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: 05bd9d17c6b502aea639b84c1ebdece5bb04b9ec
4
- data.tar.gz: b402bb6a47291e68c5530e24cf73755845f57d08
3
+ metadata.gz: 86277771094b698394dba33a73564319e357dbe8
4
+ data.tar.gz: 515898e907ed93a454e3f2d2e7fa9d0878d216a0
5
5
  SHA512:
6
- metadata.gz: 2fbde0674131935d8aaa3af4a05c5f2dfc4e0cfc21a85bd444a6a1ac381ecf098884a1c22c85e8821d54e9541187985e418e112bc342237c7d70e5bb5f550edf
7
- data.tar.gz: 3c246f41f7edc165bb9573e7974c81e370874a35427cb90c64ff350a2eeec0b7da945a75cca191fbf99474755874238ccb04df1813be157c891b1f5ff0846a99
6
+ metadata.gz: 3cf79384286e062107efcb024ff46fa929408df39a5d403c2ee405bffe37f5c90fc4fcabd80e5ed4488c5a8b4003cd3c3b1893e159045cf4b92d4c11e2bfc47f
7
+ data.tar.gz: 56698aaefc70ed3d0026018cbd9087639d013bcd621e8028256881aa303e373333187505e2852026c2349dd5aa75f90cbd5e8798bf143e99cd12d593e7e19d39
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- longbow (0.1.0)
4
+ longbow (0.1.1)
5
5
  bundler (~> 1.3)
6
6
  commander (~> 4.1)
7
7
  dotenv (~> 0.7)
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  require 'longbow/colors'
4
4
  require 'longbow/targets'
5
5
  require 'longbow/images'
6
+ require 'longbow/json'
6
7
  require 'json'
7
8
 
8
9
  command :shoot do |c|
@@ -11,6 +12,7 @@ command :shoot do |c|
11
12
  c.description = ''
12
13
  c.option '-n', '--name NAME', 'Target name from the corresponding longbow.json file.'
13
14
  c.option '-d', '--directory DIRECTORY', 'Path where the .xcodeproj or .xcworkspace file && the longbow.json file live.'
15
+ c.option '-u', '--url URL', 'URL of a longbow formatted JSON file.'
14
16
 
15
17
  c.action do |args, options|
16
18
  # Check for newer version
@@ -19,23 +21,21 @@ command :shoot do |c|
19
21
  # Set Up
20
22
  @target_name = options.name ? options.name : nil
21
23
  @directory = options.directory ? options.directory : Dir.pwd
24
+ @url = options.url ? options.url : nil
22
25
  @targets = []
23
26
 
24
- # Check for .longbow.json
25
- @json_path = @directory + '/longbow.json'
26
- if !File.exists?(@json_path)
27
- Longbow::red "\n Couldn't find longbow.json at #{@json_path}\n"
28
- puts " Run this command to install the correct files:\n longbow install\n"
29
- next
27
+ # Create JSON object
28
+ if @url
29
+ obj = Longbow::json_object_from_url @url
30
+ else
31
+ obj = Longbow::json_object_from_directory @directory
30
32
  end
31
33
 
32
- # Create an Object from JSON
33
- json_contents = File.open(@json_path).read
34
- unless !!JSON.parse(json_contents)
35
- Longbow::red ' Invalid JSON - lint it, and try again.'
34
+ # Break if Bad
35
+ unless obj
36
+ Longbow::red "\n Invalid JSON. Please lint the file, and try again.\n"
36
37
  next
37
38
  end
38
- obj = JSON.parse(json_contents)
39
39
 
40
40
  # Check for Target Name
41
41
  if @target_name
@@ -48,9 +48,7 @@ command :shoot do |c|
48
48
  next
49
49
  end
50
50
  else
51
- obj['targets'].each do |t|
52
- @targets << t
53
- end
51
+ @targets = obj['targets']
54
52
  end
55
53
 
56
54
  # Begin
@@ -69,7 +69,6 @@ module Longbow
69
69
  target = t['name']
70
70
 
71
71
  ['launch_phone_p', 'launch_phone_l', 'launch_tablet_p', 'launch_tablet_l'].each do |key|
72
- img_path = ''
73
72
  if t[key + '_url']
74
73
  img_path = self.path_for_downloaded_image_from_url directory, key + '_' + target, t[key + '_url'], 'launch'
75
74
  elsif t[key + '_path']
@@ -0,0 +1,42 @@
1
+ $:.push File.expand_path('../', __FILE__)
2
+ require 'colors'
3
+ require 'open-uri'
4
+ require 'json'
5
+
6
+ module Longbow
7
+
8
+ def self.json_object_from_directory directory
9
+ return nil unless directory
10
+
11
+ # Check for longbow.json
12
+ @json_path = directory + '/longbow.json'
13
+ unless File.exists?(@json_path)
14
+ Longbow::red "\n Couldn't find longbow.json at #{@json_path}\n"
15
+ puts " Run this command to install the correct files:\n longbow install\n"
16
+ return nil
17
+ end
18
+
19
+ # Create hash from longbow.json
20
+ json_contents = File.open(@json_path).read
21
+ return json_object_from_string json_contents
22
+ end
23
+
24
+
25
+ def self.json_object_from_url url
26
+ return nil unless url
27
+ contents = ''
28
+ open(url) {|io| contents = io.read}
29
+ return json_object_from_string contents
30
+ end
31
+
32
+ def self.json_object_from_string contents
33
+ begin
34
+ !!JSON.parse(contents)
35
+ rescue
36
+ return nil
37
+ end
38
+
39
+ return JSON.parse(contents)
40
+ end
41
+
42
+ end
@@ -2,7 +2,7 @@ $:.push File.expand_path('../', __FILE__)
2
2
  require 'colors'
3
3
 
4
4
  module Longbow
5
- VERSION = '0.1.0'
5
+ VERSION = '0.1.1'
6
6
 
7
7
  def self.check_for_newer_version
8
8
  if `gem outdated -r`.include? 'longbow'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: longbow
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Intermark Interactive
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -138,6 +138,7 @@ files:
138
138
  - ./lib/longbow/commands/shoot.rb
139
139
  - ./lib/longbow/commands.rb
140
140
  - ./lib/longbow/images.rb
141
+ - ./lib/longbow/json.rb
141
142
  - ./lib/longbow/plist.rb
142
143
  - ./lib/longbow/targets.rb
143
144
  - ./lib/longbow/version.rb