toys 0.3.10 → 0.3.11

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
  SHA256:
3
- metadata.gz: c56bc4031b9a4e6c84b5a48c05404e0054fc733ad2b6f77b43cf5efa3f8744ef
4
- data.tar.gz: 398ec517068fa746151e63e201bc0c40782a630c78c0d7cb0202d351ca74facb
3
+ metadata.gz: e808d6aa4a3e6a57484c458c7c2633ce1dc248991327c69d3c728b3eb502f135
4
+ data.tar.gz: 5092670abd0a8cdf65d6d62dc1d34455229022e9780384ec2d91dd34553a8615
5
5
  SHA512:
6
- metadata.gz: b84330bdf6b8cc738f5cfa01223be839236c6c0e5c12da4a17e144a673b591423cee45373e06e2be159516f0e8b08f8224e08314a601b84f52c235d65ab6a718
7
- data.tar.gz: 6eefb4e5b5b843f3fe95d38b9573b9a3d7e7222c7cade05c16611b0c33e8e7b914fceddc1ae74818e7e7015faee95a88684d4502a4fe31171f2070a813b1b984
6
+ metadata.gz: 932274290953fe6bbcc60f58c87b808b2f0ebec867ca6a8d21c9342ca49788131fbad9f1d7755147c4f5635177da7615e51d22f88fe91d9fe617a499b20b2748
7
+ data.tar.gz: 5d4f9b1651d79c9cbb71cedc014cbf1af5c63f22817a1f7a87f588316ee5080b8afb0a0437275428d15a15ac4bce188cd021d94f594703e165237a6dadf90fd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Release History
2
2
 
3
+ ### 0.3.11 / 2018-07-02
4
+
5
+ * CHANGED: Require Ruby 2.3 or later
6
+ * CHANGED: Renamed "set" directive to "static" to reduce confusion with Tool#set.
7
+ * ADDED: Convenience methods for getting option values
8
+
3
9
  ### 0.3.10 / 2018-06-30
4
10
 
5
11
  * CHANGED: Dropped Tool#option. Use Tool#get instead.
data/README.md CHANGED
@@ -34,7 +34,7 @@ Unlike most command line frameworks, Toys is *not primarily* designed to help
34
34
  you build and ship a custom command line binary written in Ruby. However, you
35
35
  *can* use it in that way by building with the "toys-core" API, available as a
36
36
  separate gem. For more info on using toys-core, see
37
- https://ruby-doc.info/gems/toys-core
37
+ https://www.rubydoc.info/gems/toys-core
38
38
 
39
39
  ## Quick Start
40
40
 
@@ -71,7 +71,7 @@ leading period). Copy the following into the file, and save it:
71
71
  desc "My first tool!"
72
72
  flag :whom, default: "world"
73
73
  def run
74
- puts "Hello, #{get(:whom)}!"
74
+ puts "Hello, #{whom}!"
75
75
  end
76
76
  end
77
77
 
data/bin/toys CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
4
  # Copyright 2018 Daniel Azuma
4
5
  #
data/builtins/do.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -55,8 +57,8 @@ flag :delim, "-d", "--delim=VALUE",
55
57
  remaining_args :args, desc: "A series of tools to run, separated by the delimiter"
56
58
 
57
59
  def run
58
- get(:args)
59
- .chunk { |arg| arg == get(:delim) ? :_separator : true }
60
+ args
61
+ .chunk { |arg| arg == delim ? :_separator : true }
60
62
  .each do |_, action|
61
63
  code = cli.run(action)
62
64
  exit(code) unless code.zero?
data/builtins/system.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -61,7 +63,7 @@ tool "update" do
61
63
  cur_version = ::Gem::Version.new(::Toys::VERSION)
62
64
  if latest_version > cur_version
63
65
  prompt = "Update toys from #{cur_version} to #{latest_version}?"
64
- exit(1) unless get(:yes) || confirm(prompt)
66
+ exit(1) unless yes || confirm(prompt)
65
67
  result = terminal.spinner(leading_text: "Installing Toys version #{latest_version}... ",
66
68
  final_text: "Done.\n") do
67
69
  exec(["gem", "install", "toys", "--version", latest_version.to_s],
data/docs/guide.md CHANGED
@@ -265,8 +265,8 @@ Consider the following example:
265
265
  flag :shout, "-s", "--shout", desc: "Greet loudly."
266
266
 
267
267
  def run
268
- greeting = "Hello, #{get(:whom)}!"
269
- greeting.upcase! if get(:shout)
268
+ greeting = "Hello, #{whom}!"
269
+ greeting.upcase! if shout
270
270
  puts greeting
271
271
  end
272
272
  end
@@ -454,7 +454,7 @@ integer during parsing:
454
454
  tool "args-demo" do
455
455
  required_arg :age, accept: Integer
456
456
  def run
457
- age = get(:age) # This is an integer
457
+ puts "Next year I will be #{age + 1}" # Age is an integer
458
458
  ...
459
459
 
460
460
  If you pass a non-integer for this argument, Toys will report a usage error.
@@ -505,8 +505,8 @@ You can also declare the value to be optional:
505
505
 
506
506
  flag :whom, "--whom[=VALUE]"
507
507
  flag :whom, "--whom [VALUE]"
508
- flag :whom, "-wVALUE"
509
- flag :whom, "-w VALUE"
508
+ flag :whom, "-w[VALUE]"
509
+ flag :whom, "-w [VALUE]"
510
510
 
511
511
  Note that if you define multiple flags together, they will all be coerced to
512
512
  the same "type". That is, if one takes a value, they all will implicitly take
@@ -541,7 +541,7 @@ integer during parsing:
541
541
  tool "args-demo" do
542
542
  flag :age, accept: Integer
543
543
  def run
544
- get(:age) # This is an integer
544
+ puts "Next year I will be #{age + 1}" # Age is an integer
545
545
  ...
546
546
 
547
547
  If you pass a non-integer for this flag value, Toys will report a usage error.
@@ -651,17 +651,38 @@ Let's revisit the "greet" example we covered earlier.
651
651
  flag :shout, "-s", "--shout"
652
652
 
653
653
  def run
654
- greeting = "Hello, #{get(:whom)}!"
655
- greeting.upcase! if get(:shout)
654
+ greeting = "Hello, #{whom}!"
655
+ greeting.upcase! if shout
656
656
  puts greeting
657
657
  end
658
658
  end
659
659
 
660
- Note how the `run` method uses the
660
+ Note that you can produce output or interact with the console using the normal
661
+ Ruby `$stdout`, `$stderr`, and `$stdin` streams.
662
+
663
+ Note also how the `run` method can access values that were assigned by flags or
664
+ positional arguments by just calling a method with that flag or argument name.
665
+ When you declare a flag or argument, if the option name is a symbol that is a
666
+ valid Ruby method name, Toys will provide a method of that name that you can
667
+ call to get the value.
668
+
669
+ If you create a flag or argument whose option name is not a symbol _or_ is not
670
+ a valid method name, you can still get the value by calling the
661
671
  [Toys::Tool#get](https://www.rubydoc.info/gems/toys-core/Toys%2FTool:get)
662
- method to access values that were assigned by flags or positional arguments.
663
- Note also that you can produce output or interact with the console using the
664
- normal Ruby `$stdout`, `$stderr`, and `$stdin` streams.
672
+ method. For example:
673
+
674
+ tool "greet" do
675
+ # The name "whom-to-greet" is not a valid method name.
676
+ optional_arg "whom-to-greet", default: "world"
677
+ flag :shout, "-s", "--shout"
678
+
679
+ def run
680
+ # We can access the "whom-to-greet" option using the "get" method.
681
+ greeting = "Hello, #{get('whom-to-greet')}!"
682
+ greeting.upcase! if shout
683
+ puts greeting
684
+ end
685
+ end
665
686
 
666
687
  If a tool's `run` method finishes normally, Toys will exit with a result code
667
688
  of 0, indicating success. You may exit immediately and/or provide a nonzero
@@ -680,7 +701,26 @@ exit with a nonzero code.
680
701
 
681
702
  Finally, you may also define additional methods within the tool. These are
682
703
  available to be called by your `run` method, and can be used to decompose your
683
- tool implementation.
704
+ tool implementation. Here's a contrived example:
705
+
706
+ tool "greet-many" do
707
+ # Support any number of arguments on the command line
708
+ remaining_args :whom, default: ["world"]
709
+ flag :shout, "-s", "--shout"
710
+
711
+ # You can define helper methods like this.
712
+ def greet(name)
713
+ greeting = "Hello, #{name}!"
714
+ greeting.upcase! if shout
715
+ puts greeting
716
+ end
717
+
718
+ def run
719
+ whom.each do |name|
720
+ greet(name)
721
+ end
722
+ end
723
+ end
684
724
 
685
725
  This should be enough to get you started implementing tools. A variety of
686
726
  additional features are available for your tool implementation and will be
@@ -795,7 +835,7 @@ For example, one way to create a "greet" tool, as we saw before, is to write a
795
835
  tool "greet" do
796
836
  optional_arg :whom, default: "world"
797
837
  def run
798
- puts "Hello, #{get(:whom)}"
838
+ puts "Hello, #{whom}"
799
839
  end
800
840
  end
801
841
 
@@ -804,7 +844,7 @@ creating a file `greet.rb` inside that directory. The contents would be:
804
844
 
805
845
  optional_arg :whom, default: "world"
806
846
  def run
807
- puts "Hello, #{get(:whom)}"
847
+ puts "Hello, #{whom}"
808
848
  end
809
849
 
810
850
  Notice that we did not use a `tool "greet"` block here. That is because the
@@ -1084,8 +1124,6 @@ that makes Highline available. It also automatically installs the highline
1084
1124
  gem (version 2.x) if it is not available. For more information, see the
1085
1125
  [Toys::StandardMixins::Highline mixin module](https://www.rubydoc.info/gems/toys-core/Toys/StandardMixins/Highline).
1086
1126
 
1087
- Additional mixins are forthcoming...
1088
-
1089
1127
  ## Sharing Code
1090
1128
 
1091
1129
  As you accumulate additional and more complex tools, you may find that some of
@@ -1639,6 +1677,144 @@ essentially identical to the Toys files provided for the **toys** and
1639
1677
  end
1640
1678
  end
1641
1679
 
1680
+ ## Using Third-Party Gems
1681
+
1682
+ The Ruby community has developed many resources for building command line
1683
+ tools, including a variety of gems that provide alternate command line parsing,
1684
+ control of the ANSI terminal, formatted output such as trees and tables, and
1685
+ effects such as hidden input, progress bars, various subprocess tools, and so
1686
+ forth.
1687
+
1688
+ This section describes how to use a third-party gem in your tool.
1689
+
1690
+ ### Activating Gems
1691
+
1692
+ The toys gem itself includes only two gems: **toys** and **toys-core**. It has
1693
+ no other gem dependencies. However, if you want to use a third-party gem in
1694
+ your tool, Toys provides a convenient mechanism to ensure the gem is installed.
1695
+
1696
+ If the gem is needed to *define* the tool, use the `gem` directive to ensure
1697
+ the gem is installed and activated. This takes the name of the gem, and an
1698
+ optional set of version requirements. If a gem matching the given version
1699
+ requirements is installed, it is activated. If not, the gem is installed (which
1700
+ the user can confirm or abort). Or, if Toys is being run in a bundle, a message
1701
+ is printed informing the user that they need to add the gem to their Gemfile.
1702
+
1703
+ For example, here's a way to configure a tool with flags for each of the
1704
+ HighLine styles:
1705
+
1706
+ tool "highline-styles-demo" do
1707
+ gem "highline", "~> 2.0"
1708
+ require "highline"
1709
+ HighLine::BuiltinStyles::STYLES.each do |style|
1710
+ style = style.downcase
1711
+ flag style.to_sym, "--#{style}", "Apply #{style} to the text"
1712
+ end
1713
+ def run
1714
+ # ...
1715
+
1716
+ If the gem is *not* needed to define the tool, but is needed to *run* the tool,
1717
+ then you can call
1718
+ [Toys::Tool#gem](https://www.rubydoc.info/gems/toys-core/Toys%2FTool:gem) from
1719
+ your `run` method. Here's an example:
1720
+
1721
+ tool "rake" do
1722
+ disable_argument_passing
1723
+ def run
1724
+ gem "rake", "~> 12.0"
1725
+ Kernel.exec(["rake"] + args)
1726
+ end
1727
+ end
1728
+
1729
+ If a gem satisfying the given version constraints is already activated, it
1730
+ remains active. If a gem with a conflicting version is already activated, an
1731
+ exception is raised.
1732
+
1733
+ If you are not in the Toys DSL context—e.g. you are writing a class-based
1734
+ mixin—you should use
1735
+ [Toys::Utils::Gems.activate](https://www.rubydoc.info/gems/toys-core/Toys%2FUtils%2FGems:activate)
1736
+ instead. For example:
1737
+
1738
+ Toys::Utils::Gems.activate("highline", "~> 2.0")
1739
+
1740
+ Note these methods are a bit different from the
1741
+ [gem method](http://ruby-doc.org/stdlib/libdoc/rubygems/rdoc/Kernel.html)
1742
+ provided by Rubygems. The Toys version attempts to install a missing gem for
1743
+ you, whereas Rubygems will just throw an exception.
1744
+
1745
+ ### Useful Gems
1746
+
1747
+ Now that you know how to ensure a gem is installed, let's look at some third-
1748
+ party gems that you might find useful when writing tools.
1749
+
1750
+ We already saw how to use the **highline** gem. Highline generally provides two
1751
+ features: terminal styling, and prompts. For these capabilities and many more,
1752
+ you might also consider [TTY](https://github.com/piotrmurach/tty). It comprises
1753
+ a suite of gems that you can use separately or in tandem. Here are a few
1754
+ examples.
1755
+
1756
+ To produce styled output, consider
1757
+ [Pastel](https://github.com/piotrmurach/pastel).
1758
+
1759
+ tool "fancy-output" do
1760
+ def run
1761
+ gem "pastel", "~> 0.7"
1762
+ require "pastel"
1763
+ pastel = Pastel.new
1764
+ puts pastel.red("Rubies!")
1765
+ end
1766
+ end
1767
+
1768
+ To create rich user prompts, consider
1769
+ [tty-prompt](https://github.com/piotrmurach/tty-prompt).
1770
+
1771
+ tool "favorite-language" do
1772
+ def run
1773
+ gem "tty-prompt", "~> 0.16"
1774
+ require "tty-prompt"
1775
+ prompt = TTY::Prompt.new
1776
+ lang = prompt.select("What is your favorite language?",
1777
+ %w[Elixir Java Python Ruby Rust Other])
1778
+ prompt.say("#{lang} is awesome!")
1779
+ end
1780
+ end
1781
+
1782
+ To create tabular output, consider
1783
+ [tty-table](https://github.com/piotrmurach/tty-table).
1784
+
1785
+ tool "matrix" do
1786
+ def run
1787
+ gem "tty-table", "~> 0.10"
1788
+ require "tty-table"
1789
+ table = TTY::Table.new(["Language", "Creator"],
1790
+ [["Ruby", "Matz"],
1791
+ ["Python", "Guido"],
1792
+ ["Elixir", "Jose"]])
1793
+ puts table.render(:ascii)
1794
+ end
1795
+ end
1796
+
1797
+ To show progress, consider
1798
+ [tty-progressbar](https://github.com/piotrmurach/tty-progressbar) for
1799
+ deterministic processes, or
1800
+ [tty-spinner](https://github.com/piotrmurach/tty-spinner) for
1801
+ non-deterministic.
1802
+
1803
+ tool "waiting" do
1804
+ def run
1805
+ gem "tty-progressbar", "~> 0.15"
1806
+ require "tty-progressbar"
1807
+ bar = TTY::ProgressBar.new("Waiting [:bar]", total: 30)
1808
+ 30.times do
1809
+ sleep(0.1)
1810
+ bar.advance(1)
1811
+ end
1812
+ end
1813
+ end
1814
+
1815
+ A variety of other useful gems can also be found in
1816
+ [this article](https://lab.hookops.com/ruby-cli-gems.html).
1817
+
1642
1818
  ## Advanced Tool Definition Techniques
1643
1819
 
1644
1820
  This section covers some additional features that are often useful for writing
@@ -1775,61 +1951,6 @@ Here is an example that wraps calls to git:
1775
1951
  end
1776
1952
  end
1777
1953
 
1778
- ### Activating Gems
1779
-
1780
- Sometimes implementing a tool will require a third-party gem. Some mixins also
1781
- utilize a gem. Toys provides a way to help the user install such gems if
1782
- needed.
1783
-
1784
- If the gem is needed to *define* the tool, use the `gem` directive to ensure
1785
- the gem is installed and activated. This takes the name of the gem, and an
1786
- optional set of version requirements. If a gem matching the given version
1787
- requirements is installed, it is activated. If not, the gem is installed (which
1788
- the user can confirm or abort). Or, if Toys is being run in a bundle, a message
1789
- is printed informing the user that they need to add the gem to their Gemfile.
1790
-
1791
- For example, here's a way to configure a tool with flags for each of the
1792
- HighLine styles:
1793
-
1794
- tool "highline-styles-demo" do
1795
- gem "highline", "~> 2.0"
1796
- require "highline"
1797
- HighLine::BuiltinStyles::STYLES.each do |style|
1798
- style = style.downcase
1799
- flag style.to_sym, "--#{style}", "Apply #{style} to the text"
1800
- end
1801
- def run
1802
- # ...
1803
-
1804
- If the gem is *not* needed to define the tool, but is needed to *run* the tool,
1805
- then you can call
1806
- [Toys::Tool#gem](https://www.rubydoc.info/gems/toys-core/Toys%2FTool:gem) from
1807
- your `run` method. Here's an example:
1808
-
1809
- tool "rake" do
1810
- disable_argument_passing
1811
- def run
1812
- gem "rake", "~> 12.0"
1813
- Kernel.exec(["rake"] + args)
1814
- end
1815
- end
1816
-
1817
- If a gem satisfying the given version constraints is already activated, it
1818
- remains active. If a gem with a conflicting version is already activated, an
1819
- exception is raised.
1820
-
1821
- If you are not in the Toys DSL context—e.g. you are writing a class-based
1822
- mixin—you should use
1823
- [Toys::Utils::Gems.activate](https://www.rubydoc.info/gems/toys-core/Toys%2FUtils%2FGems:activate)
1824
- instead. For example:
1825
-
1826
- Toys::Utils::Gems.activate("highline", "~> 2.0")
1827
-
1828
- Note these methods are a bit different from the
1829
- [gem method](http://ruby-doc.org/stdlib-2.5.1/libdoc/rubygems/rdoc/Kernel.html)
1830
- provided by Rubygems. The Toys version attempts to install a missing gem for
1831
- you, whereas Rubygems will just throw an exception.
1832
-
1833
1954
  ## Toys Administration Using the System Tools
1834
1955
 
1835
1956
  Toys comes with a few built-in tools, including some that let you administer
data/lib/toys.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -45,37 +47,37 @@ module Toys
45
47
  # Standard toys configuration directory name
46
48
  # @return [String]
47
49
  #
48
- CONFIG_DIR_NAME = ".toys".freeze
50
+ CONFIG_DIR_NAME = ".toys"
49
51
 
50
52
  ##
51
53
  # Standard toys configuration file name
52
54
  # @return [String]
53
55
  #
54
- CONFIG_FILE_NAME = ".toys.rb".freeze
56
+ CONFIG_FILE_NAME = ".toys.rb"
55
57
 
56
58
  ##
57
59
  # Standard index file name in a toys configuration
58
60
  # @return [String]
59
61
  #
60
- INDEX_FILE_NAME = ".toys.rb".freeze
62
+ INDEX_FILE_NAME = ".toys.rb"
61
63
 
62
64
  ##
63
65
  # Standard toys preload file name
64
66
  # @return [String]
65
67
  #
66
- PRELOAD_FILE_NAME = ".preload.rb".freeze
68
+ PRELOAD_FILE_NAME = ".preload.rb"
67
69
 
68
70
  ##
69
71
  # Name of standard toys binary
70
72
  # @return [String]
71
73
  #
72
- BINARY_NAME = "toys".freeze
74
+ BINARY_NAME = "toys"
73
75
 
74
76
  ##
75
77
  # Short description for the standard root tool
76
78
  # @return [String]
77
79
  #
78
- DEFAULT_ROOT_DESC = "Your personal command line tool".freeze
80
+ DEFAULT_ROOT_DESC = "Your personal command line tool"
79
81
 
80
82
  ##
81
83
  # Help text for the standard root tool
@@ -85,13 +87,13 @@ module Toys
85
87
  "Toys is your personal command line tool. You can add to the list of commands below by" \
86
88
  " writing scripts in Ruby using a simple DSL, and Toys will organize and document them" \
87
89
  " and make them available globally or scoped to specific directories that you choose." \
88
- " For detailed information, see https://www.rubydoc.info/gems/toys".freeze
90
+ " For detailed information, see https://www.rubydoc.info/gems/toys"
89
91
 
90
92
  ##
91
93
  # Short description for the verion flag
92
94
  # @return [String]
93
95
  #
94
- DEFAULT_VERSION_FLAG_DESC = "Show the version of Toys.".freeze
96
+ DEFAULT_VERSION_FLAG_DESC = "Show the version of Toys."
95
97
 
96
98
  ##
97
99
  # Create a standard CLI, configured with the appropriate paths and
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -39,7 +41,7 @@ module Toys
39
41
  # Default tool name
40
42
  # @return [String]
41
43
  #
42
- DEFAULT_TOOL_NAME = "clean".freeze
44
+ DEFAULT_TOOL_NAME = "clean"
43
45
 
44
46
  ##
45
47
  # Create the template settings for the Clean template.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -39,7 +41,7 @@ module Toys
39
41
  # Default tool name
40
42
  # @return [String]
41
43
  #
42
- DEFAULT_TOOL_NAME = "build".freeze
44
+ DEFAULT_TOOL_NAME = "build"
43
45
 
44
46
  ##
45
47
  # Create the template settings for the GemBuild template.
@@ -106,7 +108,7 @@ module Toys
106
108
  logger.error "Cannot push the gem when there are uncommited changes"
107
109
  exit(1)
108
110
  end
109
- exit(1) unless get(:yes) || confirm("Release #{gemfile}?")
111
+ exit(1) unless yes || confirm("Release #{gemfile}?")
110
112
  exec(["gem", "push", "pkg/#{gemfile}"])
111
113
  if template.tag
112
114
  exec(["git", "tag", "v#{version}"])
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -39,13 +41,13 @@ module Toys
39
41
  # Default version requirements for the minitest gem.
40
42
  # @return [Array<String>]
41
43
  #
42
- DEFAULT_GEM_VERSION_REQUIREMENTS = "~> 5.0".freeze
44
+ DEFAULT_GEM_VERSION_REQUIREMENTS = "~> 5.0"
43
45
 
44
46
  ##
45
47
  # Default tool name
46
48
  # @return [String]
47
49
  #
48
- DEFAULT_TOOL_NAME = "test".freeze
50
+ DEFAULT_TOOL_NAME = "test"
49
51
 
50
52
  ##
51
53
  # Default set of library paths
@@ -110,9 +112,8 @@ module Toys
110
112
  lib_path = template.libs.join(::File::PATH_SEPARATOR)
111
113
  ruby_args << "-I#{lib_path}"
112
114
  end
113
- ruby_args << "-w" if self[:warnings]
115
+ ruby_args << "-w" if warnings
114
116
 
115
- tests = self[:tests]
116
117
  if tests.empty?
117
118
  Array(template.files).each do |pattern|
118
119
  tests.concat(::Dir.glob(pattern))
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -39,19 +41,19 @@ module Toys
39
41
  # Default version requirements for the rdoc gem.
40
42
  # @return [Array<String>]
41
43
  #
42
- DEFAULT_GEM_VERSION_REQUIREMENTS = ">= 5.0.0".freeze
44
+ DEFAULT_GEM_VERSION_REQUIREMENTS = ">= 5.0.0"
43
45
 
44
46
  ##
45
47
  # Default tool name
46
48
  # @return [String]
47
49
  #
48
- DEFAULT_TOOL_NAME = "rdoc".freeze
50
+ DEFAULT_TOOL_NAME = "rdoc"
49
51
 
50
52
  ##
51
53
  # Default output directory
52
54
  # @return [String]
53
55
  #
54
- DEFAULT_OUTPUT_DIR = "html".freeze
56
+ DEFAULT_OUTPUT_DIR = "html"
55
57
 
56
58
  ##
57
59
  # Create the template settings for the Rdoc template.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -45,7 +47,7 @@ module Toys
45
47
  # Default tool name
46
48
  # @return [String]
47
49
  #
48
- DEFAULT_TOOL_NAME = "rubocop".freeze
50
+ DEFAULT_TOOL_NAME = "rubocop"
49
51
 
50
52
  ##
51
53
  # Create the template settings for the Rubocop template.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -39,13 +41,13 @@ module Toys
39
41
  # Default version requirements for the yard gem.
40
42
  # @return [String]
41
43
  #
42
- DEFAULT_GEM_VERSION_REQUIREMENTS = "~> 0.9".freeze
44
+ DEFAULT_GEM_VERSION_REQUIREMENTS = "~> 0.9"
43
45
 
44
46
  ##
45
47
  # Default tool name
46
48
  # @return [String]
47
49
  #
48
- DEFAULT_TOOL_NAME = "yardoc".freeze
50
+ DEFAULT_TOOL_NAME = "yardoc"
49
51
 
50
52
  ##
51
53
  # Create the template settings for the Yardoc template.
@@ -156,7 +158,7 @@ module Toys
156
158
  default: template.generate_output,
157
159
  desc: "Whether to generate output"
158
160
  else
159
- set :generate_output, template.generate_output
161
+ static :generate_output, template.generate_output
160
162
  end
161
163
 
162
164
  include :exec
@@ -178,7 +180,7 @@ module Toys
178
180
  stats_options = template.stats_options.dup
179
181
  stats_options << "--list-undoc" if template.fail_on_undocumented_objects
180
182
  run_options << "--fail-on-warning" if template.fail_on_warning
181
- run_options << "--no-output" unless get(:generate_output)
183
+ run_options << "--no-output" unless generate_output
182
184
  run_options << "--output-dir" << template.output_dir if template.output_dir
183
185
  run_options << "--no-public" unless template.show_public
184
186
  run_options << "--protected" if template.show_protected
@@ -197,20 +199,22 @@ module Toys
197
199
 
198
200
  result = exec_proc(proc { ::YARD::CLI::Yardoc.run(*run_options) })
199
201
  if result.error?
200
- puts("Yardoc encountered errors", :red, :bold) unless verbosity < 0
202
+ puts("Yardoc encountered errors", :red, :bold) unless verbosity.negative?
201
203
  exit(1)
202
204
  end
203
205
  unless stats_options.empty?
204
206
  result = exec_proc(proc { ::YARD::CLI::Stats.run(*stats_options) }, out: :capture)
205
207
  puts result.captured_out
206
208
  if result.error?
207
- puts("Yardoc encountered errors", :red, :bold) unless verbosity < 0
209
+ puts("Yardoc encountered errors", :red, :bold) unless verbosity.negative?
208
210
  exit(1)
209
211
  end
210
212
  exit_on_nonzero_status(result)
211
213
  if template.fail_on_undocumented_objects
212
214
  if result.captured_out =~ /Undocumented\sObjects:/
213
- puts("Yardoc encountered undocumented objects", :red, :bold) unless verbosity < 0
215
+ unless verbosity.negative?
216
+ puts("Yardoc encountered undocumented objects", :red, :bold)
217
+ end
214
218
  exit(1)
215
219
  end
216
220
  end
data/lib/toys/version.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright 2018 Daniel Azuma
2
4
  #
3
5
  # All rights reserved.
@@ -32,5 +34,5 @@ module Toys
32
34
  # Current version of the Toys command line binary
33
35
  # @return [String]
34
36
  #
35
- VERSION = "0.3.10".freeze
37
+ VERSION = "0.3.11"
36
38
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.10
4
+ version: 0.3.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Azuma
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-30 00:00:00.000000000 Z
11
+ date: 2018-07-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: toys-core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.10
19
+ version: 0.3.11
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.10
26
+ version: 0.3.11
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: minitest
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -135,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
- version: 2.2.0
138
+ version: 2.3.0
139
139
  required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  requirements:
141
141
  - - ">="