chrome_ssb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +77 -0
- data/Rakefile +1 -0
- data/chrome_ssb.gemspec +20 -0
- data/lib/chrome_ssb/version.rb +3 -0
- data/lib/chrome_ssb.rb +150 -0
- metadata +53 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d59a4e8b3fb67bf2be9896754bf832ec9559bc60
|
4
|
+
data.tar.gz: aae4f8ff7e3ec577aa9e720c57eb1f3e98460272
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d83f2594f36a14e549fbfd57d2e469ec9d4c5850a2bd2f4dbaa6de050ab2ba4d1fbb1bdbe0bba9271be1806e4040f36e6a6c6ed84d42c82b17ea991a729392aa
|
7
|
+
data.tar.gz: 89226770da4ec3cebf3fc5fb3e3404c38a0a7ba044d6126e4b83dd09843cd55c3c0a280e4d86a1f9083747f46a7855705c05190130129cc865bbf31083f8aa34
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Bradyn Poulsen
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# ChromeSSB
|
2
|
+
|
3
|
+
Mild ruby-based Cli app to generate Chrome Site-Specific Browsers on Mac OS X
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'chrome_ssb'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ gem install chrome_ssb
|
23
|
+
```
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Use via Ruby
|
28
|
+
```ruby
|
29
|
+
require 'chrome_ssb'
|
30
|
+
|
31
|
+
# ChromeSSB::new(opts={})
|
32
|
+
ssb = ChromeSSB.new
|
33
|
+
# ChromeSSB#<opts>
|
34
|
+
ssb.name = 'ChromeSSB Github'
|
35
|
+
ssb.location = 'http://www.github.com/bradynpoulsen/chrome_ssb/'
|
36
|
+
ssb.path = '~/Desktop'
|
37
|
+
ssb.overwrite = true
|
38
|
+
# Generate with options
|
39
|
+
ssb.create!
|
40
|
+
|
41
|
+
# OR EQUIVALENT
|
42
|
+
# ChromeSSB::create(opts={})
|
43
|
+
ChromeSSB.create name: 'ChromeSSB Github',
|
44
|
+
location: 'http://www.github.com/bradynpoulsen/chrome_ssb/',
|
45
|
+
path: '~/Desktop',
|
46
|
+
overwrite: true
|
47
|
+
```
|
48
|
+
|
49
|
+
Use via Command Line
|
50
|
+
|
51
|
+
```
|
52
|
+
chrome_ssb v0.1.0
|
53
|
+
http://www.github.com/bradynpoulsen/chrome_ssb/
|
54
|
+
|
55
|
+
Useage:
|
56
|
+
chrome_ssb [options...]
|
57
|
+
|
58
|
+
Options:
|
59
|
+
-c --chrome-path Path to Google Chrome Application
|
60
|
+
-d --directory alias: --path
|
61
|
+
-f --force alias: --overwrite
|
62
|
+
-h --help Show this helper message
|
63
|
+
-i --icon Path to icon
|
64
|
+
-l --location URL to open
|
65
|
+
-n --name Application Name
|
66
|
+
-o --overwrite Overwrite app if already exists
|
67
|
+
-p --path Directory to create Application in
|
68
|
+
--url alias: --location
|
69
|
+
```
|
70
|
+
|
71
|
+
## Contributing
|
72
|
+
|
73
|
+
1. Fork it (http://github.com/bradynpoulsen/chrome_ssb/fork)
|
74
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
75
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
76
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
77
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# require "bundler/gem_tasks"
|
data/chrome_ssb.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'chrome_ssb/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "chrome_ssb"
|
8
|
+
spec.version = ChromeSSB::VERSION
|
9
|
+
spec.authors = ["Bradyn Poulsen"]
|
10
|
+
spec.email = ["bradyn@bradynpoulsen.com"]
|
11
|
+
spec.summary = %q{Chrome SSBs for OS X}
|
12
|
+
spec.description = %q{Mild ruby-based Cli app to generate Chrome Site-Specific Browsers on Mac OS X}
|
13
|
+
spec.homepage = "http://www.github.com/bradynpoulsen/chrome_ssb/"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
end
|
data/lib/chrome_ssb.rb
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
require "chrome_ssb/version"
|
2
|
+
|
3
|
+
class ChromeSSB
|
4
|
+
@@compatible = !(/darwin/ =~ RUBY_PLATFORM).nil?
|
5
|
+
|
6
|
+
private
|
7
|
+
|
8
|
+
require 'fileutils'
|
9
|
+
require 'tempfile'
|
10
|
+
|
11
|
+
@@params = %i(name location icon path chrome_path overwrite)
|
12
|
+
|
13
|
+
public
|
14
|
+
|
15
|
+
attr_accessor *@@params
|
16
|
+
|
17
|
+
def initialize(args={})
|
18
|
+
## Require Mac OS X for SSB .app structure
|
19
|
+
raise '`chrome_ssb` is only compatible with Mac OS X' unless @@compatible
|
20
|
+
|
21
|
+
## Set Default Values
|
22
|
+
self.name = 'Untitled SSB'
|
23
|
+
self.location = 'http://www.google.com/'
|
24
|
+
self.icon = '.'
|
25
|
+
self.path = '.'
|
26
|
+
self.chrome_path = `mdfind "kMDItemCFBundleIdentifier == 'com.google.Chrome'" | head -n 1`.strip
|
27
|
+
self.overwrite = false
|
28
|
+
|
29
|
+
## Process passed args
|
30
|
+
args.each { |k,v| send("#{k}=",v) if @@params.include? k.to_sym }
|
31
|
+
end
|
32
|
+
|
33
|
+
def download_icon!
|
34
|
+
tmpfile = Tempfile.new('icon')
|
35
|
+
system %(curl -o "#{tmpfile.path}" "http://g.etfv.co/#{location}" >& /dev/null)
|
36
|
+
self.icon = tmpfile.path
|
37
|
+
end
|
38
|
+
|
39
|
+
def create!
|
40
|
+
app_path = File.join(path, name+'.app')
|
41
|
+
contents_path = File.join(app_path, 'Contents')
|
42
|
+
chrome_link = File.join(contents_path, 'MacOS', 'Chrome')
|
43
|
+
exec_path = File.join(contents_path, 'MacOS', name)
|
44
|
+
icon_path = File.join(contents_path, 'Resources', 'icon.icns')
|
45
|
+
locale_path = File.join(contents_path, 'Resources', 'en.lproj', 'InfoPlist.strings')
|
46
|
+
plist_path = File.join(contents_path, 'Info.plist')
|
47
|
+
versions_path = File.join(contents_path, 'Versions')
|
48
|
+
|
49
|
+
chrome_executable = File.join(chrome_path, 'Contents', 'MacOS', 'Google Chrome')
|
50
|
+
chrome_versions = File.join(chrome_path, 'Contents', 'Versions')
|
51
|
+
|
52
|
+
## Check that Google Chrome exists
|
53
|
+
raise ArgumentError, "Google Chrome was not found at #{chrome_path}. Try again passing its path" unless File.file? chrome_executable
|
54
|
+
|
55
|
+
## Check if app exists
|
56
|
+
if File.directory? app_path
|
57
|
+
if overwrite?
|
58
|
+
FileUtils.rm_rf app_path
|
59
|
+
else
|
60
|
+
raise ArgumentError, "App name is already taken"
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
## Create Initial Directories
|
65
|
+
[File.dirname(locale_path), File.dirname(exec_path), File.join(contents_path,'Profile')].each do |dir|
|
66
|
+
FileUtils.mkdir_p dir
|
67
|
+
end
|
68
|
+
|
69
|
+
## Icon
|
70
|
+
download_icon! unless File.file? icon
|
71
|
+
if File.file? icon
|
72
|
+
if (File.extname icon || '') == '.icns'
|
73
|
+
FileUtils.cp icon, icon_path
|
74
|
+
else
|
75
|
+
system %(sips -s format tiff "#{icon}" --out "#{icon_path}.tiff" --resampleWidth 128 >& /dev/null)
|
76
|
+
system %(tiff2icns -noLarge "#{icon_path}.tiff" >& /dev/null)
|
77
|
+
end
|
78
|
+
else
|
79
|
+
raise ArgumentError, "Icon could not be found or downloaded for #{location}"
|
80
|
+
end
|
81
|
+
|
82
|
+
## Chrome Symlink
|
83
|
+
FileUtils.ln_s chrome_executable, chrome_link
|
84
|
+
|
85
|
+
## Chrome Versions
|
86
|
+
FileUtils.ln_s chrome_versions, versions_path
|
87
|
+
|
88
|
+
## Chrome Wrapper
|
89
|
+
IO.write exec_path, <<-WRAPPER.gsub(/^\s+/m, '')
|
90
|
+
#!/bin/bash
|
91
|
+
ABSPATH=\$(cd "\$(dirname "\$0")"; pwd)
|
92
|
+
/bin/cp "\$ABSPATH/Chrome" "\$ABSPATH/#{name} Chrome"
|
93
|
+
exec "\$ABSPATH/#{name} Chrome" --app="#{location}" --user-data-dir="\$ABSPATH/../Profile" "\$@"
|
94
|
+
WRAPPER
|
95
|
+
system %(/bin/chmod +x "#{exec_path}" >& /dev/null)
|
96
|
+
|
97
|
+
## Info.plist
|
98
|
+
IO.write plist_path, <<-PLIST.gsub(/^\s+/m, '')
|
99
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
100
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
101
|
+
<plist version="1.0">
|
102
|
+
<dict>
|
103
|
+
<key>CFBundleExecutable</key>
|
104
|
+
<string>#{name}</string>
|
105
|
+
<key>CFBundleName</key>
|
106
|
+
<string>#{name}</string>
|
107
|
+
<key>CFBundleIconFile</key>
|
108
|
+
<string>icon.icns</string>
|
109
|
+
<key>NSHighResolutionCapable</key>
|
110
|
+
<string>True</string>
|
111
|
+
</dict>
|
112
|
+
</plist>
|
113
|
+
PLIST
|
114
|
+
|
115
|
+
## Localization
|
116
|
+
IO.write locale_path, <<-LOCALE.gsub(/^\s+/m, '')
|
117
|
+
CFBundleDisplayName = "#{name}";
|
118
|
+
CFBundleName = "#{name}";
|
119
|
+
LOCALE
|
120
|
+
|
121
|
+
end
|
122
|
+
|
123
|
+
## Name Filtered Setter
|
124
|
+
def name=(name)
|
125
|
+
@name = name.gsub /[^\w\-\.\s]/, ''
|
126
|
+
end
|
127
|
+
|
128
|
+
## Path Expansion Setters
|
129
|
+
%i(icon path chrome_path).each do |cb|
|
130
|
+
class_eval <<-RUBY_EVAL, __FILE__, __LINE__+1
|
131
|
+
def #{cb}=(#{cb})
|
132
|
+
@#{cb} = File.expand_path #{cb}
|
133
|
+
end
|
134
|
+
RUBY_EVAL
|
135
|
+
end
|
136
|
+
|
137
|
+
def overwrite?
|
138
|
+
!!overwrite
|
139
|
+
end
|
140
|
+
|
141
|
+
## Static Create Shortcut
|
142
|
+
def self.create(args={})
|
143
|
+
ChromeSSB.new(args).create!
|
144
|
+
end
|
145
|
+
|
146
|
+
## System Compatible
|
147
|
+
def self.compatible?
|
148
|
+
!!@@compatible
|
149
|
+
end
|
150
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: chrome_ssb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bradyn Poulsen
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Mild ruby-based Cli app to generate Chrome Site-Specific Browsers on
|
14
|
+
Mac OS X
|
15
|
+
email:
|
16
|
+
- bradyn@bradynpoulsen.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- chrome_ssb.gemspec
|
27
|
+
- lib/chrome_ssb.rb
|
28
|
+
- lib/chrome_ssb/version.rb
|
29
|
+
homepage: http://www.github.com/bradynpoulsen/chrome_ssb/
|
30
|
+
licenses:
|
31
|
+
- MIT
|
32
|
+
metadata: {}
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '0'
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project:
|
49
|
+
rubygems_version: 2.2.2
|
50
|
+
signing_key:
|
51
|
+
specification_version: 4
|
52
|
+
summary: Chrome SSBs for OS X
|
53
|
+
test_files: []
|