atk_toolbox 0.0.126 → 0.0.127

Sign up to get free protection for your applications and to get access to all the features.
data/lib/atk/online.rb DELETED
@@ -1,8 +0,0 @@
1
- def online?
2
- require 'open-uri'
3
- begin
4
- true if open("http://www.google.com/")
5
- rescue
6
- false
7
- end
8
- end
@@ -1,111 +0,0 @@
1
- class PackageManager
2
- def self.installed?(app_name, version=nil)
3
- puts 'This has not been implemented yet'
4
- end
5
-
6
- def self.install(app_name, version=nil)
7
- puts 'This has not been implemented yet'
8
- end
9
-
10
- def self.uninstall(app_name, version=nil)
11
- puts 'This has not been implemented yet'
12
- end
13
-
14
- def self.update_app(app_name)
15
- puts 'This has not been implemented yet'
16
- end
17
- end
18
-
19
- class Scoop < PackageManager
20
-
21
- @@scoop_dir = ENV['SCOOP'] or '#{Dir.home}/scoop'
22
- @@scoop_global_dir = ENV['SCOOP_GLOBAL'] or '#{ENV["ProgramData"]}/scoop'
23
-
24
- def self.base_dir(global=false)
25
- return global ? @@scoop_global_dir : @@scoop_dir
26
- end
27
-
28
- def self.apps_dir(global=false)
29
- root = base_dir(global)
30
- return '#{root}/apps'
31
- end
32
-
33
- def self.app_dir(app_name, global=false)
34
- root = apps_dir(global)
35
- return '#{root}/#{app_name}'
36
- end
37
-
38
- def self.add_bucket(bucket_name, bucket_location=nil)
39
- if (bucket_location == nil)
40
- `scoop bucket add #{bucket_name}`
41
- else
42
- `scoop bucket add #{bucket_name} #{bucket_location}`
43
- end
44
- end
45
-
46
- def self.switch_app_version(app_name, version=nil)
47
- if(version == nil)
48
- `scoop reset #{app_name}`
49
- else
50
- `scoop reset #{app_name}@#{version}`
51
- end
52
- end
53
-
54
- # Overriden Methods
55
-
56
- def self.installed?(app_name, version=nil)
57
- # if(global == nil) { return (installed?(app_name, true) or installed? (app_name, false)) }
58
- # Dependencies of the format "bucket/dependency" install in a directory of form
59
- # "dependency". So we need to extract the bucket from the name and only give the app
60
- # name to is_directory
61
- # TODO: add support for checking if version is installed
62
- app_name = app_name.split("/")[-1]
63
- return File.directory?(File.expand_path(app_dir(app_name)))
64
- end
65
-
66
- def self.install(app_name, version=nil)
67
- if(installed?(app_name))
68
- puts 'You already have #{app_name} installed'
69
- return
70
- end
71
-
72
- if(version == nil)
73
- `scoop install #{app_name}`
74
- else
75
- `scoop install #{app_name}@#{version}`
76
- end
77
- end
78
-
79
- def self.uninstall(app_name, version=nil)
80
- if(app_name == 'scoop')
81
- puts 'You are trying to uninstall scoop which is a dependency for ATK. We will not let you uninstall Scoop through ATK'
82
- return
83
- end
84
-
85
- if(version == nil)
86
- `scoop uninstall #{app_name}`
87
- else
88
- `scoop uninstall #{app_name}@#{version}`
89
- end
90
- end
91
-
92
- def self.update_app(app_name)
93
- `scoop update #{app_name}`
94
- end
95
- end
96
-
97
- class Homebrew < PackageManager
98
-
99
- end
100
-
101
- class Apt < PackageManager
102
-
103
- end
104
-
105
- class Pacman < PackageManager
106
-
107
- end
108
-
109
- class Yum < PackageManager
110
-
111
- end
data/lib/atk/zip.rb DELETED
@@ -1,54 +0,0 @@
1
- require 'zip'
2
-
3
- class ZipFileGenerator
4
- # Initialize with the directory to zip and the location of the output archive.
5
- def initialize(input_dir, output_file)
6
- @input_dir = input_dir
7
- @output_file = output_file
8
- end
9
-
10
- # Zip the input directory.
11
- def write
12
- entries = Dir.entries(@input_dir) - %w[. ..]
13
-
14
- Zip::ZipFile.open(@output_file, Zip::ZipFile::CREATE) do |zipfile|
15
- write_entries entries, '', zipfile
16
- end
17
- end
18
-
19
- private
20
-
21
- # A helper method to make the recursion work.
22
- def write_entries(entries, path, zipfile)
23
- entries.each do |e|
24
- zipfile_path = path == '' ? e : File.join(path, e)
25
- disk_file_path = File.join(@input_dir, zipfile_path)
26
-
27
- if File.directory? disk_file_path
28
- recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
29
- else
30
- put_into_archive(disk_file_path, zipfile, zipfile_path)
31
- end
32
- end
33
- end
34
-
35
- def recursively_deflate_directory(disk_file_path, zipfile, zipfile_path)
36
- zipfile.mkdir zipfile_path
37
- subdir = Dir.entries(disk_file_path) - %w[. ..]
38
- write_entries subdir, zipfile_path, zipfile
39
- end
40
-
41
- def put_into_archive(disk_file_path, zipfile, zipfile_path)
42
- zipfile.add(zipfile_path, disk_file_path)
43
- end
44
- end
45
-
46
-
47
- def zip(source, destination=nil)
48
- if destination == nil
49
- destination = source + ".zip"
50
- end
51
-
52
- zip_helper = ZipFileGenerator.new(source, destination)
53
- zip_helper.write()
54
- end