arpm 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0f5a1c1cfb42651abccccd469487764ace2b7feb
4
+ data.tar.gz: 801769a8aa288b45690c5d3863272aa9828f052f
5
+ SHA512:
6
+ metadata.gz: 375a6b4dcc7195801db1349317daa030bfb51b9ae67c1967a2f13385b8826ac04ff6ef4a46b0fa17f5b533f5a3f0c1b5d2d34a8248cc27e41f3d23027cc5ce97
7
+ data.tar.gz: 81ec2b26e71330ef34683851231f48b09d18702819daad6eb167d529cfa3961aa1612e4b693eb9e320fd115c652c5da3be751719fd230a48eef22ef82275e312
@@ -0,0 +1,23 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ Libfile
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in arpm.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Alex Forey
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.
@@ -0,0 +1,92 @@
1
+ # arpm
2
+
3
+ arpm is the Arduino Package Manager, a simple way to keep track of all the libraries used in an Arduino project.
4
+
5
+ ## Installation
6
+
7
+ Install it via RubyGems:
8
+
9
+ $ gem install arpm
10
+
11
+ ## Usage
12
+
13
+ There are two ways of installing libraries, much like with other package managers such as RubyGems. You can either install them by hand, and use arpm as an easy way of quickly installing libraries, or you can use the Libfile to keep track of which libraries a project requires and allows anyone else to install all of them by running a single command, `arpm bundle`.
14
+
15
+ ### Bundle
16
+
17
+ Projects should have a Libfile in their root (the folder with the `.ino` sketch file in it), which looks something like:
18
+
19
+ ```
20
+ lib "bergcloud", "1.0"
21
+ lib "time", "3.2"
22
+ ```
23
+
24
+ Then, open a console in that directory and type:
25
+
26
+ $ arpm bundle
27
+
28
+ This will read the list of dependencies and install them into your Arduino's library directory (`~/Documents/Arduino/libraries` on OS X and `~\My Documents\Arduino\libaries` on Windows).
29
+
30
+ ### Manual Installing
31
+
32
+ Manually installing libraries is as simple as running a command. For the most recent version of a library, run:
33
+
34
+ $ arpm install package_name
35
+
36
+ To specify a version, you can do this, for instance:
37
+
38
+ $ arpm install package_name 1.0
39
+
40
+ ## Registering a Library
41
+
42
+ So you've made a library and you want to get it on arpm? There are only 3 things you need to do:
43
+
44
+ 1. Put the source code for the library on GitHub (or some other Git host, like BitBucket)
45
+ 2. Create a release of your code with the tag of a version number (e.g. `1.0`)
46
+ 3. Add your library to `packages.json`
47
+
48
+ ### Putting Source Online
49
+
50
+ Push your source code to your favourite Git hosting site, and obtain an URL that looks like:
51
+
52
+ > https://github.com/bergcloud/devshield-arduino.git
53
+
54
+ ### Create a Release
55
+
56
+ This is as simple as going to the releases tab of the site you use. For GitHub, it's:
57
+
58
+ > https://github.com/username/your-repository/releases
59
+
60
+ Then hit the 'Create a New Release' button, and put the version number in the `tag` box. Make sure your version number starts with a number, and is separated by dots. Version numbers cannot contain `-` however because the Arduino IDE doesn't like them.
61
+
62
+ For instance, `1.0`, `0.9.2` and `2.0.beta` are all valid version names.
63
+
64
+ ### Adding to `packages.json`
65
+
66
+ First, fork this repository. Then edit the `packages.json` file, adding a section like this:
67
+
68
+ ```
69
+ {
70
+ "name": "bergcloud",
71
+ "repository": "https://github.com/bergcloud/devshield-arduino.git",
72
+ "authors": ["Nick Ludlam", "Andy Huntington"],
73
+ "email": "info@bergcloud.com"
74
+ }
75
+ ```
76
+ Note: the `name` cannot contain dashes (`-`) either because Arduino doesn't like them. It can only contain letters, numbers, and underscores.
77
+
78
+ Add the git URL you got earlier to the `repository` section.
79
+
80
+ Make sure that there's a comma on the end of the previous repository (`},`) and one on the end of yours if there are packages after it.
81
+
82
+ Then make a pull request, and if everything's fine, I'll merge it as soon as I can, and your package will go live.
83
+
84
+ ## Contributing to Source
85
+
86
+ To contribute to the source of arpm:
87
+
88
+ 1. Fork it (https://github.com/alfo/arpm/fork)
89
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
90
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
91
+ 4. Push to the branch (`git push origin my-new-feature`)
92
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'arpm/version'
5
+ require 'arpm/string'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "arpm"
9
+ spec.version = ARPM::VERSION
10
+ spec.authors = ["Alex Forey"]
11
+ spec.email = ["me@alexforey.com"]
12
+ spec.summary = %q{The Arduino Package Manager}
13
+ spec.description = %q{Keep your libraries in shape}
14
+ spec.homepage = "http://arpm.github.io"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = ["arpm"]
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+
25
+ spec.add_runtime_dependency "thor", "~> 0.19"
26
+
27
+ end
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'thor'
4
+ require 'arpm'
5
+
6
+ ARPM::CLI.start(ARGV)
@@ -0,0 +1,14 @@
1
+ require "json"
2
+ require "open-uri"
3
+
4
+ require "arpm/vendor/ruby-git/git"
5
+
6
+ require "arpm/config"
7
+ require "arpm/version"
8
+ require "arpm/string"
9
+ require "arpm/os"
10
+
11
+ require "arpm/libfile"
12
+ require "arpm/list"
13
+ require "arpm/package"
14
+ require "arpm/cli"
@@ -0,0 +1,250 @@
1
+ require "fileutils"
2
+
3
+ module ARPM
4
+ class CLI < Thor
5
+
6
+ desc "install [PACKAGE] ([VERSION])", "Install a package"
7
+ def install(name, version = nil)
8
+
9
+ # Install all the things
10
+ puts "Searching for packages...".cyan
11
+
12
+ package = ARPM::Package.search(name)
13
+
14
+ if package
15
+
16
+ # Check to see if there actually any releases yet
17
+ puts "No releases of #{name} yet".red and return unless package.latest_version
18
+
19
+ # Check that the requested version exists
20
+ if version and !package.versions.include?(version)
21
+ puts "Version #{version} of #{name} doesn't exist".red
22
+ return false
23
+ end
24
+
25
+ # Get the install path
26
+ path = package.install_path(version)
27
+
28
+ puts "Cloning #{name} into #{path}"
29
+
30
+ # Delete the path if it already exists
31
+ FileUtils.rm_r(path) if File.exists?(path)
32
+
33
+ # Was the version specified?
34
+ version = package.latest_version unless version
35
+
36
+ package.install(version)
37
+
38
+ puts "Installed #{name} version #{version}".green.bold
39
+
40
+ else
41
+
42
+ puts "No package named #{name} found".red
43
+ return false
44
+
45
+ end
46
+
47
+ end
48
+
49
+ desc "uninstall [PACKAGE] ([VERSION])", "Uninstall a package"
50
+ def uninstall(name, version = nil)
51
+
52
+ if ARPM::List.includes?(name)
53
+
54
+ package = ARPM::Package.new(:name => name, :versions => ARPM::List.versions(name))
55
+
56
+ versions = package.installed_versions
57
+
58
+ # Was a version specified?
59
+ if version
60
+
61
+ # Yes it was, is it installed?
62
+ if versions.include?(version)
63
+
64
+ # Yes it is! Unintstall it
65
+ package.uninstall(version)
66
+
67
+ puts "#{package.name} version #{version} uninstalled".green.bold
68
+
69
+
70
+ else
71
+
72
+ # Nope, it's not installed
73
+ puts "Version #{version} of #{name} is not installed".red and return
74
+ end
75
+
76
+ else
77
+
78
+ if package.installed_versions.size > 1
79
+
80
+ # They've got multiple installed but haven't said which one
81
+ puts "Please specify a version to uninstall from this list:".red
82
+
83
+ package.installed_versions.each do |v|
84
+ puts " #{v}"
85
+ end
86
+
87
+ else
88
+
89
+ version = installed_versions.first
90
+
91
+ # There's only one installed version
92
+ package.uninstall(version)
93
+
94
+ puts "#{package.name} version #{version} uninstalled".green.bold
95
+
96
+ end
97
+
98
+ end
99
+
100
+ else
101
+
102
+ puts "#{name} is not installed".red and return
103
+
104
+ end
105
+
106
+ end
107
+
108
+ desc "update PACKAGE", "Update a package"
109
+ def update(name)
110
+
111
+ # Check to see if it is installed?
112
+ if ARPM::List.includes?(name)
113
+
114
+ # Get the current info
115
+ package = ARPM::Package.search(name)
116
+
117
+ # Does it exist?
118
+ if package
119
+
120
+ # Do we have more than one installed version?
121
+ if package.installed_versions.size > 1
122
+
123
+ # Yes, ask the user to deal with it
124
+ puts "#{name} has more than one version installed:".red
125
+ package.installed_versions.each do |v|
126
+ puts " #{v}"
127
+ end
128
+ puts "Please run" + "arpm install #{name}".bold + "to install the latest one"
129
+
130
+ else
131
+
132
+ # No, just one installed version
133
+
134
+ current_version = package.installed_versions.first
135
+
136
+ # Does this package even need updating?
137
+ if current_version == package.latest_version
138
+
139
+ # Nope
140
+ puts "#{name} is already at the most recent version (#{package.latest_version})".red
141
+
142
+ else
143
+
144
+ # Yes, so let's actually fucking do it
145
+
146
+ package.uninstall(current_version)
147
+ package.install(package.latest_version)
148
+
149
+ puts "#{name} updated to version #{package.latest_version}".green.bold
150
+
151
+ end
152
+
153
+ end
154
+
155
+ else
156
+
157
+ puts "#{name} no longer exists".red and return
158
+
159
+ end
160
+
161
+ else
162
+ puts "#{name} is not installed yet".red and return
163
+ end
164
+ end
165
+
166
+ desc "list", "List the installed packages"
167
+ def list
168
+
169
+ # Get a list of all the packages
170
+ packages = ARPM::List.all
171
+
172
+ puts "\nLocal Packages: \n".bold
173
+
174
+ # Loop over them
175
+ packages.each do |p|
176
+
177
+ name = p.keys.first
178
+ versions = p[name]
179
+
180
+ # Print them out
181
+ puts "#{name} (#{versions.join(', ')})".cyan
182
+
183
+ end
184
+
185
+ puts "\n"
186
+
187
+ end
188
+
189
+ desc "search [PACKAGE]", "Search for packages with names containing [PACKAGE]"
190
+ def search(name)
191
+
192
+ # Search for the package
193
+ packages = ARPM::Package.search(name, false)
194
+
195
+ if packages
196
+
197
+ # Loop over any results
198
+ packages.each do |package|
199
+ puts "#{package.name}-#{package.latest_version}"
200
+ end
201
+
202
+ else
203
+ puts "No results".red
204
+ end
205
+ end
206
+
207
+ desc "bundle", "Install all a project's dependencies"
208
+ def bundle
209
+
210
+ # Find the Libfile
211
+ lib_file = ARPM::Libfile.location
212
+
213
+ if File.exists?(lib_file)
214
+
215
+ # It exists, so get its contents and make an object
216
+ lib_file = ARPM::Libfile.new(File.open(lib_file).read)
217
+
218
+ # Loop over the dependencies
219
+ lib_file.dependencies.each do |dependency|
220
+
221
+ name = dependency.keys[0]
222
+ version = dependency[dependency.keys[0]]
223
+
224
+ # Make sure the package exists
225
+ package = ARPM::Package.search(name)
226
+
227
+ if package
228
+
229
+ # Is it already installed?
230
+ if ARPM::List.includes?(name, version)
231
+ puts "Using #{name}-#{version}"
232
+ else
233
+
234
+ # No, so install it
235
+ package.install(version)
236
+ end
237
+ else
238
+
239
+ # The package doesn't exist
240
+ puts "Could not find #{name}".red
241
+ end
242
+
243
+ end
244
+
245
+ end
246
+
247
+ end
248
+
249
+ end
250
+ end