ruby_osx_app 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1c2f7c600d3aab60478a94143839955d3f996fa6
4
+ data.tar.gz: 9001feb8782dbbd8a28aee6f2df7ffc0833bb0dd
5
+ SHA512:
6
+ metadata.gz: 694edbc6bb393cb61fa732f3383112ed1381b3107068a080031e9c547a60dfabb548c2f63f278e8b57b57d7526b51b452eca6104fc7492dc3398634e97d962be
7
+ data.tar.gz: b2c2f95d4db0889f55ceb18b36c0daa0a28a6b52a238d994fc65cb9e6f83a6dcaaf23e31913c91a9eea7256fa95430644e904b14422ce095b57bd5f3642f83f2
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "rspec", "~> 2.8.0"
10
+ gem "rdoc", "~> 3.12"
11
+ gem "bundler", "~> 1.0"
12
+ gem "jeweler", "~> 1.8.7"
13
+ gem "simplecov", ">= 0"
14
+ end
15
+
16
+ group :development, :test do
17
+ gem 'rails_best_practices'
18
+ gem 'rubocop'
19
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Marcin Nowicki
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,58 @@
1
+ ruby_osx_app
2
+ ------------
3
+
4
+ This gem operates on Mac OSX Applications to retrieve information from them.
5
+
6
+ Example usage
7
+ -------------
8
+
9
+ Into Gemfile put:
10
+
11
+ ```ruby
12
+ gem 'ruby_osx_app'
13
+ ```
14
+
15
+ Get version from app:
16
+
17
+ ```ruby
18
+ require 'osx_app'
19
+ osx_app = OsxApp.new('/Applications/1Password.app')
20
+ osx_app.version # => 4.0.3
21
+ osx_app.version_major # => 4
22
+ ```
23
+
24
+ You can initialize simpler:
25
+
26
+ ```ruby
27
+ osx_app = OsxApp.new('1Password.app')
28
+ ```
29
+
30
+ Or even more simpler:
31
+
32
+ ```ruby
33
+ osx_app = OsxApp.new('1Password')
34
+ ```
35
+
36
+ You can also get info from custom path app:
37
+
38
+ ```ruby
39
+ osx_app = OsxApp.new('/Volumes/ExternalDisk/Applications/1Password.app')
40
+ ```
41
+
42
+ Contributing to ruby_osx_app
43
+ ----------------------------
44
+
45
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
46
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
47
+ * Fork the project.
48
+ * Start a feature/bugfix branch.
49
+ * Commit and push until you are happy with your contribution.
50
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
51
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
52
+
53
+ Copyright
54
+ ---------
55
+
56
+ Copyright (c) 2013 Marcin Nowicki. See LICENSE.txt for
57
+ further details.
58
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "ruby_osx_app"
18
+ gem.homepage = "http://github.com/pr0d1r2/ruby_osx_app"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{This gem operates on Mac OSX Applications to retrieve information from them.}
21
+ gem.description = %Q{This gem operates on Mac OSX Applications to retrieve information from them.}
22
+ gem.email = "pr0d1r2@gmail.com"
23
+ gem.authors = ["Marcin Nowicki"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "ruby_osx_app #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/lib/osx_app.rb ADDED
@@ -0,0 +1,38 @@
1
+ # this class describes OSX Application
2
+ class OsxApp
3
+ class CannotFind < StandardError; end
4
+ class Invalid < StandardError; end
5
+
6
+ attr_reader :name
7
+ attr_reader :path
8
+
9
+ def initialize(name_or_path)
10
+ if File.directory?(name_or_path)
11
+ @name = File.basename(name_or_path).gsub('.app', '')
12
+ @path = name_or_path
13
+ else
14
+ @name = name_or_path.gsub('.app', '')
15
+ @path = "/Applications/#{@name}.app"
16
+ fail CannotFind, @path unless File.directory?(@path)
17
+ end
18
+ validate!
19
+ end
20
+
21
+ def version
22
+ `defaults read #{info_plist} CFBundleShortVersionString`.strip
23
+ end
24
+
25
+ def version_major
26
+ version.split('.').first
27
+ end
28
+
29
+ private
30
+
31
+ def validate!
32
+ fail Invalid, "No #{info_plist}" unless File.exist?(info_plist)
33
+ end
34
+
35
+ def info_plist
36
+ "#{path}/Contents/Info.plist"
37
+ end
38
+ end
@@ -0,0 +1,72 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: ruby_osx_app 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "ruby_osx_app"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.authors = ["Marcin Nowicki"]
13
+ s.date = "2013-12-22"
14
+ s.description = "This gem operates on Mac OSX Applications to retrieve information from them."
15
+ s.email = "pr0d1r2@gmail.com"
16
+ s.extra_rdoc_files = [
17
+ "LICENSE.txt",
18
+ "README.md"
19
+ ]
20
+ s.files = [
21
+ ".document",
22
+ ".rspec",
23
+ ".ruby-version",
24
+ "Gemfile",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "lib/osx_app.rb",
30
+ "ruby_osx_app.gemspec",
31
+ "spec/osx_app_spec.rb",
32
+ "spec/rails_best_practices_spec.rb",
33
+ "spec/rubocop_spec.rb",
34
+ "spec/spec_helper.rb"
35
+ ]
36
+ s.homepage = "http://github.com/pr0d1r2/ruby_osx_app"
37
+ s.licenses = ["MIT"]
38
+ s.require_paths = ["lib"]
39
+ s.rubygems_version = "2.1.5"
40
+ s.summary = "This gem operates on Mac OSX Applications to retrieve information from them."
41
+
42
+ if s.respond_to? :specification_version then
43
+ s.specification_version = 4
44
+
45
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
47
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
48
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
49
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
50
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
51
+ s.add_development_dependency(%q<rails_best_practices>, [">= 0"])
52
+ s.add_development_dependency(%q<rubocop>, [">= 0"])
53
+ else
54
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
58
+ s.add_dependency(%q<simplecov>, [">= 0"])
59
+ s.add_dependency(%q<rails_best_practices>, [">= 0"])
60
+ s.add_dependency(%q<rubocop>, [">= 0"])
61
+ end
62
+ else
63
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
64
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
65
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
66
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
67
+ s.add_dependency(%q<simplecov>, [">= 0"])
68
+ s.add_dependency(%q<rails_best_practices>, [">= 0"])
69
+ s.add_dependency(%q<rubocop>, [">= 0"])
70
+ end
71
+ end
72
+
@@ -0,0 +1,82 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe OsxApp do
4
+
5
+ subject { OsxApp.new(parameter) }
6
+
7
+ context 'when using name of app' do
8
+ context 'and app exist by default' do
9
+ let(:parameter) { 'Automator' }
10
+
11
+ its(:name) { should == 'Automator' }
12
+
13
+ its(:path) { should == '/Applications/Automator.app' }
14
+
15
+ its(:version) { should == expected_automator_version }
16
+
17
+ its(:version_major) { should == expected_automator_version_major }
18
+ end
19
+
20
+ context 'with app suffix and app exist by default' do
21
+ let(:parameter) { 'Automator.app' }
22
+
23
+ its(:name) { should == 'Automator' }
24
+
25
+ its(:path) { should == '/Applications/Automator.app' }
26
+
27
+ its(:version) { should == expected_automator_version }
28
+
29
+ its(:version_major) { should == expected_automator_version_major }
30
+ end
31
+
32
+ context 'and app does not exist' do
33
+ let(:parameter) { 'Example' }
34
+
35
+ it { expect { subject }.to raise_error(OsxApp::CannotFind) }
36
+ end
37
+
38
+ context 'with app suffix and app does not exist' do
39
+ let(:parameter) { 'Example.app' }
40
+
41
+ it { expect { subject }.to raise_error(OsxApp::CannotFind) }
42
+ end
43
+ end
44
+
45
+ context 'when using path of app' do
46
+ context 'and app exist by default' do
47
+ let(:parameter) { '/Applications/Automator.app' }
48
+
49
+ its(:name) { should == 'Automator' }
50
+
51
+ its(:path) { should == '/Applications/Automator.app' }
52
+
53
+ its(:version) { should == expected_automator_version }
54
+
55
+ its(:version_major) { should == expected_automator_version_major }
56
+ end
57
+
58
+ context 'and app not exist' do
59
+ let(:parameter) { '/Applications/Example.app' }
60
+
61
+ it { expect { subject }.to raise_error(OsxApp::CannotFind) }
62
+ end
63
+
64
+ context 'and app does not contain Info.plist' do
65
+ let(:parameter) { "/tmp/Example#{Random.new_seed}.app" }
66
+ before { FileUtils.mkdir(parameter) }
67
+ after { FileUtils.rm_rf(parameter) }
68
+
69
+ it { expect { subject }.to raise_error(OsxApp::Invalid) }
70
+ end
71
+ end
72
+
73
+ def expected_automator_version
74
+ {
75
+ '10.8.5' => '2.3'
76
+ }[`sw_vers -productVersion`.strip]
77
+ end
78
+
79
+ def expected_automator_version_major
80
+ expected_automator_version.split('.').first
81
+ end
82
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'rails_best_practices' do
4
+
5
+ it 'should conform' do
6
+ system('rails_best_practices --spec').should be_true
7
+ end
8
+
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'rails_best_practices' do
4
+
5
+ it 'should conform' do
6
+ system('rubocop').should be_true
7
+ end
8
+
9
+ end
@@ -0,0 +1,16 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+ SimpleCov.minimum_coverage 100
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'rspec'
8
+ require 'osx_app'
9
+
10
+ # Requires supporting files with custom matchers and macros, etc,
11
+ # in ./support/ and its subdirectories.
12
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
13
+
14
+ RSpec.configure do |config|
15
+
16
+ end
metadata ADDED
@@ -0,0 +1,158 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_osx_app
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Marcin Nowicki
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-12-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 2.8.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 2.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rdoc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '3.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '3.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: jeweler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 1.8.7
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 1.8.7
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails_best_practices
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: This gem operates on Mac OSX Applications to retrieve information from
112
+ them.
113
+ email: pr0d1r2@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files:
117
+ - LICENSE.txt
118
+ - README.md
119
+ files:
120
+ - .document
121
+ - .rspec
122
+ - .ruby-version
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - VERSION
128
+ - lib/osx_app.rb
129
+ - ruby_osx_app.gemspec
130
+ - spec/osx_app_spec.rb
131
+ - spec/rails_best_practices_spec.rb
132
+ - spec/rubocop_spec.rb
133
+ - spec/spec_helper.rb
134
+ homepage: http://github.com/pr0d1r2/ruby_osx_app
135
+ licenses:
136
+ - MIT
137
+ metadata: {}
138
+ post_install_message:
139
+ rdoc_options: []
140
+ require_paths:
141
+ - lib
142
+ required_ruby_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ required_rubygems_version: !ruby/object:Gem::Requirement
148
+ requirements:
149
+ - - '>='
150
+ - !ruby/object:Gem::Version
151
+ version: '0'
152
+ requirements: []
153
+ rubyforge_project:
154
+ rubygems_version: 2.1.5
155
+ signing_key:
156
+ specification_version: 4
157
+ summary: This gem operates on Mac OSX Applications to retrieve information from them.
158
+ test_files: []