dist_diff 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ DistDiff
2
+ ========
3
+
4
+ [![Gem Version](https://badge.fury.io/rb/dist_diff.svg)](https://badge.fury.io/rb/dist_diff)
5
+ [![Code Climate](https://codeclimate.com/github/AnwarShah/dist_diff/badges/gpa.svg)](https://codeclimate.com/github/AnwarShah/dist_diff)
6
+
7
+ For getting the difference of package names between two Ubuntu distributions using Ubuntu manifest file.
8
+
9
+ It will be helpful to convert a full Kubuntu installation to Ubuntu or vice-versa or similar other case.
10
+
11
+ Installation
12
+ ------------
13
+ Install gem with
14
+
15
+ ```ruby
16
+ gem install dist_diff
17
+ ```
18
+
19
+ Usage of the executable
20
+ ------------------------
21
+ From any command line client use this pattern
22
+
23
+ ```bash
24
+ dist_diff from_ubuntu_manifest to_ubuntu_manifest
25
+ ```
26
+ Where `from_ubuntu_manifest` is the manifest file of your current Ubuntu derivative and `to_ubuntu_manifest` is the derivative you want to switch to.
27
+
28
+ Usage in Ruby program or irb
29
+ ----------------------------
30
+
31
+ ```ruby
32
+ require 'dist_diff'
33
+
34
+ dist_diff = DistDiff.new('kubuntu-15.10-desktkop-amd64.manifest', 'ubuntu-15.10-desktkop-amd64.manifest')
35
+ dist_diff.extra_packages # To get the package names in Ubuntu not in Kubuntu
36
+ dist_diff.reverse_extra_packages # To get the reverse list, that is extra packages in Kubuntu
37
+ ```
38
+
39
+ TODO
40
+ ----
41
+ 1. Interatively ask user about the derivatives and
42
+ 2. Use Internet to fetch the manifest files of Ubuntu
43
+
44
+ Disclaimer
45
+ -----------
46
+
47
+ The developer of this program shall not be held responsible for any loss by using this program. It is your responsibilty to ensure that two compatible Ubuntu distribution's manifest files are given.
data/dist_diff.gemspec ADDED
@@ -0,0 +1,16 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'dist_diff'
3
+ s.version = '0.3'
4
+ s.date = '2016-05-12'
5
+ s.summary = "A gem for finding the packages need to be installed to switch Ubuntu derivatives"
6
+ s.description = "A simple gem to extract the differences of package names between Ubuntu derivatives so that it becomes easy to switch from one Ubuntu derivative to another"
7
+ s.authors = ["Mohammad Anwar Shah"]
8
+ s.email = 'mohammadanwarshah@gmail.com'
9
+ s.files = `git ls-files`.split("\n")
10
+ s.test_files = `git ls-files -- spec/*`.split("\n")
11
+ s.required_ruby_version = '>= 1.9.1'
12
+ s.executables << 'dist_diff'
13
+ s.homepage =
14
+ 'http://rubygems.org/gems/dist_diff'
15
+ s.license = 'MIT'
16
+ end
@@ -0,0 +1,38 @@
1
+ require 'spec_helper'
2
+ require 'dist_diff/file_reader'
3
+
4
+ RSpec.describe FileReader do
5
+
6
+ let(:file_content) {
7
+ <<-END
8
+ account-plugin-aim 3.12.10-0ubuntu2
9
+ acpid 1:2.0.23-1ubuntu1
10
+ amarok 2:2.8.0-0ubuntu6
11
+ END
12
+ }
13
+ let(:filename) { "ubuntu_manifest" }
14
+
15
+ let(:manifest_file) { StringIO.new }
16
+
17
+ before(:example) do
18
+ allow(File).to receive(:open).with(filename,'r').and_yield(manifest_file)
19
+ # Setting file content
20
+ manifest_file.string = file_content
21
+ end
22
+
23
+ describe "#initialize" do
24
+ it "accepts the filename as only argument" do
25
+ expect { FileReader.new() }.to raise_error(ArgumentError)
26
+ end
27
+ end
28
+
29
+ describe "#package_names" do
30
+ it "returns an Array" do
31
+ expect(FileReader.new(filename).package_names).to be_kind_of(Array)
32
+ end
33
+
34
+ it "returns the package names in the Array" do
35
+ expect(FileReader.new(filename).package_names).to eq ['account-plugin-aim', 'acpid', 'amarok']
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+ require 'dist_diff'
3
+
4
+ RSpec.describe DistDiff do
5
+ describe "#initialize" do
6
+ it "accepts two filenames as two arguments" do
7
+ expect{ DistDiff.new() }.to raise_error(ArgumentError)
8
+ expect{ DistDiff.new('file1', 'file2') }.not_to raise_error
9
+ end
10
+ end
11
+
12
+ describe "#extra_packages" do
13
+
14
+ let(:ubuntu_manifest_content) {
15
+ <<-END
16
+ account-plugin-aim 3.12.10-0ubuntu2
17
+ acpid 1:2.0.23-1ubuntu1
18
+ alsa-base 1.0.25+dfsg-0ubuntu5
19
+ alsa-utils 1.0.29-0ubuntu1
20
+ activity-log-manager 0.9.7-0ubuntu22
21
+ brasero-common 3.12.1-0ubuntu2
22
+ bsdmainutils 9.0.6ubuntu1
23
+ cheese-common 3.16.1-1ubuntu2
24
+ END
25
+ }
26
+
27
+ let(:kubuntu_manifest_content) {
28
+ <<-END
29
+ adduser 3.113+nmu3ubuntu4
30
+ adwaita-icon-theme 3.16.2.1-2ubuntu1
31
+ akonadi-server 4:15.08.2-0ubuntu1
32
+ akregator 4:15.08.2-0ubuntu1
33
+ alsa-base 1.0.25+dfsg-0ubuntu5
34
+ alsa-utils 1.0.29-0ubuntu1
35
+ amarok 2:2.8.0-0ubuntu6
36
+ END
37
+ }
38
+
39
+ let(:ubuntu_manifest_file) { StringIO.new }
40
+ let(:kubuntu_manifest_file) { StringIO.new }
41
+
42
+ before(:example) do
43
+ # Setting the content
44
+ ubuntu_manifest_file.string = ubuntu_manifest_content
45
+ kubuntu_manifest_file.string = kubuntu_manifest_content
46
+
47
+ allow(File).to receive(:open).with('ubuntu_manifest', 'r').and_yield(ubuntu_manifest_file)
48
+ allow(File).to receive(:open).with('kubuntu_manifest', 'r').and_yield(kubuntu_manifest_file)
49
+ end
50
+
51
+ subject { DistDiff.new('ubuntu_manifest', 'kubuntu_manifest') }
52
+
53
+ it "returns an array" do
54
+ expect(subject.extra_packages).to be_kind_of(Array)
55
+ end
56
+
57
+ it "returns the package names only presents in the second manifest" do
58
+ returned_result = subject.extra_packages
59
+ expect(returned_result).to eq ['adduser', 'adwaita-icon-theme', 'akonadi-server', 'akregator', 'amarok']
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,98 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
4
+ # this file to always be loaded, without a need to explicitly require it in any
5
+ # files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need
13
+ # it.
14
+ #
15
+ # The `.rspec` file also contains a few flags that are not defaults but that
16
+ # users commonly want.
17
+ #
18
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
+
20
+ RSpec.configure do |config|
21
+ # rspec-expectations config goes here. You can use an alternate
22
+ # assertion/expectation library such as wrong or the stdlib/minitest
23
+ # assertions if you prefer.
24
+ config.expect_with :rspec do |expectations|
25
+ # This option will default to `true` in RSpec 4. It makes the `description`
26
+ # and `failure_message` of custom matchers include text for helper methods
27
+ # defined using `chain`, e.g.:
28
+ # be_bigger_than(2).and_smaller_than(4).description
29
+ # # => "be bigger than 2 and smaller than 4"
30
+ # ...rather than:
31
+ # # => "be bigger than 2"
32
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
33
+ end
34
+
35
+ # rspec-mocks config goes here. You can use an alternate test double
36
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
37
+ config.mock_with :rspec do |mocks|
38
+ # Prevents you from mocking or stubbing a method that does not exist on
39
+ # a real object. This is generally recommended, and will default to
40
+ # `true` in RSpec 4.
41
+ mocks.verify_partial_doubles = true
42
+ end
43
+
44
+
45
+ # The settings below are suggested to provide a good initial experience
46
+ # with RSpec, but feel free to customize to your heart's content.
47
+ =begin
48
+ # These two settings work together to allow you to limit a spec run
49
+ # to individual examples or groups you care about by tagging them with
50
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
51
+ # get run.
52
+ config.filter_run :focus
53
+ config.run_all_when_everything_filtered = true
54
+
55
+ # Allows RSpec to persist some state between runs in order to support
56
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
57
+ # you configure your source control system to ignore this file.
58
+ config.example_status_persistence_file_path = "spec/examples.txt"
59
+
60
+ # Limits the available syntax to the non-monkey patched syntax that is
61
+ # recommended. For more details, see:
62
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
63
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
64
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
65
+ config.disable_monkey_patching!
66
+
67
+ # This setting enables warnings. It's recommended, but in some cases may
68
+ # be too noisy due to issues in dependencies.
69
+ config.warnings = true
70
+
71
+ # Many RSpec users commonly either run the entire suite or an individual
72
+ # file, and it's useful to allow more verbose output when running an
73
+ # individual spec file.
74
+ if config.files_to_run.one?
75
+ # Use the documentation formatter for detailed output,
76
+ # unless a formatter has already been configured
77
+ # (e.g. via a command-line flag).
78
+ config.default_formatter = 'doc'
79
+ end
80
+
81
+ # Print the 10 slowest examples and example groups at the
82
+ # end of the spec run, to help surface which specs are running
83
+ # particularly slow.
84
+ config.profile_examples = 10
85
+
86
+ # Run specs in random order to surface order dependencies. If you find an
87
+ # order dependency and want to debug it, you can fix the order by providing
88
+ # the seed, which is printed after each run.
89
+ # --seed 1234
90
+ config.order = :random
91
+
92
+ # Seed global randomization in this process using the `--seed` CLI option.
93
+ # Setting this allows you to use `--seed` to deterministically reproduce
94
+ # test failures related to randomization by passing the same `--seed` value
95
+ # as the one that triggered the failure.
96
+ Kernel.srand config.seed
97
+ =end
98
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dist_diff
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohammad Anwar Shah
@@ -18,9 +18,19 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - ".codeclimate.yml"
22
+ - ".gitignore"
23
+ - ".rspec"
24
+ - ".rubocop.yml"
25
+ - LICENSE
26
+ - README.md
21
27
  - bin/dist_diff
28
+ - dist_diff.gemspec
22
29
  - lib/dist_diff.rb
23
30
  - lib/dist_diff/file_reader.rb
31
+ - spec/dist_diff/file_reader_spec.rb
32
+ - spec/dist_diff_spec.rb
33
+ - spec/spec_helper.rb
24
34
  homepage: http://rubygems.org/gems/dist_diff
25
35
  licenses:
26
36
  - MIT
@@ -33,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
43
  requirements:
34
44
  - - ">="
35
45
  - !ruby/object:Gem::Version
36
- version: '0'
46
+ version: 1.9.1
37
47
  required_rubygems_version: !ruby/object:Gem::Requirement
38
48
  requirements:
39
49
  - - ">="
@@ -41,8 +51,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
51
  version: '0'
42
52
  requirements: []
43
53
  rubyforge_project:
44
- rubygems_version: 2.4.8
54
+ rubygems_version: 2.2.2
45
55
  signing_key:
46
56
  specification_version: 4
47
57
  summary: A gem for finding the packages need to be installed to switch Ubuntu derivatives
48
- test_files: []
58
+ test_files:
59
+ - spec/dist_diff/file_reader_spec.rb
60
+ - spec/dist_diff_spec.rb
61
+ - spec/spec_helper.rb