Skip to content

Commit

Permalink
add registration submenu and remove support for the old yaml preferences
Browse files Browse the repository at this point in the history
  • Loading branch information
henderea committed Jul 24, 2014
1 parent 425a619 commit 4967da7
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 32 deletions.
4 changes: 1 addition & 3 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ source 'https://rubygems.org'
gem 'rake'
# Add your dependencies here:
gem 'everyday-menu', '>= 1.3.4'
gem 'bubble-wrap', require: 'bubble-wrap/core'
gem 'bubble-wrap-http'
gem 'motion-yaml'
gem 'bubble-wrap', require: 'bubble-wrap/core'
3 changes: 0 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ GEM
bubble-wrap-http (1.7.0)
everyday-menu (1.3.4)
rm-digest
motion-yaml (1.2)
rake (10.3.2)
rm-digest (0.0.2)

Expand All @@ -15,7 +14,5 @@ PLATFORMS

DEPENDENCIES
bubble-wrap
bubble-wrap-http
everyday-menu (>= 1.3.4)
motion-yaml
rake
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
MemoryTamer
===========

As of version 0.7.2, Memory Tamer is now a paid app. Please visit <https://pay.paddle.com/checkout/492767> to get a license.
As of version 0.7.2, Memory Tamer is now a paid app. Please visit <https://pay.paddle.com/checkout/492767> to get a license. You can also buy in-app.

A RubyMotion application for keeping memory usage in check. Shows up in the menu bar and shows current free ram (refreshed every 2 seconds).

Expand All @@ -20,6 +20,7 @@ A RubyMotion application for keeping memory usage in check. Shows up in the men
* **v0.7:** add an option to disable updating the free memory display while freeing memory; also change some preference items to checkbox items
* **v0.7.1:** hopefully decrease the amount of memory leaking
* **v0.7.2:** change to a paid app
* **v0.7.3:** add registration submenu

###Versions (code-signed with developer ID):
* **v0.3:** <https://myepg-ds.s3.amazonaws.com/MemoryTamer-0.3> (Mavericks-only)
Expand Down
7 changes: 3 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Motion::Project
class Builder
def codesign(config, platform)
app_bundle = config.app_bundle_raw('MacOSX')
entitlements = File.join(config.versionized_build_dir(platform), "Entitlements.plist")
entitlements = File.join(config.versionized_build_dir(platform), 'Entitlements.plist')
if File.mtime(config.project_file) > File.mtime(app_bundle) or !system("/usr/bin/codesign --verify \"#{app_bundle}\" >& /dev/null")
App.info 'Codesign', app_bundle
File.open(entitlements, 'w') { |io| io.write(config.entitlements_data) }
Expand All @@ -27,8 +27,8 @@ Motion::Project::App.setup do |app|
app.icon = 'Icon.icns'
app.info_plist['CFBundleIconFile'] = 'Icon.icns'
app.name = 'MemoryTamer'
app.version = '0.7.2'
app.short_version = '0.7.2'
app.version = '0.7.3'
app.short_version = '0.7.3'
app.identifier = 'us.myepg.MemoryTamer'
app.info_plist['NSUIElement'] = 1
app.info_plist['SUFeedURL'] = 'https://raw.githubusercontent.com/henderea/MemoryTamer/master/appcast.xml'
Expand All @@ -37,5 +37,4 @@ Motion::Project::App.setup do |app|
app.embedded_frameworks << 'vendor/Growl.framework'
app.embedded_frameworks << 'vendor/Sparkle.framework'
app.embedded_frameworks << 'vendor/Paddle.framework'
# app.embedded_frameworks << 'WebKit.framework'
end
41 changes: 20 additions & 21 deletions app/app_delegate.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def applicationDidFinishLaunching(notification)
KPADTrialDuration => '7',
KPADTrialText => 'Thanks for downloading a trial of MemoryTamer! We hope you enjoy it.',
KPADProductImage => 'Icon.png'}, timeTrial: true, withWindow: nil)
NSNotificationCenter.defaultCenter.addObserver(self, selector: :set_license_display, name: KPADActivated, object: nil)
SUUpdater.sharedUpdater
@freeing = false
system('which memory_pressure')
Expand All @@ -33,6 +34,9 @@ def applicationDidFinishLaunching(notification)
MainMenu[:statusbar].subscribe(:status_update) { |_, sender|
SUUpdater.sharedUpdater.checkForUpdates(sender)
}
MainMenu[:license].subscribe(:license_change) { |_, _|
Paddle.sharedInstance.showLicencing
}
MainMenu[:prefs].subscribe(:preferences_refresh) { |_, _|
NSLog 'Reloading preferences'
load_prefs
Expand Down Expand Up @@ -112,6 +116,7 @@ def set_all_displays
set_escalate_display
set_show_display
set_update_display
set_license_display
end

def set_notification_display
Expand Down Expand Up @@ -146,30 +151,24 @@ def set_update_display
MainMenu[:prefs].items[:update_display][:state] = App::Persistence['update_while'] ? NSOnState : NSOffState
end

def set_license_display(note = nil)
Thread.start {
paddle = Paddle.sharedInstance
MainMenu[:license].items[:license_display][:title] = paddle.productActivated ? paddle.activatedEmail : 'Not Registered'
MainMenu[:license].items[:license_change][:title] = paddle.productActivated ? 'View Registration' : 'Buy / Register'
}
end

def load_prefs
pth = File.expand_path('~/mtprefs.yaml')
if App::Persistence['pressure'].nil?
App::Persistence['mem'] = 1024
App::Persistence['pressure'] = 'warn'
App::Persistence['growl'] = false
App::Persistence['method_pressure'] = true
begin
if File.exist?(pth)
fc = IO.read(pth).chomp
tmp = YAML::load(fc)
App::Persistence['mem'] = tmp[:mem] if tmp[:mem] && tmp[:mem].is_a?(Numeric)
App::Persistence['pressure'] = tmp[:pressure] if tmp[:pressure] && %w(normal warn critical).include?(tmp[:pressure])
App::Persistence['growl'] = tmp[:growl] && tmp[:growl] != 0
App::Persistence['method_pressure'] = tmp[:method_pressure] && tmp[:method_pressure] != 0
end
rescue
# ignored
end
end
App::Persistence['growl'] = App::Persistence['growl'] || !@has_nc
App::Persistence['method_pressure'] = App::Persistence['method_pressure'] && @mavericks
App::Persistence['mem'] = 1024 if App::Persistence['mem'].nil?
App::Persistence['pressure'] = 'warn' if App::Persistence['pressure'].nil?
App::Persistence['growl'] = false if App::Persistence['growl'].nil?
App::Persistence['method_pressure'] = true if App::Persistence['method_pressure'].nil?
App::Persistence['show_mem'] = true if App::Persistence['show_mem'].nil?
App::Persistence['update_while'] = true if App::Persistence['update_while'].nil?

App::Persistence['growl'] = App::Persistence['growl'] || !@has_nc
App::Persistence['method_pressure'] = App::Persistence['method_pressure'] && @mavericks
end

def dfm
Expand Down
10 changes: 10 additions & 0 deletions app/menu.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def self.def_items
menuItem :escalate_display, 'Auto-escalate', state: NSOffState
menuItem :show_display, 'Show free memory', state: NSOnState
menuItem :update_display, 'Update while freeing', state: NSOnState
menuItem :status_license, 'Registration', submenu: :license
menuItem :license_display, 'Not Registered'
menuItem :license_change, 'Buy / Register'
menuItem :status_update, 'Check for Updates'
menuItem :status_quit, 'Quit', preset: :quit
end
Expand All @@ -41,6 +44,8 @@ def self.def_menus
___
status_preferences
___
status_license
___
status_update
___
status_quit
Expand All @@ -67,6 +72,11 @@ def self.def_menus
___
update_display
}

menu(:license, 'Registration') {
license_display
license_change
}
end

def_menus
Expand Down
9 changes: 9 additions & 0 deletions appcast.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@
<link>https://raw.githubusercontent.com/henderea/MemoryTamer/master/appcast.xml</link>
<description>Most recent changes with links to updates.</description>
<language>en</language>
<item>
<title>Version 0.7.3</title>
<sparkle:releaseNotesLink>
http://releases.io/henderea/MemoryTamer/0.7.3?heading=true
</sparkle:releaseNotesLink>
<pubDate>Thu, 24 Jul 2014 16:00:00 -0400</pubDate>
<enclosure url="https://myepg-ds.s3.amazonaws.com/MemoryTamer-0.7.3/MemoryTamer-0.7.3.zip" sparkle:version="0.7.3" length="4776811" type="application/octet-stream" />
<sparkle:minimumSystemVersion>10.7</sparkle:minimumSystemVersion>
</item>
<item>
<title>Version 0.7.2</title>
<sparkle:releaseNotesLink>
Expand Down

0 comments on commit 4967da7

Please sign in to comment.