ordinare 0.2.8 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 47c18c1d0acc8ec6bb426e2104ab6d51e07a8016
4
- data.tar.gz: 0a34018511ccfa5db40f97002dacf0018b5e88b5
3
+ metadata.gz: e8eefbe9b6d3f26de2734863db44c6545edbad95
4
+ data.tar.gz: 3caea8639b118c3b4165a0d59921c9735cc72279
5
5
  SHA512:
6
- metadata.gz: 986d7a9908771216e657d3c19b8650e183c067993239c0bcb301a186400578cf642cc0f5224bffb8da3862bc4a57e69b2e0fc1d1a31b94365be9b701ebf91a0c
7
- data.tar.gz: 0d3dc6c0583f13c4469cb0abc49073bf66beee0ac6ed0711d5e048f274794d61abc55cd06e6914377dffe4ebdcde3d7170a5edaf4f2e07243a19b0db6a8e4646
6
+ metadata.gz: 3c8dc9e5021c9ed77f65a9da1822f34ba02bffe5e87de87a939f164ec423ba6b8d478e7c847f42c181a94de59f2a588e7d749aa817768848e3cbfd34f6187f5b
7
+ data.tar.gz: 7ebb521a7018e5ea544837411ffd4c5ed6d5cf4289a183eb0db6a8ffe40f0ae74c7dee332829348fa43fa2466b0d0272ea89f4616aa8605508a44c5df03eb92e
@@ -3,8 +3,7 @@
3
3
  require "ordinare"
4
4
 
5
5
  if ARGV.size > 0
6
- puts Ordinare.parse_args
6
+ Ordinare.parse_args
7
7
  else
8
8
  Ordinare.sort
9
9
  end
10
-
@@ -9,24 +9,39 @@ module Ordinare
9
9
  end
10
10
 
11
11
  def parse_args
12
+ path = "Gemfile"
13
+ overwrite = true
14
+ version = nil
15
+ help = nil
16
+
12
17
  OptionParser.new do |opts|
13
18
  opts.banner = "Usage: ordinare inside your Rails project"
19
+ opts.separator ""
20
+ opts.separator "Specific options:"
14
21
 
15
22
  opts.on("-pFILE", "--path=FILE", "Order file") do |filename|
16
- Ordinare.sort(filename)
23
+ path = filename
24
+ end
25
+
26
+ opts.on("-n", "--no-overwrite", "Don't overwrite Gemfile") do
27
+ overwrite = false
17
28
  end
18
29
 
19
30
  opts.on("-v", "--version", "Check gem version") do
20
31
  puts Ordinare::VERSION
32
+ version = true
21
33
  end
22
34
 
23
35
  opts.on("-h", "--help", "Get help") do
24
36
  puts opts
37
+ help = true
25
38
  end
26
39
  end.parse!
40
+
41
+ Ordinare.sort(overwrite, path) unless version || help
27
42
  end
28
43
 
29
- def sort(path = "Gemfile")
44
+ def sort(overwrite = true, path = "Gemfile")
30
45
  unless File.file?(path)
31
46
  abort("No Gemfile found in the current directory, is this a Rails project with Gemfile?")
32
47
  end
@@ -40,11 +55,13 @@ module Ordinare
40
55
  content[range[:start_index]..range[:end_index]].sort
41
56
  end
42
57
 
43
- File.open("#{path}.ordinare", "w+") do |file|
58
+ path = "#{path}.ordinare" unless overwrite
59
+
60
+ File.open(path, "w+") do |file|
44
61
  content.each { |line| file.puts(line) }
45
62
  end
46
63
 
47
- puts "Your sorted Gemfile can be found at #{path}.ordinare"
64
+ puts "Your sorted Gemfile can be found at #{path} path"
48
65
  end
49
66
 
50
67
  def find_ranges_of_gems(content)
@@ -1,3 +1,3 @@
1
1
  module Ordinare
2
- VERSION = "0.2.8"
2
+ VERSION = "0.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ordinare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.8
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Đuza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-01 00:00:00.000000000 Z
11
+ date: 2017-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 2.5.2
63
+ rubygems_version: 2.4.5.2
64
64
  signing_key:
65
65
  specification_version: 4
66
66
  summary: Sort your gems in Gemfile with ease