smc-get 0.2.0.beta1 → 0.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,58 +1,58 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
20
-
21
- module SmcGet
22
-
23
- module CUICommands
24
-
25
- class VersionCommand < Command
26
-
27
- def self.help
28
- <<EOF
29
- USAGE: #{File.basename($0)} version
30
-
31
- Shows the version of #{File.basename($0)} and the copyright statement.
32
- EOF
33
- end
34
-
35
- def self.summary
36
- "version\tShows smc-get's version and copyright."
37
- end
38
-
39
- def parse(args)
40
- raise(InvalidCommandline, "Too many arguments.") unless args.empty?
41
- end
42
-
43
- def execute(config)
44
- puts "This is #{File.basename($0)}, version #{SmcGet.version}."
45
- puts
46
- puts "#{File.basename($0)} Copyright (C) 2010-2011 Luiji Maryo"
47
- puts "#{File.basename($0)} Copyright (C) 2011 Marvin Gülker"
48
- puts "This program comes with ABSOLUTELY NO WARRANTY."
49
- puts "This is free software, and you are welcome to redistribute it"
50
- puts "under certain conditions; see the COPYING file for information."
51
- end
52
-
53
- end
54
-
55
- end
56
-
57
- end
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
+
21
+ module SmcGet
22
+
23
+ module CUICommands
24
+
25
+ class VersionCommand < Command
26
+
27
+ def self.help
28
+ <<EOF
29
+ USAGE: #{File.basename($0)} version
30
+
31
+ Shows the version of #{File.basename($0)} and the copyright statement.
32
+ EOF
33
+ end
34
+
35
+ def self.summary
36
+ "version\tShows smc-get's version and copyright."
37
+ end
38
+
39
+ def parse(args)
40
+ raise(InvalidCommandline, "Too many arguments.") unless args.empty?
41
+ end
42
+
43
+ def execute(config)
44
+ puts "This is #{File.basename($0)}, version #{SmcGet.version}."
45
+ puts
46
+ puts "#{File.basename($0)} Copyright (C) 2010-2011 Luiji Maryo"
47
+ puts "#{File.basename($0)} Copyright (C) 2011 Marvin Gülker"
48
+ puts "This program comes with ABSOLUTELY NO WARRANTY."
49
+ puts "This is free software, and you are welcome to redistribute it"
50
+ puts "under certain conditions; see the COPYING file for information."
51
+ end
52
+
53
+ end
54
+
55
+ end
56
+
57
+ end
58
58
  # vim:set ts=8 sts=2 sw=2 et: #
@@ -1,140 +1,166 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
20
-
21
- module SmcGet
22
-
23
- #This module contains all errors messages that are specific to smc-get.
24
- module Errors
25
-
26
- #Superclass for all errors in this library.
27
- class SmcGetError < StandardError
28
- end
29
-
30
- #Raises when you did not call SmcGet.setup.
31
- class LibraryNotInitialized < SmcGetError
32
-
33
- #Throws an exception of this class with an appropriate error
34
- #message if smc-get has not been initialized correctly.
35
- def self.throw_if_needed!
36
- if SmcGet.datadir.nil? or SmcGet.repo_url.nil?
37
- raise(self, "You have to setup smc-get first!")
38
- end
39
- end
40
-
41
- end
42
-
43
- # Raised when the class is initialized with a non-existant settings file.
44
- class CannotFindSettings < SmcGetError
45
- # The path to the settings file that was specified.
46
- attr_reader :settings_path
47
-
48
- # Create a new instance of the exception with the settings path.
49
- def initialize(settings_path)
50
- @settings_path = settings_path
51
- end
52
- end
53
-
54
- # Raised when a package call is made but the specified package cannot be
55
- # found.
56
- class NoSuchPackageError < SmcGetError
57
- # The name of the package that could not be found.
58
- attr_reader :package_name
59
-
60
- # Create a new instance of the exception with the specified package name.
61
- def initialize(name)
62
- @package_name = name
63
- end
64
- end
65
-
66
- # Raised when a package call is made but one of the resources of the
67
- # specified package is missing.
68
- class NoSuchResourceError < SmcGetError
69
- # The type of resource (should be either :music, :graphic, :level or :spec).
70
- attr_reader :resource_type
71
- # The name of the resource (i.e. mylevel.lvl or Stuff/Cheeseburger.png).
72
- attr_reader :resource_name
73
-
74
- # Create a new instance of the exception with the specified resource type
75
- # and name. Type should either be :music, :graphic, or :level.
76
- def initialize(type, name)
77
- @resource_type = type
78
- @resource_name = name
79
- end
80
-
81
- # Returns true if the resource type is :music. False otherwise.
82
- def is_music?
83
- @resource_type == :music
84
- end
85
-
86
- # Returns true if the resource type is :graphic. False otherwise.
87
- def is_graphic?
88
- @resource_type == :graphic
89
- end
90
-
91
- # Returns true if the resource type is :level. False otherwise.
92
- def is_level?
93
- @resource_type == :level
94
- end
95
-
96
- # Returns true if the resource type is :spec. False otherwise.
97
- def is_spec?
98
- @resource_type == :spec
99
- end
100
-
101
- end
102
-
103
- # Raised when a call to download() fails.
104
- class DownloadFailedError < SmcGetError
105
- # The URL that failed to download (including everything after /raw/master
106
- # only).
107
- attr_reader :download_url
108
-
109
- def initialize(url)
110
- @download_url = url
111
- end
112
- end
113
-
114
- #Raised when SmcGet.download timed out.
115
- class ConnectionTimedOutError < DownloadFailedError
116
- end
117
-
118
- #Raised if a package is damaged or malformed.
119
- class BrokenPackageError < SmcGetError
120
- end
121
-
122
- #Raised if a package specification file contains rubbish.
123
- class InvalidSpecification < BrokenPackageError
124
- end
125
-
126
- #Raised when a repository wasn’t found or contains structure errors.
127
- class InvalidRepository < SmcGetError
128
-
129
- #The URL of the repository.
130
- attr_reader :repository_uri
131
-
132
- def initialize(repository_uri)
133
- @repository_uri = repository_uri
134
- end
135
-
136
- end
137
-
138
- end
139
- end
140
- # vim:set ts=8 sts=2 sw=2 et: #
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
+
21
+ module SmcGet
22
+
23
+ #This module contains all errors messages that are specific to smc-get.
24
+ module Errors
25
+
26
+ #Superclass for all errors in this library.
27
+ class SmcGetError < StandardError
28
+ end
29
+
30
+ #Raises when you did not call SmcGet.setup.
31
+ class LibraryNotInitialized < SmcGetError
32
+
33
+ #Throws an exception of this class with an appropriate error
34
+ #message if smc-get has not been initialized correctly.
35
+ def self.throw_if_needed!
36
+ if SmcGet.datadir.nil? or SmcGet.repo_url.nil?
37
+ raise(self, "You have to setup smc-get first!")
38
+ end
39
+ end
40
+
41
+ end
42
+
43
+ # Raised when the class is initialized with a non-existant settings file.
44
+ class CannotFindSettings < SmcGetError
45
+ # The path to the settings file that was specified.
46
+ attr_reader :settings_path
47
+
48
+ # Create a new instance of the exception with the settings path.
49
+ def initialize(settings_path)
50
+ @settings_path = settings_path
51
+ end
52
+ end
53
+
54
+ # Raised when a package call is made but the specified package cannot be
55
+ # found.
56
+ class NoSuchPackageError < SmcGetError
57
+ # The name of the package that could not be found.
58
+ attr_reader :package_name
59
+
60
+ # Create a new instance of the exception with the specified package name.
61
+ def initialize(name)
62
+ @package_name = name
63
+ end
64
+ end
65
+
66
+ # Raised when a package call is made but one of the resources of the
67
+ # specified package is missing.
68
+ class NoSuchResourceError < SmcGetError
69
+ # The type of resource (should be either :music, :graphic, :level or :spec).
70
+ attr_reader :resource_type
71
+ # The name of the resource (i.e. mylevel.lvl or Stuff/Cheeseburger.png).
72
+ attr_reader :resource_name
73
+
74
+ # Create a new instance of the exception with the specified resource type
75
+ # and name. Type should either be :music, :graphic, or :level.
76
+ def initialize(type, name)
77
+ @resource_type = type
78
+ @resource_name = name
79
+ end
80
+
81
+ # Returns true if the resource type is :music. False otherwise.
82
+ def is_music?
83
+ @resource_type == :music
84
+ end
85
+
86
+ # Returns true if the resource type is :graphic. False otherwise.
87
+ def is_graphic?
88
+ @resource_type == :graphic
89
+ end
90
+
91
+ # Returns true if the resource type is :level. False otherwise.
92
+ def is_level?
93
+ @resource_type == :level
94
+ end
95
+
96
+ # Returns true if the resource type is :spec. False otherwise.
97
+ def is_spec?
98
+ @resource_type == :spec
99
+ end
100
+
101
+ end
102
+
103
+ # Raised when a call to download() fails.
104
+ class DownloadFailedError < SmcGetError
105
+ # The URL that failed to download (including everything after /raw/master
106
+ # only).
107
+ attr_reader :download_url
108
+
109
+ def initialize(url)
110
+ @download_url = url
111
+ end
112
+ end
113
+
114
+ #Raised when SmcGet.download timed out.
115
+ class ConnectionTimedOutError < DownloadFailedError
116
+ end
117
+
118
+ #Raised if a package is damaged or malformed.
119
+ class BrokenPackageError < SmcGetError
120
+ end
121
+
122
+ #Raised if a package specification file contains rubbish.
123
+ class InvalidSpecification < BrokenPackageError
124
+ end
125
+
126
+ #Raised when a repository wasn’t found or contains structure errors.
127
+ class InvalidRepository < SmcGetError
128
+
129
+ #The URI of the repository. For remote repositories the URL, for
130
+ #local repositories the local installation path.
131
+ attr_reader :repository_uri
132
+
133
+ #Creates a new instance of this class. Pass in the URL or path to
134
+ #the repository.
135
+ def initialize(repository_uri)
136
+ @repository_uri = repository_uri
137
+ end
138
+
139
+ end
140
+
141
+ #Raised if something goes wrong during compression
142
+ #or decompression of packages.
143
+ class CompressionError < SmcGetError
144
+
145
+ #The path to the file something was wrong with.
146
+ #A Pathname object.
147
+ attr_reader :path
148
+
149
+ #Creates a new exception of this type.
150
+ #==Parameters
151
+ #[message] The message to display.
152
+ #[path] The path to the errorneous file.
153
+ #==Return value
154
+ #An instance of this class.
155
+ #==Example
156
+ # raise(CompressionError.new("Boring file", "/dev/null"))
157
+ def initialize(message, path)
158
+ super(message)
159
+ @path = Pathname.new(path) rescue path
160
+ end
161
+
162
+ end
163
+
164
+ end
165
+ end
166
+ # vim:set ts=8 sts=2 sw=2 et: #
@@ -1,20 +1,20 @@
1
- #Encoding: UTF-8
2
- ################################################################################
3
- # This file is part of smc-get.
4
- # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
- # Copyright (C) 2011 Marvin Gülker
6
- #
7
- # This program is free software: you can redistribute it and/or modify
8
- # it under the terms of the GNU General Public License as published by
9
- # the Free Software Foundation, either version 3 of the License, or
10
- # (at your option) any later version.
11
- #
12
- # This program is distributed in the hope that it will be useful,
13
- # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- # GNU General Public License for more details.
16
- #
17
- # You should have received a copy of the GNU General Public License
18
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
- ################################################################################
1
+ #Encoding: UTF-8
2
+ ################################################################################
3
+ # This file is part of smc-get.
4
+ # Copyright (C) 2010-2011 Entertaining Software, Inc.
5
+ # Copyright (C) 2011 Marvin Gülker
6
+ #
7
+ # This program is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # This program is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
+ ################################################################################
20
20
  # vim:set ts=8 sts=2 sw=2 et: #