mpm 0.1.1

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: 3660542003def25af8d4ee3d2c8a8f10ba44d09a
4
+ data.tar.gz: 811ae64a7e9f1cfaca323a331ae13d42c1010ea6
5
+ SHA512:
6
+ metadata.gz: 46a16b4748b49f3aefa6483578c983ce787dc6710434141308b81c3bd203ce79d4db0cb301f5feec814a7a18defe338e4ab8c7fe0cef883a71f9b32198e51c13
7
+ data.tar.gz: 547c112ab8098a65adaf43758d7840b76d488dfd9778d09868fcf04b0de55bb1afcae3cdd0db04385938ae7ac03a02c442cbfd2bbb8e8e3d19788b6863438e04
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ #gem "recursive-open-struct"
6
+ #gem "pidfile"
7
+ #gem "os"
8
+ gem "activesupport", "~> 4.2"
9
+ gem "thor", "~> 0.19"
10
+ gem "awesome_print", "~> 1.6"
11
+ gem "os", "~> 0.9"
12
+ gem "os-name", "~> 0.0"
13
+ gem "recursive-open-struct", "~> 0"
14
+ gem "colorize", "~> 0"
15
+
16
+ # Add dependencies to develop your gem here.
17
+ # Include everything needed to run rake, tests, features, etc.
18
+ group :development do
19
+ gem "shoulda", "~> 3.5"
20
+ gem "rdoc", "~> 3.12"
21
+ gem "bundler", "= 1.12.0"
22
+ gem "jeweler", "~> 2.0"
23
+ gem "simplecov", "~> 0"
24
+ gem "pry", "~> 0"
25
+ end
@@ -0,0 +1,106 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.7.1)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.4.0)
11
+ awesome_print (1.7.0)
12
+ builder (3.2.2)
13
+ coderay (1.1.1)
14
+ colorize (0.8.1)
15
+ descendants_tracker (0.0.4)
16
+ thread_safe (~> 0.3, >= 0.3.1)
17
+ docile (1.1.5)
18
+ faraday (0.9.2)
19
+ multipart-post (>= 1.2, < 3)
20
+ git (1.3.0)
21
+ github_api (0.14.5)
22
+ addressable (~> 2.4.0)
23
+ descendants_tracker (~> 0.0.4)
24
+ faraday (~> 0.8, < 0.10)
25
+ hashie (>= 3.4)
26
+ oauth2 (~> 1.0)
27
+ hashie (3.4.6)
28
+ highline (1.7.8)
29
+ i18n (0.7.0)
30
+ jeweler (2.1.1)
31
+ builder
32
+ bundler (>= 1.0)
33
+ git (>= 1.2.5)
34
+ github_api
35
+ highline (>= 1.6.15)
36
+ nokogiri (>= 1.5.10)
37
+ rake
38
+ rdoc
39
+ semver
40
+ json (1.8.3)
41
+ jwt (1.5.6)
42
+ method_source (0.8.2)
43
+ mini_portile2 (2.1.0)
44
+ minitest (5.9.0)
45
+ multi_json (1.12.1)
46
+ multi_xml (0.5.5)
47
+ multipart-post (2.0.0)
48
+ nokogiri (1.6.8)
49
+ mini_portile2 (~> 2.1.0)
50
+ pkg-config (~> 1.1.7)
51
+ oauth2 (1.2.0)
52
+ faraday (>= 0.8, < 0.10)
53
+ jwt (~> 1.0)
54
+ multi_json (~> 1.3)
55
+ multi_xml (~> 0.5)
56
+ rack (>= 1.2, < 3)
57
+ os (0.9.6)
58
+ os-name (0.0.4)
59
+ pkg-config (1.1.7)
60
+ pry (0.10.4)
61
+ coderay (~> 1.1.0)
62
+ method_source (~> 0.8.1)
63
+ slop (~> 3.4)
64
+ rack (2.0.1)
65
+ rake (11.2.2)
66
+ rdoc (3.12.2)
67
+ json (~> 1.4)
68
+ recursive-open-struct (0.6.5)
69
+ semver (1.0.1)
70
+ shoulda (3.5.0)
71
+ shoulda-context (~> 1.0, >= 1.0.1)
72
+ shoulda-matchers (>= 1.4.1, < 3.0)
73
+ shoulda-context (1.2.1)
74
+ shoulda-matchers (2.8.0)
75
+ activesupport (>= 3.0.0)
76
+ simplecov (0.12.0)
77
+ docile (~> 1.1.0)
78
+ json (>= 1.8, < 3)
79
+ simplecov-html (~> 0.10.0)
80
+ simplecov-html (0.10.0)
81
+ slop (3.6.0)
82
+ thor (0.19.1)
83
+ thread_safe (0.3.5)
84
+ tzinfo (1.2.2)
85
+ thread_safe (~> 0.1)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ activesupport (~> 4.2)
92
+ awesome_print (~> 1.6)
93
+ bundler (= 1.12.0)
94
+ colorize (~> 0)
95
+ jeweler (~> 2.0)
96
+ os (~> 0.9)
97
+ os-name (~> 0.0)
98
+ pry (~> 0)
99
+ rdoc (~> 3.12)
100
+ recursive-open-struct (~> 0)
101
+ shoulda (~> 3.5)
102
+ simplecov (~> 0)
103
+ thor (~> 0.19)
104
+
105
+ BUNDLED WITH
106
+ 1.13.1
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Erik Nomitch
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.
@@ -0,0 +1,65 @@
1
+ # mpm (Meta Package Manager)
2
+
3
+ *A CLI wrapper to unify interaction with multiple package managers across various OSs/distributions.*
4
+
5
+ The concept of `mpm` is to create a (meta) package manager syntax/wrapper for the numerous package managers that exist to simplify administration of them.
6
+
7
+ <!---
8
+ **_Disclaimer_: This is in early development and is experimental.**
9
+ -->
10
+
11
+ ## Usage
12
+
13
+ ```Shell
14
+
15
+ # Searching (Searches Available Packages)
16
+ $ mpm search <query>
17
+
18
+ # For example:
19
+ # * If you were on Debian, this would execute: apt-cache search <query>
20
+ # * If you were on OS X, this would execute: brew search <query>
21
+
22
+ # Installing (base package manager)
23
+ $ mpm install <package name(s)...>
24
+
25
+ # Installing (exterior/additional package managers)
26
+ $ mpm /cask install PACKAGE [PACKAGE...]
27
+ $ mpm /gem install GEM [GEM...]
28
+ $ mpm /npm install PACKAGE [PACKAGE...]
29
+
30
+ # Uninstalling
31
+ $ mpm uninstall <package name(s)...>
32
+
33
+ # Listing (Lists Installed Packages)
34
+ $ mpm list
35
+
36
+ # Updating (Updates the Package Index)
37
+ $ mpm update
38
+
39
+ ```
40
+
41
+ ## Supported Package Managers
42
+
43
+ ### Linux
44
+ * [Advanced Packaging Tool](https://wiki.debian.org/Apt) aka **APT** (i.e., `apt-get`, `apt-cache`, etc.)
45
+
46
+ ### OS X
47
+ * [Homebrew](http://brew.sh/) (i.e., `brew`)
48
+
49
+ ### Others
50
+ * Suggestions? Open a GitHub issue tagged as a *Feature Request*.
51
+
52
+ ## Installation
53
+
54
+ For now:
55
+
56
+ ```Shell
57
+ $ git clone https://github.com/eriknomitch/mpm.git
58
+ $ cd mpm
59
+ $ bundle install
60
+ $ rake install
61
+ ```
62
+ ## Copyright
63
+
64
+ Copyright &copy; 2015 Erik Nomitch. See LICENSE.txt for further details.
65
+
@@ -0,0 +1,52 @@
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://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = "mpm"
18
+ gem.homepage = "http://github.com/eriknomitch/mpm"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{A meta package manager}
21
+ gem.description = %Q{A meta package manager to unify interaction with multiple package managers across various platforms.}
22
+ gem.email = "erik@nomitch.com"
23
+ gem.authors = ["Erik Nomitch"]
24
+ gem.executables = ["mpm"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ desc "Code coverage detail"
37
+ task :simplecov do
38
+ ENV['COVERAGE'] = "true"
39
+ Rake::Task['test'].execute
40
+ end
41
+
42
+ task :default => :test
43
+
44
+ require 'rdoc/task'
45
+ Rake::RDocTask.new do |rdoc|
46
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
47
+
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.title = "mpm #{version}"
50
+ rdoc.rdoc_files.include('README*')
51
+ rdoc.rdoc_files.include('lib/**/*.rb')
52
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/bin/mpm ADDED
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+ # ================================================
3
+ # MPM ============================================
4
+ # ================================================
5
+ begin
6
+ require "mpm"
7
+ rescue LoadError
8
+ require "rubygems"
9
+ require "mpm"
10
+ end
11
+
@@ -0,0 +1,138 @@
1
+ # ================================================
2
+ # MPM ============================================
3
+ # ================================================
4
+
5
+ # ------------------------------------------------
6
+ # REQUIRE->PRE -----------------------------------
7
+ # ------------------------------------------------
8
+ require "json"
9
+ require "shellwords"
10
+ require "yaml"
11
+ require "recursive-open-struct"
12
+ require "thor"
13
+ require "thor/group"
14
+ require "awesome_print"
15
+ require "active_support/core_ext/hash/reverse_merge"
16
+ require "active_support/core_ext/module"
17
+ require "active_support/core_ext/object/blank"
18
+ require "active_support/core_ext/object/try"
19
+ require "active_support/inflector/inflections"
20
+ require "os-name"
21
+ require "colorize"
22
+
23
+ # FIX: Development only
24
+ require "pry" if Gem::Specification::find_all_by_name("pry").any?
25
+
26
+ # ------------------------------------------------
27
+ # ->CLASS->STRING --------------------------------
28
+ # ------------------------------------------------
29
+ # http://headynation.com/opposite-of-chomp-in-ruby/
30
+ class String
31
+ def remove_from_beginning(string_to_remove)
32
+ len = string_to_remove.size
33
+ if self[0..(len-1)] == string_to_remove
34
+ return self[len..-1]
35
+ end
36
+ self
37
+ end
38
+ end
39
+
40
+ # ------------------------------------------------
41
+ # MODULE->MPM ------------------------------------
42
+ # ------------------------------------------------
43
+ module MPM
44
+
45
+ # ----------------------------------------------
46
+ # CONSTANTS ------------------------------------
47
+ # ----------------------------------------------
48
+ VERSION = Gem.loaded_specs["mpm"].version
49
+
50
+ # ----------------------------------------------
51
+ # ATTRIBUTES -----------------------------------
52
+ # ----------------------------------------------
53
+ # pm_provisioners: The Set of all the defined PackageManagerProvisioners
54
+ # pm_provisioner: The currently selected PackageManagerProvisioner for this OS/platform.
55
+ mattr_accessor *%i(
56
+ pm_provisioners
57
+ pm_provisioner
58
+ config
59
+ )
60
+
61
+ self.pm_provisioners = Set.new
62
+
63
+ self.config = {
64
+ output_translation: true
65
+ }
66
+
67
+ # ----------------------------------------------
68
+ # MODULE->UTILITY ------------------------------
69
+ # ----------------------------------------------
70
+ module Utility
71
+ def self.get_os()
72
+ OS.to_sym
73
+ end
74
+
75
+ def self.get_pm_executable()
76
+ case get_os
77
+ when :linux
78
+ # FIX: Detect distro...
79
+ "apt-get"
80
+ when :osx, :macos
81
+ # FIX: Ensure brew, etc.
82
+ "brew"
83
+ end
84
+ end
85
+
86
+ # --------------------------------------------
87
+ # FILE-LOADING -------------------------------
88
+ # --------------------------------------------
89
+ def self.glob_in_pwd(*path_suffixes)
90
+ Dir.glob(File.expand_path(File.join(File.dirname(__FILE__), *path_suffixes)))
91
+ end
92
+
93
+ def self.load_from_glob_in_pwd(*path_suffixes)
94
+ glob_in_pwd(*path_suffixes).each do |file|
95
+ load file
96
+ end
97
+ end
98
+
99
+ def self.instance_eval_from_glob_in_pwd(instance, *path_suffixes)
100
+ glob_in_pwd(*path_suffixes).each do |file|
101
+ instance.instance_eval File.read(file)
102
+ end
103
+ end
104
+
105
+ end
106
+
107
+ # ----------------------------------------------
108
+ # MAIN -----------------------------------------
109
+ # ----------------------------------------------
110
+
111
+ # Load additional files
112
+ # ----------------------------------------------
113
+ # Load the base modules/classes for Provisioner and Extension
114
+ Utility.load_from_glob_in_pwd "mpm/pm/*.rb"
115
+
116
+ # Load the Provisioners definitions from their own files.
117
+ Utility.instance_eval_from_glob_in_pwd self, "pm_provisioners/*.rb"
118
+
119
+ # Load the Provisioners extensions (after their base Provisioners
120
+ # have been loaded)
121
+ Utility.load_from_glob_in_pwd "pm_provisioners/*/**.rb"
122
+
123
+ # Set main Provisioner
124
+ # ----------------------------------------------
125
+ # Find and set the main Provisioners that this machine will use.
126
+ self.pm_provisioner = ::MPM::PM::Provisioner.get()
127
+
128
+ end
129
+
130
+ # ------------------------------------------------
131
+ # REQUIRE->POST ----------------------------------
132
+ # ------------------------------------------------
133
+ require "mpm/cli"
134
+
135
+ # ================================================
136
+ # MAIN ===========================================
137
+ # ================================================
138
+ MPM::CLI.start ARGV
@@ -0,0 +1,128 @@
1
+ # ------------------------------------------------
2
+ # MODULE->MPM ------------------------------------
3
+ # ------------------------------------------------
4
+ module MPM
5
+
6
+ # ----------------------------------------------
7
+ # CLASS->CLI (THOR) ----------------------------
8
+ # ----------------------------------------------
9
+ class CLI < Thor
10
+
11
+ # --------------------------------------------
12
+ # CONFIGURATION ------------------------------
13
+ # --------------------------------------------
14
+ package_name "mpm"
15
+
16
+ # --------------------------------------------
17
+ # COMMAND->SEARCH ----------------------------
18
+ # --------------------------------------------
19
+ desc "search [--all|-a] PACKAGE", "Searches for a package in the list of available packages."
20
+ def search(package)
21
+ ::MPM.pm_provisioner.exec_command :search, package
22
+ end
23
+
24
+ map "--search" => "search"
25
+
26
+ # FIX: Change this to an argument of "list"
27
+ desc "search-installed PACKAGE", "Searches for a package in the list of installed packages."
28
+ def search_installed(package)
29
+ ::MPM.pm_provisioner.exec_command :search_installed, package
30
+ end
31
+
32
+ map "--search-installed" => "search-installed"
33
+
34
+ # --------------------------------------------
35
+ # COMMAND->INSTALL ---------------------------
36
+ # --------------------------------------------
37
+ # TODO: $ mpm install cask/hazel
38
+ # TODO: $ mpm install gem/git-up
39
+ desc "install PACKAGE", "Installs one or more packages."
40
+ def install(*packages)
41
+ ::MPM.pm_provisioner.exec_command :install, *packages
42
+ end
43
+
44
+ map "--install" => "install"
45
+
46
+ # --------------------------------------------
47
+ # COMMAND->UNINSTALL -------------------------
48
+ # --------------------------------------------
49
+ desc "uninstall PACKAGE", "Uninstalls one or more packages."
50
+ def uninstall(*packages)
51
+ ::MPM.pm_provisioner.exec_command :uninstall, *packages
52
+ end
53
+
54
+ map "--uninstall" => "uninstall"
55
+
56
+ # --------------------------------------------
57
+ # COMMAND->LIST ------------------------------
58
+ # --------------------------------------------
59
+ desc "list", "Lists installed packages."
60
+ def list()
61
+ ::MPM.pm_provisioner.exec_command :list
62
+ end
63
+
64
+ map "--list" => "list"
65
+
66
+ # --------------------------------------------
67
+ # COMMAND->UPDATE ----------------------------
68
+ # --------------------------------------------
69
+ desc "update", "TODO"
70
+ def update()
71
+ ::MPM.pm_provisioner.exec_command :update
72
+ end
73
+
74
+ map "--update" => "update"
75
+
76
+ # --------------------------------------------
77
+ # COMMAND->UPGRADE ---------------------------
78
+ # --------------------------------------------
79
+ desc "update", "Upgrades a package."
80
+ def upgrade()
81
+ ::MPM.pm_provisioner.exec_command :upgrade
82
+ end
83
+
84
+ map "--upgrade" => "upgrade"
85
+
86
+ # --------------------------------------------
87
+ # COMMAND->INFO ------------------------------
88
+ # --------------------------------------------
89
+ desc "info PACKAGE", "Displays information about a package."
90
+ def info(package)
91
+ ::MPM.pm_provisioner.exec_command :info, package
92
+ end
93
+
94
+ map "--info" => "info"
95
+
96
+ # TODO:
97
+ # --------------------------------------------
98
+ # * mpm installed details PACKAGE (Gets details on an installed package)
99
+ # * mpm installed search PACKAGE
100
+ #
101
+ # * mpm upgrade cowsay # Ability to upgrade single packege.
102
+ #
103
+ # * How to handle 'apt-get autoremove'? mpm clean? mpm cleanup? mpm system-cleanup?
104
+ #
105
+ # * Have the ability to pass multiple extensions to search `mpm / /gem mruby` for
106
+ # the base package manager and /gem
107
+
108
+ # --------------------------------------------
109
+ # COMMAND->VERSION ---------------------------
110
+ # --------------------------------------------
111
+ desc "version", "Displays the current version of notify-push"
112
+ def version()
113
+ puts ::MPM::VERSION
114
+ end
115
+
116
+ map "--version" => "version"
117
+
118
+ end
119
+
120
+ end
121
+
122
+ # ------------------------------------------------
123
+ # TRAP->SIGINT -----------------------------------
124
+ # ------------------------------------------------
125
+ trap "SIGINT" do
126
+ exit 130
127
+ end
128
+