motion-rubberstamp 0.0.3 → 0.0.4

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: e73596661dda135a369015be51b33506ee2b7315
4
- data.tar.gz: a03d5fb671385ad48b8f39b208579e0e556a0935
3
+ metadata.gz: 348217ce8090219bffa05a868cdde6444c52c0f5
4
+ data.tar.gz: ecd308178bdf0f6d2a4a8257680b11db2d2f1ba1
5
5
  SHA512:
6
- metadata.gz: 42c3ad2a8fba5cf48df1017c78c11b538a9bcd3664dbb5f79b5cc90deb5cb8d915408c0208fc82383e08502da49d977678649571eeca18fd5c2b0807e38c11ba
7
- data.tar.gz: 10a53c9418f69698f20e336819bb728aea3fade3faf231e2ec6d32a4ad70e3369956c38d30ef542980bcbc9ff89576db9248413b7c90fb1f69bdb594dc7917c7
6
+ metadata.gz: 0b1c82428177a42e8e6acba426e47c965909462efe7c8c032336e337b86e7eff965a2cb726e9e2c6fc395072c8bd8d37f21f5daebaee7a75cfe2abcbe8b84ebc
7
+ data.tar.gz: b7db682ff1966a7ecbaf826fb1aef8b8a811afd7bb2ebaee9b1beb3eb572e296bdb95dccdbe62f103df231f3cbbd120cda2c08538459880271efe6b0649d45ae
data/README.md CHANGED
@@ -62,15 +62,10 @@ Or to remove the overlays and restore your original icons, you can run
62
62
 
63
63
  ## Notes
64
64
 
65
- The iOS Simulator will appear to cache your app icons when you run a
66
- build because RubyMotion's deployer apparently only looks for new resource
67
- files when deploying (it copies resource files to a simulator directory on
68
- your local filesystem). Motion-rubberstamp is still invoked, but it won't
69
- appear to update on your simulator. Deleting the app on your simulator
70
- before building will invoke the refresh but is a non-optimal solution. I
71
- hope to have this solved in the next release.
72
-
73
- Motion-rubberstamp also currently only checks for app icons in the `/resources`
65
+ The iOS Simulator is trying to cache your app icons. For this reason we've put in a significant refresh step!
66
+ Your app data and simulator are restarted on restamp. It's a small but notable necessary evil.
67
+
68
+ Motion-rubberstamp _currently_ only checks for app icons in the `/resources`
74
69
  path, regardless of what your Rakefile is configured for.
75
70
 
76
71
  ## Uninstalling
@@ -1,5 +1,7 @@
1
1
  require 'pathname'
2
2
  require 'fileutils'
3
+ require 'motion/project/app'
4
+ require 'motion/project/config'
3
5
 
4
6
  # Gratuitously lifted from Laurent Sansonetti's motion-testflight.
5
7
  unless defined?(Motion::Project::Config)
@@ -9,20 +11,22 @@ end
9
11
  namespace :rubberstamp do
10
12
  desc "Stamp iOS app icons with version and git information"
11
13
  def process_icon(icon_name, caption)
12
- # There's probably a better way to get this info, I'm not terribly familiar with Ruby's filesystem libs
13
-
14
14
  # Resolve icon's full path
15
15
  pwd = Pathname.pwd
16
16
  filename = "#{pwd.realdirpath.to_s}/#{icon_name}"
17
17
 
18
18
  if File.exist? filename
19
- width= `identify -format '%w' #{filename}`.to_i
20
- new_filename = filename.gsub('_base', '')
21
- status = `convert -background '#0008' -fill white -gravity center -size #{width}x30\
22
- caption:"#{caption}"\
23
- #{filename} +swap -gravity south -composite #{new_filename}`
19
+ width= `identify -format '%w' #{filename}`
20
+ height = (width.to_i * 0.4).to_i
21
+ width = (width.to_i)
22
+ if width >= 57
23
+ new_filename = filename.gsub('_base', '')
24
+ status = `convert -background '#0008' -fill white -gravity center -size #{width.to_i}x#{height} \
25
+ caption:'#{caption}' \
26
+ #{filename} +swap -gravity south -composite #{new_filename}`
27
+ end
24
28
  else
25
- puts "File does not exist, you broke it."
29
+ App.info "motion-rubberstamp", "File does not exist, you broke it."
26
30
  end
27
31
  end
28
32
 
@@ -32,25 +36,52 @@ namespace :rubberstamp do
32
36
  prexisting_base_icons.include?(true)
33
37
  end
34
38
 
39
+ # stub to check if the app needs to be restamped or not.
40
+ def updated?
41
+ true
42
+ end
43
+
44
+ # delete old app!
45
+ def wipe
46
+ app = App.config.app_bundle('iPhoneSimulator')
47
+ target = ENV['target'] || App.config.sdk_version
48
+ sim_apps = File.expand_path("~/Library/Application Support/iPhone Simulator/#{target}/Applications")
49
+ Dir.glob("#{sim_apps}/**/*.app").each do |app_bundle|
50
+ if File.basename(app_bundle) == File.basename(app)
51
+ p "Deleting #{app_bundle}"
52
+ rm_rf File.dirname(app_bundle)
53
+ break
54
+ end
55
+ end
56
+ end
57
+
35
58
  task :run do
36
- # Automatically run install on first run
37
- Rake::Task["rubberstamp:install"].execute unless installed?
38
-
39
- # piggyback on RubyMotion's own app config tool
40
- project_config_vars = Motion::Project::App.config.variables
41
- app_version = project_config_vars['version']
42
- # execute shell commands to get git info
43
- git_commit = `git rev-parse --short HEAD`
44
- git_branch = `git rev-parse --abbrev-ref HEAD`
45
-
46
- caption = "v#{app_version} #{git_commit} #{git_branch}"
47
- # process_icon("Icon_base.png", caption)
48
- # process_icon("Icon@2x_base.png", caption)
49
- # process_icon("Icon-72_base.png", caption)
50
- # process_icon("Icon-72@2x_base.png", caption)
51
- App.info "motion-rubberstamp", "Rubberstamping icons..."
52
- Dir.glob('resources/*_base.png').each do |icon|
53
- process_icon(icon, caption)
59
+
60
+ if updated?
61
+ # Clean old out the simulator
62
+ Rake::Task["rubberstamp:sim_clean"].execute
63
+ # Automatically run install on first run
64
+ Rake::Task["rubberstamp:install"].execute unless installed?
65
+
66
+ # piggyback on RubyMotion's own app config tool
67
+ project_config_vars = Motion::Project::App.config.variables
68
+ app_version = project_config_vars['version']
69
+ # execute shell commands to get git info
70
+ git_commit = `git rev-parse --short HEAD`
71
+ git_branch = `git rev-parse --abbrev-ref HEAD`
72
+
73
+ caption = "v#{app_version} #{git_commit.strip} #{git_branch.strip}"
74
+ # process_icon("Icon_base.png", caption)
75
+ # process_icon("Icon@2x_base.png", caption)
76
+ # process_icon("Icon-72_base.png", caption)
77
+ # process_icon("Icon-72@2x_base.png", caption)
78
+ App.info "motion-rubberstamp", "Rubberstamping icons..."
79
+ Dir.glob('resources/*_base.png').each do |icon|
80
+ process_icon(icon, caption)
81
+ end
82
+
83
+ else
84
+ App.info "motion-rubberstamp", "No change detected"
54
85
  end
55
86
  end
56
87
 
@@ -76,6 +107,16 @@ namespace :rubberstamp do
76
107
  end
77
108
  end
78
109
 
110
+ desc "Deletes app and kills the simulator (for cache reasons)"
111
+ task :sim_clean do
112
+ App.info "motion-rubberstamp", "Deleting App from simulator for new icons."
113
+ wipe
114
+ scripts_dir = File.join(File.dirname(__FILE__), "scripts")
115
+ close_script = File.expand_path(File.join(scripts_dir, "close_simulator.applescript"))
116
+
117
+ system("osascript #{close_script}")
118
+ end
119
+
79
120
  end
80
121
 
81
122
  # Make rubberstamp run before any build
@@ -0,0 +1,15 @@
1
+ tell application "iPhone Simulator"
2
+ activate
3
+ end tell
4
+
5
+ tell application "System Events"
6
+ tell process "iPhone Simulator"
7
+ tell menu bar 1
8
+ tell menu bar item "iOs Simulator"
9
+ tell menu "iOs Simulator"
10
+ click menu item "Quit iOS Simulator"
11
+ end tell
12
+ end tell
13
+ end tell
14
+ end tell
15
+ end tell
@@ -1,4 +1,4 @@
1
1
  module Rubberstamp
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-rubberstamp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Garrison
@@ -52,6 +52,7 @@ files:
52
52
  - Rakefile
53
53
  - lib/motion-rubberstamp.rb
54
54
  - lib/motion/project/rubberstamp.rb
55
+ - lib/motion/project/scripts/close_simulator.applescript
55
56
  - lib/rubberstamp/version.rb
56
57
  - motion-rubberstamp.gemspec
57
58
  homepage: http://github.com/iconoclastlabs/motion-rubberstamp