Class: GemCheckUpdates::Option
- Inherits:
-
Object
- Object
- GemCheckUpdates::Option
- Defined in:
- lib/gem_check_updates/option.rb
Instance Attribute Summary collapse
-
#apply ⇒ Object
Returns the value of attribute apply.
-
#file ⇒ Object
Returns the value of attribute file.
-
#major ⇒ Object
Returns the value of attribute major.
-
#minor ⇒ Object
Returns the value of attribute minor.
-
#patch ⇒ Object
Returns the value of attribute patch.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(file: './Gemfile') ⇒ Option
constructor
A new instance of Option.
- #update_scope ⇒ Object
Constructor Details
#initialize(file: './Gemfile') ⇒ Option
Returns a new instance of Option.
7 8 9 10 11 12 13 |
# File 'lib/gem_check_updates/option.rb', line 7 def initialize(file: './Gemfile') @file = file @apply = false @major = true @minor = false @patch = false end |
Instance Attribute Details
#apply ⇒ Object
Returns the value of attribute apply.
5 6 7 |
# File 'lib/gem_check_updates/option.rb', line 5 def apply @apply end |
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/gem_check_updates/option.rb', line 5 def file @file end |
#major ⇒ Object
Returns the value of attribute major.
5 6 7 |
# File 'lib/gem_check_updates/option.rb', line 5 def major @major end |
#minor ⇒ Object
Returns the value of attribute minor.
5 6 7 |
# File 'lib/gem_check_updates/option.rb', line 5 def minor @minor end |
#patch ⇒ Object
Returns the value of attribute patch.
5 6 7 |
# File 'lib/gem_check_updates/option.rb', line 5 def patch @patch end |
Class Method Details
.parse(argv) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/gem_check_updates/option.rb', line 15 def self.parse(argv) option = new OptionParser.new do |opt| opt.version = GemCheckUpdates::VERSION opt.on('-f Gemfile', '--file', "Path to Gemfile (default: #{option.file})") { |v| option.file = v } opt.on('-a', '--apply', "Apply updates (default: #{option.apply})") { |v| option.apply = v } opt.on('--major', "Update major version (default: #{option.major})") do |v| option.major = v option.minor = !v option.patch = !v end opt.on('--minor', "Update minor version (default: #{option.minor})") do |v| option.major = !v option.minor = v option.patch = !v end opt.on('--patch', "Update patch version (default: #{option.patch})") do |v| option.major = !v option.minor = !v option.patch = v end opt.parse!(argv) end option end |
Instance Method Details
#update_scope ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/gem_check_updates/option.rb', line 45 def update_scope if !@major && @minor GemCheckUpdates::VersionScope::MINOR elsif !@major && !@minor && @patch GemCheckUpdates::VersionScope::PATCH else GemCheckUpdates::VersionScope::MAJOR end end |