├── .github_changelog_generator ├── .gitignore ├── .rspec ├── .rubocop.yml ├── .rubocop_todo.yml ├── .travis.yml ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── Gemfile ├── Gemfile.lock ├── LICENSE ├── README.md ├── Rakefile ├── lib ├── manpages.rb ├── manpages │ ├── gem_version.rb │ ├── install.rb │ ├── man_files.rb │ ├── uninstall.rb │ └── version.rb ├── rubygems │ └── commands │ │ └── manpages_command.rb └── rubygems_plugin.rb ├── manpages.gemspec ├── rbenv ├── hooks │ ├── install-man.bash │ └── version-name-change-man.bash ├── rbenv_hook_install.sh ├── remove_hook_folders.sh └── vars.sh └── spec ├── data └── man │ ├── example │ ├── example.1 │ ├── example.2 │ └── man1 │ └── extra.1 ├── manpages ├── gem_version_spec.rb ├── install_spec.rb ├── man_files_spec.rb └── uninstall_spec.rb └── spec_helper.rb /.github_changelog_generator: -------------------------------------------------------------------------------- 1 | unreleased=false 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | /.config 4 | /coverage/ 5 | /InstalledFiles 6 | /pkg/ 7 | /spec/reports/ 8 | /spec/examples.txt 9 | /test/tmp/ 10 | /test/version_tmp/ 11 | /tmp/ 12 | 13 | # Used by dotenv library to load environment variables. 14 | # .env 15 | 16 | ## Specific to RubyMotion: 17 | .dat* 18 | .repl_history 19 | build/ 20 | *.bridgesupport 21 | build-iPhoneOS/ 22 | build-iPhoneSimulator/ 23 | 24 | ## Specific to RubyMotion (use of CocoaPods): 25 | # 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 29 | # 30 | # vendor/Pods/ 31 | 32 | ## Documentation cache and generated files: 33 | /.yardoc/ 34 | /_yardoc/ 35 | /doc/ 36 | /rdoc/ 37 | 38 | ## Environment normalization: 39 | /.bundle/ 40 | /vendor/bundle 41 | /lib/bundler/man/ 42 | 43 | # for a library or gem, you might want to ignore these files since the code is 44 | # intended to run in multiple environments; otherwise, check them in: 45 | # Gemfile.lock 46 | # .ruby-version 47 | # .ruby-gemset 48 | 49 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 50 | .rvmrc 51 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | inherit_from: 2 | - .rubocop_todo.yml 3 | 4 | AllCops: 5 | TargetRubyVersion: 1.9 6 | Exclude: 7 | - tmp/**/* 8 | - lib/bundler/vendor/**/* 9 | - vendor/bundle/**/* 10 | DisplayCopNames: true 11 | 12 | # Lint 13 | 14 | # They are idiomatic 15 | Lint/AssignmentInCondition: 16 | Enabled: false 17 | 18 | Lint/EndAlignment: 19 | AlignWith: variable 20 | AutoCorrect: true 21 | 22 | Lint/UnusedMethodArgument: 23 | Enabled: false 24 | 25 | # Style 26 | 27 | Style/AccessModifierIndentation: 28 | EnforcedStyle: outdent 29 | 30 | Style/Alias: 31 | EnforcedStyle: prefer_alias_method 32 | 33 | Style/AlignParameters: 34 | EnforcedStyle: with_fixed_indentation 35 | 36 | Style/MultilineBlockChain: 37 | Enabled: false 38 | 39 | Style/MultilineOperationIndentation: 40 | EnforcedStyle: indented 41 | 42 | Style/PerlBackrefs: 43 | Enabled: false 44 | 45 | Style/SingleLineBlockParams: 46 | Enabled: false 47 | 48 | Style/SpaceInsideBlockBraces: 49 | SpaceBeforeBlockParameters: false 50 | 51 | Style/TrivialAccessors: 52 | Enabled: false 53 | 54 | # We adopted raise instead of fail. 55 | Style/SignalException: 56 | EnforcedStyle: only_raise 57 | 58 | Style/StringLiterals: 59 | EnforcedStyle: double_quotes 60 | 61 | Style/StringLiteralsInInterpolation: 62 | EnforcedStyle: double_quotes 63 | 64 | # Having these make it easier to *not* forget to add one when adding a new 65 | # value and you can simply copy the previous line. 66 | Style/TrailingCommaInLiteral: 67 | EnforcedStyleForMultiline: comma 68 | 69 | Style/TrailingUnderscoreVariable: 70 | Enabled: false 71 | 72 | # `String.new` is preferred style with enabled frozen string literal 73 | Style/EmptyLiteral: 74 | Enabled: false 75 | 76 | # 1.8.7 support 77 | 78 | Style/Lambda: 79 | Enabled: false 80 | 81 | Style/DotPosition: 82 | EnforcedStyle: trailing 83 | 84 | Style/EachWithObject: 85 | Enabled: false 86 | 87 | Style/SpecialGlobalVars: 88 | Enabled: false 89 | 90 | Style/TrailingCommaInArguments: 91 | Enabled: false 92 | 93 | Performance/FlatMap: 94 | Enabled: false 95 | 96 | # Metrics 97 | 98 | # We've chosen to use Rubocop only for style, and not for complexity or quality checks. 99 | Metrics/ClassLength: 100 | Enabled: false 101 | 102 | Metrics/ModuleLength: 103 | Enabled: false 104 | 105 | Metrics/MethodLength: 106 | Enabled: false 107 | 108 | Metrics/BlockNesting: 109 | Enabled: false 110 | 111 | Metrics/AbcSize: 112 | Enabled: false 113 | 114 | Metrics/CyclomaticComplexity: 115 | Enabled: false 116 | 117 | Metrics/ParameterLists: 118 | Enabled: false 119 | 120 | # It will be obvious which code is complex, Rubocop should only lint simple 121 | # rules for us. 122 | Metrics/PerceivedComplexity: 123 | Enabled: false 124 | -------------------------------------------------------------------------------- /.rubocop_todo.yml: -------------------------------------------------------------------------------- 1 | # This configuration was generated by 2 | # `rubocop --auto-gen-config` 3 | # on 2016-07-27 12:41:39 -0500 using RuboCop version 0.41.2. 4 | # The point is for the user to remove these configuration records 5 | # one by one as the offenses are removed from the code base. 6 | # Note that changes in the inspected code, or installation of new 7 | # versions of RuboCop, may require this file to be generated again. 8 | 9 | # Offense count: 4 10 | Lint/Eval: 11 | Exclude: 12 | - 'lib/bundler.rb' 13 | - 'lib/bundler/endpoint_specification.rb' 14 | - 'spec/support/streams.rb' 15 | 16 | # Offense count: 4 17 | Lint/HandleExceptions: 18 | Exclude: 19 | - 'lib/bundler/installer.rb' 20 | - 'lib/bundler/psyched_yaml.rb' 21 | - 'lib/bundler/vendored_persistent.rb' 22 | 23 | # Offense count: 1 24 | Lint/IneffectiveAccessModifier: 25 | Exclude: 26 | - 'lib/bundler/settings.rb' 27 | 28 | # Offense count: 3 29 | Lint/NestedMethodDefinition: 30 | Exclude: 31 | - 'lib/bundler/inline.rb' 32 | - 'spec/support/builders.rb' 33 | 34 | # Offense count: 5 35 | Lint/RescueException: 36 | Exclude: 37 | - 'lib/bundler/cli.rb' 38 | - 'lib/bundler/dsl.rb' 39 | - 'lib/bundler/friendly_errors.rb' 40 | - 'lib/bundler/rubygems_integration.rb' 41 | - 'lib/bundler/worker.rb' 42 | 43 | # Offense count: 1 44 | Lint/UselessAccessModifier: 45 | Exclude: 46 | - 'lib/bundler/fetcher.rb' 47 | 48 | # Offense count: 6 49 | Lint/UselessAssignment: 50 | Exclude: 51 | - 'lib/bundler/index.rb' 52 | - 'lib/bundler/installer.rb' 53 | 54 | # Offense count: 1686 55 | # Configuration parameters: AllowHeredoc, AllowURI, URISchemes. 56 | # URISchemes: http, https 57 | Metrics/LineLength: 58 | Max: 207 59 | 60 | # Offense count: 3 61 | # Configuration parameters: CountKeywordArgs. 62 | Metrics/ParameterLists: 63 | Max: 6 64 | 65 | # Offense count: 6 66 | # Cop supports --auto-correct. 67 | Performance/RedundantBlockCall: 68 | Exclude: 69 | - 'lib/bundler/dsl.rb' 70 | - 'lib/bundler/gem_helper.rb' 71 | - 'lib/bundler/retry.rb' 72 | - 'lib/bundler/shared_helpers.rb' 73 | - 'spec/support/helpers.rb' 74 | 75 | # Offense count: 2 76 | # Cop supports --auto-correct. 77 | Performance/RedundantMatch: 78 | Exclude: 79 | - 'lib/bundler/definition.rb' 80 | - 'lib/bundler/lockfile_parser.rb' 81 | 82 | # Offense count: 6 83 | # Cop supports --auto-correct. 84 | # Configuration parameters: MaxKeyValuePairs. 85 | Performance/RedundantMerge: 86 | Exclude: 87 | - 'lib/bundler/cli/gem.rb' 88 | - 'spec/support/helpers.rb' 89 | 90 | # Offense count: 1 91 | Style/AccessorMethodName: 92 | Exclude: 93 | - 'lib/bundler/source/git.rb' 94 | 95 | # Offense count: 3 96 | Style/CaseEquality: 97 | Exclude: 98 | - 'lib/bundler/dsl.rb' 99 | - 'lib/bundler/match_platform.rb' 100 | - 'lib/bundler/rubygems_ext.rb' 101 | 102 | # Offense count: 23 103 | # Configuration parameters: EnforcedStyle, SupportedStyles. 104 | # SupportedStyles: nested, compact 105 | Style/ClassAndModuleChildren: 106 | Enabled: false 107 | 108 | # Offense count: 10 109 | # Cop supports --auto-correct. 110 | # Configuration parameters: EnforcedStyle, SupportedStyles, SingleLineConditionsOnly. 111 | # SupportedStyles: assign_to_condition, assign_inside_condition 112 | Style/ConditionalAssignment: 113 | Exclude: 114 | - 'lib/bundler/cli.rb' 115 | - 'lib/bundler/cli/gem.rb' 116 | - 'lib/bundler/cli/lock.rb' 117 | - 'lib/bundler/cli/platform.rb' 118 | - 'lib/bundler/dsl.rb' 119 | - 'lib/bundler/lazy_specification.rb' 120 | - 'lib/bundler/psyched_yaml.rb' 121 | - 'lib/bundler/rubygems_integration.rb' 122 | - 'lib/bundler/source/git.rb' 123 | - 'lib/bundler/source/rubygems.rb' 124 | 125 | # Offense count: 138 126 | Style/Documentation: 127 | Enabled: false 128 | 129 | # Offense count: 2 130 | # Cop supports --auto-correct. 131 | # Configuration parameters: AllowForAlignment, ForceEqualSignAlignment. 132 | Style/ExtraSpacing: 133 | Exclude: 134 | - 'lib/bundler/cli.rb' 135 | 136 | # Offense count: 4 137 | # Configuration parameters: AllowedVariables. 138 | Style/GlobalVars: 139 | Exclude: 140 | - 'lib/bundler/cli.rb' 141 | - 'spec/spec_helper.rb' 142 | - 'spec/support/helpers.rb' 143 | 144 | # Offense count: 1 145 | Style/IfInsideElse: 146 | Exclude: 147 | - 'lib/bundler/cli/install.rb' 148 | 149 | # Offense count: 1 150 | Style/IfUnlessModifierOfIfUnless: 151 | Exclude: 152 | - 'spec/support/helpers.rb' 153 | 154 | # Offense count: 4 155 | # Cop supports --auto-correct. 156 | # Configuration parameters: SupportedStyles, IndentationWidth. 157 | # SupportedStyles: special_inside_parentheses, consistent, align_brackets 158 | Style/IndentArray: 159 | EnforcedStyle: consistent 160 | 161 | # Offense count: 2 162 | # Configuration parameters: EnforcedStyle, SupportedStyles. 163 | # SupportedStyles: module_function, extend_self 164 | Style/ModuleFunction: 165 | Exclude: 166 | - 'lib/bundler/shared_helpers.rb' 167 | - 'spec/support/path.rb' 168 | 169 | # Offense count: 3 170 | # Cop supports --auto-correct. 171 | # Configuration parameters: EnforcedStyle, SupportedStyles, IndentationWidth. 172 | # SupportedStyles: aligned, indented, indented_relative_to_receiver 173 | Style/MultilineMethodCallIndentation: 174 | Exclude: 175 | - 'lib/bundler/cli/common.rb' 176 | - 'spec/bundler/plugin/source_list_spec.rb' 177 | 178 | # Offense count: 3 179 | # Cop supports --auto-correct. 180 | Style/NestedParenthesizedCalls: 181 | Exclude: 182 | - 'lib/bundler/resolver.rb' 183 | - 'spec/commands/lock_spec.rb' 184 | - 'spec/runtime/setup_spec.rb' 185 | 186 | # Offense count: 9 187 | # Configuration parameters: NamePrefix, NamePrefixBlacklist, NameWhitelist. 188 | # NamePrefix: is_, has_, have_ 189 | # NamePrefixBlacklist: is_, has_, have_ 190 | # NameWhitelist: is_a? 191 | Style/PredicateName: 192 | Exclude: 193 | - 'spec/**/*' 194 | - 'lib/bundler/definition.rb' 195 | - 'lib/bundler/installer/parallel_installer.rb' 196 | - 'lib/bundler/settings.rb' 197 | - 'lib/bundler/source/git.rb' 198 | - 'lib/bundler/source/git/git_proxy.rb' 199 | - 'lib/bundler/source/path.rb' 200 | 201 | # Offense count: 25 202 | # Cop supports --auto-correct. 203 | # Configuration parameters: EnforcedStyle, SupportedStyles. 204 | # SupportedStyles: compact, exploded 205 | Style/RaiseArgs: 206 | Enabled: false 207 | 208 | # Offense count: 2 209 | # Cop supports --auto-correct. 210 | Style/RedundantParentheses: 211 | Exclude: 212 | - 'lib/bundler/cli/console.rb' 213 | - 'lib/bundler/dsl.rb' 214 | 215 | # Offense count: 1 216 | # Cop supports --auto-correct. 217 | # Configuration parameters: AllowForAlignment. 218 | Style/SpaceAroundOperators: 219 | Exclude: 220 | - 'lib/bundler/retry.rb' 221 | 222 | # Offense count: 10 223 | # Cop supports --auto-correct. 224 | # Configuration parameters: EnforcedStyleForMultiline, SupportedStyles. 225 | # SupportedStyles: comma, consistent_comma, no_comma 226 | Style/TrailingCommaInLiteral: 227 | Exclude: 228 | - 'lib/bundler/cli/gem.rb' 229 | - 'lib/bundler/dependency.rb' 230 | - 'lib/bundler/fetcher.rb' 231 | - 'lib/bundler/gem_helpers.rb' 232 | - 'lib/bundler/graph.rb' 233 | - 'lib/bundler/ruby_version.rb' 234 | - 'lib/bundler/similarity_detector.rb' 235 | - 'spec/support/artifice/endpoint.rb' 236 | 237 | # Offense count: 18 238 | # Cop supports --auto-correct. 239 | Style/UnneededInterpolation: 240 | Exclude: 241 | - 'lib/bundler/cli/config.rb' 242 | - 'lib/bundler/env.rb' 243 | - 'spec/bundler/shared_helpers_spec.rb' 244 | - 'spec/cache/git_spec.rb' 245 | - 'spec/commands/exec_spec.rb' 246 | - 'spec/support/artifice/endpoint.rb' 247 | - 'spec/support/artifice/endpoint_500.rb' 248 | - 'spec/support/fakeweb/windows.rb' 249 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.0 4 | - 2.1 5 | - 2.2 6 | - 2.3.3 7 | - 2.4.0 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | ## [0.6.1](https://github.com/bitboxer/manpages/tree/0.6.1) (2017-02-05) 4 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.6.0...0.6.1) 5 | 6 | **Merged pull requests:** 7 | 8 | - Travis: with 2.4.0, 2.3.3 [\#40](https://github.com/bitboxer/manpages/pull/40) ([olleolleolle](https://github.com/olleolleolle)) 9 | - Bugfix: require missing FileUtils [\#39](https://github.com/bitboxer/manpages/pull/39) ([olleolleolle](https://github.com/olleolleolle)) 10 | 11 | ## [0.6.0](https://github.com/bitboxer/manpages/tree/0.6.0) (2016-12-04) 12 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.5.2...0.6.0) 13 | 14 | **Closed issues:** 15 | 16 | - Flaky test because of running order of tests [\#37](https://github.com/bitboxer/manpages/issues/37) 17 | - Can't see man pages after installation [\#34](https://github.com/bitboxer/manpages/issues/34) 18 | 19 | **Merged pull requests:** 20 | 21 | - \[\#37\] Flaky test because of running order of tests [\#38](https://github.com/bitboxer/manpages/pull/38) ([bitboxer](https://github.com/bitboxer)) 22 | - Use all man pages inside `man` directory [\#36](https://github.com/bitboxer/manpages/pull/36) ([gettalong](https://github.com/gettalong)) 23 | - Fix regex for determining man page file [\#35](https://github.com/bitboxer/manpages/pull/35) ([gettalong](https://github.com/gettalong)) 24 | 25 | ## [0.5.2](https://github.com/bitboxer/manpages/tree/0.5.2) (2016-11-19) 26 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.5.0...0.5.2) 27 | 28 | **Closed issues:** 29 | 30 | - Can't set it up in ruby 2.3.2 [\#32](https://github.com/bitboxer/manpages/issues/32) 31 | 32 | **Merged pull requests:** 33 | 34 | - \[\#32\] Can't set it up in ruby 2.3.2 [\#33](https://github.com/bitboxer/manpages/pull/33) ([bitboxer](https://github.com/bitboxer)) 35 | 36 | ## [0.5.0](https://github.com/bitboxer/manpages/tree/0.5.0) (2016-11-05) 37 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.5.1...0.5.0) 38 | 39 | ## [0.5.1](https://github.com/bitboxer/manpages/tree/0.5.1) (2016-11-05) 40 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.4.0...0.5.1) 41 | 42 | **Closed issues:** 43 | 44 | - Add command that relinks all manpages of already installed gems [\#24](https://github.com/bitboxer/manpages/issues/24) 45 | 46 | **Merged pull requests:** 47 | 48 | - \[\#24\] Add command that relinks all manpages of already installed gems [\#31](https://github.com/bitboxer/manpages/pull/31) ([bitboxer](https://github.com/bitboxer)) 49 | 50 | ## [0.4.0](https://github.com/bitboxer/manpages/tree/0.4.0) (2016-11-04) 51 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.3.2...0.4.0) 52 | 53 | **Closed issues:** 54 | 55 | - chore: exclude Gemfile, Gemfile.lock from files that go into the gem [\#28](https://github.com/bitboxer/manpages/issues/28) 56 | - Add rubocop config from bundler [\#25](https://github.com/bitboxer/manpages/issues/25) 57 | - Add rbenv hook [\#2](https://github.com/bitboxer/manpages/issues/2) 58 | 59 | **Merged pull requests:** 60 | 61 | - \[\#28\] chore: exclude Gemfile, Gemfile.lock from files that go into th… [\#30](https://github.com/bitboxer/manpages/pull/30) ([bitboxer](https://github.com/bitboxer)) 62 | - \[\#2\] Add rbenv hook [\#29](https://github.com/bitboxer/manpages/pull/29) ([bitboxer](https://github.com/bitboxer)) 63 | - Refactor to Pathname, rspec shared settings [\#27](https://github.com/bitboxer/manpages/pull/27) ([olleolleolle](https://github.com/olleolleolle)) 64 | - \[\#25\] Add rubocop config from bundler [\#26](https://github.com/bitboxer/manpages/pull/26) ([bitboxer](https://github.com/bitboxer)) 65 | 66 | ## [0.3.2](https://github.com/bitboxer/manpages/tree/0.3.2) (2016-10-30) 67 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.3.1...0.3.2) 68 | 69 | **Closed issues:** 70 | 71 | - remove register command, it is not needed anymore [\#22](https://github.com/bitboxer/manpages/issues/22) 72 | 73 | **Merged pull requests:** 74 | 75 | - \[\#22\] remove register command, it is not needed anymore [\#23](https://github.com/bitboxer/manpages/pull/23) ([bitboxer](https://github.com/bitboxer)) 76 | 77 | ## [0.3.1](https://github.com/bitboxer/manpages/tree/0.3.1) (2016-10-29) 78 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.3.0...0.3.1) 79 | 80 | **Closed issues:** 81 | 82 | - Using wrong directory to save man pages [\#20](https://github.com/bitboxer/manpages/issues/20) 83 | - Add description on how to add manpages to a gem [\#18](https://github.com/bitboxer/manpages/issues/18) 84 | 85 | **Merged pull requests:** 86 | 87 | - \[\#20\] Using wrong directory to save man pages [\#21](https://github.com/bitboxer/manpages/pull/21) ([bitboxer](https://github.com/bitboxer)) 88 | - \[\#18\] Add description on how to add manpages to a gem [\#19](https://github.com/bitboxer/manpages/pull/19) ([bitboxer](https://github.com/bitboxer)) 89 | 90 | ## [0.3.0](https://github.com/bitboxer/manpages/tree/0.3.0) (2016-10-28) 91 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.2.1...0.3.0) 92 | 93 | **Closed issues:** 94 | 95 | - Remove command class [\#13](https://github.com/bitboxer/manpages/issues/13) 96 | - File.expand\_path [\#10](https://github.com/bitboxer/manpages/issues/10) 97 | - Make sure to install only the latest version of the man page [\#9](https://github.com/bitboxer/manpages/issues/9) 98 | - Do not crash if permissions don't allow creating of dirs/files [\#8](https://github.com/bitboxer/manpages/issues/8) 99 | - Do not overwrite man files [\#7](https://github.com/bitboxer/manpages/issues/7) 100 | 101 | **Merged pull requests:** 102 | 103 | - \[\#8\] Do not crash if permissions don't allow creating of dirs/files [\#17](https://github.com/bitboxer/manpages/pull/17) ([bitboxer](https://github.com/bitboxer)) 104 | - \[\#7\] Do not overwrite man files [\#16](https://github.com/bitboxer/manpages/pull/16) ([bitboxer](https://github.com/bitboxer)) 105 | - \[\#9\] Make sure to install only the latest version of the man page [\#15](https://github.com/bitboxer/manpages/pull/15) ([bitboxer](https://github.com/bitboxer)) 106 | - \[\#13\] Remove command class [\#14](https://github.com/bitboxer/manpages/pull/14) ([bitboxer](https://github.com/bitboxer)) 107 | - \[\#10\] File.expand\_path [\#11](https://github.com/bitboxer/manpages/pull/11) ([bitboxer](https://github.com/bitboxer)) 108 | 109 | ## [0.2.1](https://github.com/bitboxer/manpages/tree/0.2.1) (2016-10-08) 110 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.2.0...0.2.1) 111 | 112 | ## [0.2.0](https://github.com/bitboxer/manpages/tree/0.2.0) (2016-10-08) 113 | [Full Changelog](https://github.com/bitboxer/manpages/compare/0.1.0...0.2.0) 114 | 115 | **Closed issues:** 116 | 117 | - Uninstall man pages [\#6](https://github.com/bitboxer/manpages/issues/6) 118 | - Add chruby hook [\#5](https://github.com/bitboxer/manpages/issues/5) 119 | 120 | ## [0.1.0](https://github.com/bitboxer/manpages/tree/0.1.0) (2016-10-03) 121 | **Closed issues:** 122 | 123 | - change test suite to rspec [\#4](https://github.com/bitboxer/manpages/issues/4) 124 | - Add rvm hook [\#3](https://github.com/bitboxer/manpages/issues/3) 125 | - Find man pages and copy them [\#1](https://github.com/bitboxer/manpages/issues/1) 126 | 127 | 128 | 129 | \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | As contributors and maintainers of this project, and in the interest of 4 | fostering an open and welcoming community, we pledge to respect all people who 5 | contribute through reporting issues, posting feature requests, updating 6 | documentation, submitting pull requests or patches, and other activities. 7 | 8 | We are committed to making participation in this project a harassment-free 9 | experience for everyone, regardless of level of experience, gender, gender 10 | identity and expression, sexual orientation, disability, personal appearance, 11 | body size, race, ethnicity, age, religion, or nationality. 12 | 13 | Examples of unacceptable behavior by participants include: 14 | 15 | * The use of sexualized language or imagery 16 | * Personal attacks 17 | * Trolling or insulting/derogatory comments 18 | * Public or private harassment 19 | * Publishing other's private information, such as physical or electronic 20 | addresses, without explicit permission 21 | * Other unethical or unprofessional conduct 22 | 23 | Project maintainers have the right and responsibility to remove, edit, or 24 | reject comments, commits, code, wiki edits, issues, and other contributions 25 | that are not aligned to this Code of Conduct, or to ban temporarily or 26 | permanently any contributor for other behaviors that they deem inappropriate, 27 | threatening, offensive, or harmful. 28 | 29 | By adopting this Code of Conduct, project maintainers commit themselves to 30 | fairly and consistently applying these principles to every aspect of managing 31 | this project. Project maintainers who do not follow or enforce the Code of 32 | Conduct may be permanently removed from the project team. 33 | 34 | This code of conduct applies both within project spaces and in public spaces 35 | when an individual is representing the project or its community. 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be 38 | reported by contacting a project maintainer at bodo@wannawork.de. All 39 | complaints will be reviewed and investigated and will result in a response that 40 | is deemed necessary and appropriate to the circumstances. Maintainers are 41 | obligated to maintain confidentiality with regard to the reporter of an 42 | incident. 43 | 44 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 45 | version 1.3.0, available at 46 | [http://contributor-covenant.org/version/1/3/0/][version] 47 | 48 | [homepage]: http://contributor-covenant.org 49 | [version]: http://contributor-covenant.org/version/1/3/0/ -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | manpages (0.6.1) 5 | 6 | GEM 7 | remote: https://rubygems.org/ 8 | specs: 9 | ast (2.4.0) 10 | coderay (1.1.2) 11 | diff-lcs (1.3) 12 | jaro_winkler (1.5.4) 13 | method_source (0.9.2) 14 | parallel (1.19.1) 15 | parser (2.7.0.3) 16 | ast (~> 2.4.0) 17 | pry (0.12.2) 18 | coderay (~> 1.1.0) 19 | method_source (~> 0.9.0) 20 | rainbow (3.0.0) 21 | rake (10.5.0) 22 | rexml (3.2.4) 23 | rspec (3.9.0) 24 | rspec-core (~> 3.9.0) 25 | rspec-expectations (~> 3.9.0) 26 | rspec-mocks (~> 3.9.0) 27 | rspec-core (3.9.1) 28 | rspec-support (~> 3.9.1) 29 | rspec-expectations (3.9.0) 30 | diff-lcs (>= 1.2.0, < 2.0) 31 | rspec-support (~> 3.9.0) 32 | rspec-mocks (3.9.1) 33 | diff-lcs (>= 1.2.0, < 2.0) 34 | rspec-support (~> 3.9.0) 35 | rspec-support (3.9.2) 36 | rubocop (0.80.1) 37 | jaro_winkler (~> 1.5.1) 38 | parallel (~> 1.10) 39 | parser (>= 2.7.0.1) 40 | rainbow (>= 2.2.2, < 4.0) 41 | rexml 42 | ruby-progressbar (~> 1.7) 43 | unicode-display_width (>= 1.4.0, < 1.7) 44 | ruby-progressbar (1.10.1) 45 | unicode-display_width (1.6.1) 46 | 47 | PLATFORMS 48 | ruby 49 | 50 | DEPENDENCIES 51 | bundler (~> 1.8) 52 | manpages! 53 | pry (~> 0) 54 | rake (~> 10.0) 55 | rspec (~> 3.0) 56 | rubocop (~> 0.80.1) 57 | 58 | BUNDLED WITH 59 | 1.17.3 60 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Bodo Tasche 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Manpages 2 | 3 | [![Build Status](https://travis-ci.com/bitboxer/manpages.svg?branch=master)](https://travis-ci.com/bitboxer/manpages) 4 | [![Gem](https://img.shields.io/gem/v/manpages.svg)](https://rubygems.org/gems/manpages) 5 | 6 | This plugin will add man pages support to ruby gems. Instead 7 | of adding a new command like [gem-man](https://github.com/defunkt/gem-man) 8 | it will try to link the files to a place the `man` command automatically 9 | discovers. 10 | 11 | With rvm and chruby it works out of the box, but sadly for rbenv we need to 12 | [add hooks that](#using-this-with-rbenv) modify the `man` symlink depending on 13 | the ruby version currently used. 14 | 15 | # Installation 16 | 17 | `gem install manpages && gem manpages --update-all` 18 | 19 | This plugin automatically hooks into the ruby gems system. Every gem 20 | installed afterwards is checked for manpages. If this gem finds them, it 21 | exposes them to the `man` command. 22 | 23 | # Using this with rbenv 24 | 25 | Sadly rbenv uses shims to hide the actual executables. This makes it a bit 26 | harder to make this gem work in that environment. 27 | 28 | This gem provides hooks to change the man path for the current used ruby version. 29 | To install them execute the following line: 30 | 31 | ``` 32 | curl -o- https://raw.githubusercontent.com/bitboxer/manpages/master/rbenv/rbenv_hook_install.sh | bash 33 | ``` 34 | 35 | After the hooks are installed, rbenv will always change the man symlink to the 36 | currently used ruby version. Sadly rbenv does not provide a hook that is fired 37 | when switching ruby versions. This means that the path can only be corrected 38 | when executing a command provided by a gem. If you want to have the correct 39 | man page for a gem, you need to execute the command of that gem, first. 40 | 41 | # How this works 42 | 43 | After a gem is installed, this plugin will check for a directory called `man` within the 44 | gem and link the manpages it finds to `BIN_DIR/../share/man`, where `BIN_DIR` is the 45 | directory where the executable of the gem is installed. 46 | 47 | Most man versions will automatically search this directory and no additional work 48 | is required. If you install a gem that includes a man page (e.g. [guard](https://github.com/guard/guard)), you can 49 | simply use `man guard` and you will see the man page the gem provided. 50 | 51 | # Providing man pages with your gem 52 | 53 | The most common way in the ruby world to create a man page is through a tool 54 | called [ronn](https://github.com/rtomayko/ronn#readme). Ronn uses a modified 55 | variant of markdown as source file. More details about the format can be found 56 | [here](https://github.com/rtomayko/ronn/blob/master/man/ronn-format.7.ronn). 57 | In the newest version [kramdown](http://kramdown.gettalong.org/converter/man.html) also 58 | is able to generate man pages. 59 | 60 | Make sure the resulting manpage is in a folder called `man` in the root of the 61 | gem. Files stored in that directory will automatically be exposed to the 62 | `man` command. 63 | 64 | Examples for gems with manpages are [guard](https://github.com/guard/guard/tree/master/man) or 65 | [gem-man](https://github.com/defunkt/gem-man/tree/master/man). 66 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | require "rspec/core/rake_task" 3 | require "rubocop/rake_task" 4 | 5 | RuboCop::RakeTask.new 6 | 7 | RSpec::Core::RakeTask.new(:spec) 8 | 9 | task default: [:rubocop, :spec] 10 | -------------------------------------------------------------------------------- /lib/manpages.rb: -------------------------------------------------------------------------------- 1 | require "manpages/version" 2 | require "manpages/install" 3 | require "manpages/uninstall" 4 | require "manpages/man_files" 5 | require "manpages/gem_version" 6 | 7 | module Manpages 8 | end 9 | -------------------------------------------------------------------------------- /lib/manpages/gem_version.rb: -------------------------------------------------------------------------------- 1 | module Manpages 2 | class GemVersion 3 | def initialize(gem_spec) 4 | @gem_spec = gem_spec 5 | end 6 | 7 | def latest? 8 | latest_gem.nil? || latest_gem <= @gem_spec.version 9 | end 10 | 11 | private 12 | 13 | def latest_gem 14 | all_gem_versions.sort.last 15 | end 16 | 17 | def all_gem_versions 18 | Gem::Specification.each.select {|spec| @gem_spec.name == spec.name }.map(&:version) 19 | end 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /lib/manpages/install.rb: -------------------------------------------------------------------------------- 1 | require "fileutils" 2 | 3 | module Manpages 4 | class Install 5 | def initialize(gem_spec, gem_dir, target_dir) 6 | @gem_spec = gem_spec 7 | @gem_dir = gem_dir 8 | @target_dir = target_dir 9 | end 10 | 11 | def install_manpages 12 | link_manpages if GemVersion.new(@gem_spec).latest? 13 | end 14 | 15 | private 16 | 17 | def link_manpages 18 | ManFiles.new(@gem_dir, @target_dir).manpages.each do |file| 19 | link_manpage(file) 20 | end 21 | end 22 | 23 | def link_manpage(file) 24 | man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file) 25 | return if man_target_file.exist? 26 | 27 | begin 28 | FileUtils.mkdir_p(man_target_file.dirname) 29 | FileUtils.ln_s(file, man_target_file, force: true) 30 | rescue 31 | puts "Problems creating symlink #{man_target_file}" 32 | end 33 | end 34 | end 35 | end 36 | -------------------------------------------------------------------------------- /lib/manpages/man_files.rb: -------------------------------------------------------------------------------- 1 | require "pathname" 2 | 3 | module Manpages 4 | class ManFiles 5 | attr_reader :man_dir 6 | 7 | def initialize(gem_dir, target_dir = "") 8 | @target_dir = Pathname(target_dir) 9 | @man_dir = Pathname(File.join(gem_dir, "man")) 10 | end 11 | 12 | def manpages_present? 13 | !manpages.empty? 14 | end 15 | 16 | def manpages 17 | return [] unless man_dir.directory? 18 | 19 | Dir[man_dir.join("**/*")].select do |file| 20 | file =~ /\.\d$/ 21 | end.map {|file| Pathname.new(file) } 22 | end 23 | 24 | def man_file_path(file) 25 | man_section = file.extname.match(/\.(\d*)/) 26 | @target_dir.join("man#{man_section[1]}", file.basename) 27 | end 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /lib/manpages/uninstall.rb: -------------------------------------------------------------------------------- 1 | module Manpages 2 | class Uninstall 3 | def initialize(gem_spec, gem_dir, target_dir) 4 | @gem_spec = gem_spec 5 | @gem_dir = gem_dir 6 | @target_dir = target_dir 7 | end 8 | 9 | def uninstall_manpages 10 | unlink_manpages if GemVersion.new(@gem_spec).latest? 11 | end 12 | 13 | private 14 | 15 | def unlink_manpages 16 | ManFiles.new(@gem_dir, @target_dir).manpages.each do |file| 17 | unlink_manpage(file) 18 | end 19 | end 20 | 21 | def unlink_manpage(file) 22 | man_target_file = ManFiles.new(@gem_dir, @target_dir).man_file_path(file) 23 | FileUtils.rm(man_target_file) if man_target_file.symlink? && 24 | man_target_file.readlink == file 25 | end 26 | end 27 | end 28 | -------------------------------------------------------------------------------- /lib/manpages/version.rb: -------------------------------------------------------------------------------- 1 | module Manpages 2 | VERSION = "0.6.1".freeze 3 | end 4 | -------------------------------------------------------------------------------- /lib/rubygems/commands/manpages_command.rb: -------------------------------------------------------------------------------- 1 | class Gem::Commands::ManpagesCommand < Gem::Command 2 | include Gem::VersionOption 3 | 4 | def initialize 5 | super "manpages", "Handling manpages in gems", 6 | command: nil, 7 | version: Gem::Requirement.default, 8 | latest: false, 9 | all: false 10 | 11 | add_update_all_option 12 | end 13 | 14 | def usage 15 | "gem manpages" 16 | end 17 | 18 | def add_update_all_option 19 | add_option("-u", "--update-all", 20 | "Search for manpages in all installed gems and expose them to man") do |_, options| 21 | options[:update_all] = true 22 | end 23 | end 24 | 25 | def execute 26 | if options[:update_all] 27 | update_all 28 | else 29 | show_help 30 | end 31 | end 32 | 33 | def update_all 34 | specs = Gem::Specification.respond_to?(:each) ? Gem::Specification : Gem.source_index.gems 35 | specs.each do |*name_and_spec| 36 | spec = name_and_spec.pop 37 | next unless Manpages::ManFiles.new(spec.gem_dir).manpages_present? && 38 | Manpages::GemVersion.new(spec).latest? 39 | 40 | say "Installing man pages for #{spec.name} #{spec.version}" 41 | target_dir = File.expand_path("#{Gem.bindir}/../share/man") 42 | Manpages::Install.new(spec, spec.gem_dir, target_dir).install_manpages 43 | end 44 | end 45 | end 46 | -------------------------------------------------------------------------------- /lib/rubygems_plugin.rb: -------------------------------------------------------------------------------- 1 | require "manpages" 2 | require "rubygems/command_manager" 3 | require "rubygems/version_option" 4 | 5 | Gem::CommandManager.instance.register_command :manpages 6 | 7 | Gem.post_install do |installer| 8 | source_dir = installer.spec.gem_dir 9 | target_dir = File.expand_path("#{installer.bin_dir}/../share/man") 10 | 11 | Manpages::Install.new(installer.spec, source_dir, target_dir).install_manpages 12 | end 13 | 14 | Gem.pre_uninstall do |uninstaller| 15 | bin_dir = uninstaller.bin_dir || Gem.bindir(uninstaller.spec.base_dir) 16 | source_dir = uninstaller.spec.gem_dir 17 | target_dir = File.expand_path("#{bin_dir}/../share/man") 18 | 19 | Manpages::Uninstall.new(uninstaller.spec, source_dir, target_dir).uninstall_manpages 20 | end 21 | -------------------------------------------------------------------------------- /manpages.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | 3 | lib = File.expand_path("../lib", __FILE__) 4 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 5 | require "manpages/version" 6 | 7 | Gem::Specification.new do |spec| 8 | spec.name = "manpages" 9 | spec.version = Manpages::VERSION 10 | spec.authors = ["Bodo Tasche"] 11 | spec.email = ["bodo@tasche.me"] 12 | 13 | spec.summary = "Adds support for man pages to rubygems" 14 | spec.description = "With this gem the rubygems command will detect man pages within gems and exposes them to the man command." 15 | spec.license = "MIT" 16 | spec.homepage = "https://github.com/bitboxer/manpages" 17 | 18 | spec.files = `git ls-files -z`.split("\x0").reject do |f| 19 | f.match(%r{^(test|spec|features|Gemfile|Gemfile.lock)/}) 20 | end 21 | spec.bindir = "exe" 22 | spec.executables = spec.files.grep(%r{^exe/}) {|f| File.basename(f) } 23 | spec.require_paths = ["lib"] 24 | 25 | spec.add_development_dependency "bundler", "~> 1.8" 26 | spec.add_development_dependency "rake", "~> 10.0" 27 | spec.add_development_dependency "rspec", "~> 3.0" 28 | spec.add_development_dependency "pry", "~> 0" 29 | spec.add_development_dependency "rubocop", "~> 0.80.1" 30 | end 31 | -------------------------------------------------------------------------------- /rbenv/hooks/install-man.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if declare -Ff after_install >/dev/null; then 4 | after_install install_manpages 5 | else 6 | echo "rbenv: rbenv-default-gems plugin requires ruby-build 20130129$" 7 | fi 8 | 9 | install_manpages() { 10 | gem install manpages < /dev/null || { 11 | echo "rbenv: error installing gem 'manpages'" 12 | } >&2 13 | } 14 | -------------------------------------------------------------------------------- /rbenv/hooks/version-name-change-man.bash: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | [ -n "$RBENV_DEBUG" ] && set -x 5 | 6 | SHARE_MAN="$(rbenv root)/share" 7 | ROOT_MAN="$SHARE_MAN/man" 8 | PREFIX_MAN="$(rbenv prefix)/share/man" 9 | 10 | if [ "$(readlink $ROOT_MAN)" != "$PREFIX_MAN" ]; then 11 | [ -n "$RBENV_DEBUG" ] && echo "linking ${PREFIX_MAN} -> ${ROOT_MAN}" 12 | mkdir -p $SHARE_MAN 13 | ln -f -s $PREFIX_MAN $SHARE_MAN 14 | fi 15 | -------------------------------------------------------------------------------- /rbenv/rbenv_hook_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | SCRIPT_DIR="$( cd "$( dirname "$0" )/../" && pwd )" 4 | 5 | if [ -z $GEM_NAME ]; then 6 | GEM_NAME="manpages" 7 | fi 8 | if ! $(gem list -i "$GEM_NAME") ;then 9 | gem install "$GEM_NAME" 10 | fi 11 | 12 | if [ -n "$(command -v git)" ] && \ 13 | [ "$(basename $(git config --local remote.origin.url) 2>/dev/null)" = "manpages.git" ]; then 14 | DIR=$SCRIPT_DIR 15 | else 16 | LIB_DIR="$(dirname "$(gem which manpages)")" 17 | DIR="$(readlink -f ${LIB_DIR}/../)" 18 | fi 19 | 20 | if [ "$DIR" != "$(rbenv root)" ]; then 21 | . "${DIR}/rbenv/vars.sh" 22 | 23 | mkdir -p "${PREFIX_MAN}" 24 | 25 | mkdir -p $EXEC_HOOK_DIR 26 | mkdir -p $INSTALL_HOOK_DIR 27 | 28 | cp "${DIR}/rbenv/hooks/version-name-change-man.bash" $EXEC_HOOK_DIR/ 29 | cp "${DIR}/rbenv/hooks/install-man.bash" $INSTALL_HOOK_DIR/ 30 | 31 | ln -sf $PREFIX_MAN "${ROOT_MAN}" 32 | echo "manpages gem installed" 33 | else 34 | echo "cannot find gem folder" 35 | fi 36 | -------------------------------------------------------------------------------- /rbenv/remove_hook_folders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | DIR="$( cd "$( dirname "$0" )/../" && pwd )" 3 | 4 | . ${DIR}/rbenv/vars.sh 5 | 6 | echo "removing $ROOT_MAN" 7 | rm -rf "$ROOT_MAN" 8 | echo "removing $PREFIX_MAN" 9 | rm -rf "$PREFIX_MAN" 10 | echo "removing $INSTALL_HOOK_DIR" 11 | rm -rf "$INSTALL_HOOK_DIR" 12 | echo "removing $EXEC_HOOK_DIR" 13 | rm -rf "$EXEC_HOOK_DIR" 14 | 15 | if [ -z $GEM_NAME ]; then 16 | GEM_NAME="manpages" 17 | fi 18 | 19 | gem uninstall "$GEM_NAME" 20 | -------------------------------------------------------------------------------- /rbenv/vars.sh: -------------------------------------------------------------------------------- 1 | RBENV_ROOT=`rbenv root` 2 | 3 | PREFIX_MAN="$(rbenv prefix)/share/man" 4 | ROOT_MAN="${RBENV_ROOT}/share/man" 5 | EXEC_HOOK_DIR="${RBENV_ROOT}/plugins/manpages/etc/rbenv.d/exec" 6 | INSTALL_HOOK_DIR="${RBENV_ROOT}/plugins/manpages/etc/rbenv.d/install" 7 | -------------------------------------------------------------------------------- /spec/data/man/example: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitboxer/manpages/e46dc1f87c00583c2397fdb74c4f26226c412bd2/spec/data/man/example -------------------------------------------------------------------------------- /spec/data/man/example.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitboxer/manpages/e46dc1f87c00583c2397fdb74c4f26226c412bd2/spec/data/man/example.1 -------------------------------------------------------------------------------- /spec/data/man/example.2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitboxer/manpages/e46dc1f87c00583c2397fdb74c4f26226c412bd2/spec/data/man/example.2 -------------------------------------------------------------------------------- /spec/data/man/man1/extra.1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitboxer/manpages/e46dc1f87c00583c2397fdb74c4f26226c412bd2/spec/data/man/man1/extra.1 -------------------------------------------------------------------------------- /spec/manpages/gem_version_spec.rb: -------------------------------------------------------------------------------- 1 | require "ostruct" 2 | 3 | describe Manpages::GemVersion do 4 | context "#latest?" do 5 | it "Returns true if there is no other gem version" do 6 | gem_spec = Gem::Specification.new(name: "manpages_test") 7 | expect(Manpages::GemVersion.new(gem_spec).latest?).to be_truthy 8 | end 9 | 10 | it "Returns true if it is the newest version" do 11 | gem_spec = Gem::Specification.new("manpages_test", Gem::Version.new("0.1.0")) 12 | allow(Gem::Specification).to receive(:each).and_return([ 13 | OpenStruct.new(name: "manpages_test", version: Gem::Version.new("0.0.1")), 14 | ]) 15 | expect(Manpages::GemVersion.new(gem_spec).latest?).to be_truthy 16 | end 17 | 18 | it "Returns false if it is not the newest version of a gem" do 19 | gem_spec = Gem::Specification.new("manpages_test", Gem::Version.new("0.1.0")) 20 | allow(Gem::Specification).to receive(:each).and_return([ 21 | OpenStruct.new(name: "manpages_test", version: Gem::Version.new("1.0.0")), 22 | ]) 23 | expect(Manpages::GemVersion.new(gem_spec).latest?).to be_falsy 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/manpages/install_spec.rb: -------------------------------------------------------------------------------- 1 | require "fileutils" 2 | 3 | describe Manpages::Install do 4 | after do 5 | FileUtils.rm_r "spec/tmp" 6 | end 7 | 8 | it "copies the man pages to a correct directory structure" do 9 | Manpages::Install.new( 10 | Gem::Specification.new(name: "manpages_test"), 11 | "spec/data", 12 | "spec/tmp/man" 13 | ).install_manpages 14 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array [ 15 | "spec/tmp/man/man1", 16 | "spec/tmp/man/man1/example.1", 17 | "spec/tmp/man/man1/extra.1", 18 | "spec/tmp/man/man2", 19 | "spec/tmp/man/man2/example.2", 20 | ] 21 | end 22 | 23 | it "ignores gems without a man dir" do 24 | Manpages::Install.new( 25 | Gem::Specification.new(name: "manpages_test"), 26 | "spec/non_existent", 27 | "spec/tmp/man" 28 | ).install_manpages 29 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array [] 30 | end 31 | 32 | it "Does not install if version is too old" do 33 | expect_any_instance_of(Manpages::GemVersion).to receive(:latest?).and_return(false) 34 | Manpages::Install.new( 35 | Gem::Specification.new(name: "manpages_test"), 36 | "spec/data", 37 | "spec/tmp/man" 38 | ).install_manpages 39 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array [] 40 | end 41 | 42 | it "does not overwrite file if it is not a symlink" do 43 | FileUtils.mkdir_p "spec/tmp/man/man1" 44 | FileUtils.touch "spec/tmp/man/man1/example.1" 45 | Manpages::Install.new( 46 | Gem::Specification.new(name: "manpages_test"), 47 | "spec/data", 48 | "spec/tmp/man" 49 | ).install_manpages 50 | expect(File.symlink?("spec/tmp/man/man1/example.1")).to be_falsy 51 | end 52 | 53 | it "overwrite file if it is a symlink" do 54 | FileUtils.mkdir_p "spec/tmp/man/man1" 55 | FileUtils.ln_s("README.md", "spec/tmp/man/man1/example.1") 56 | Manpages::Install.new( 57 | Gem::Specification.new(name: "manpages_test"), 58 | "spec/data", 59 | "spec/tmp/man" 60 | ).install_manpages 61 | expect(File.symlink?("spec/tmp/man/man1/example.1")).to be_truthy 62 | expect(File.readlink("spec/tmp/man/man1/example.1")).to eql "spec/data/man/example.1" 63 | end 64 | 65 | it "handles permission problems gracefully" do 66 | FileUtils.mkdir_p("spec/tmp") 67 | FileUtils.chmod(400, "spec/tmp") 68 | 69 | expect do 70 | Manpages::Install.new( 71 | Gem::Specification.new(name: "manpages_test"), 72 | "spec/data", 73 | "spec/tmp/man", 74 | ).install_manpages 75 | end.to output( 76 | "Problems creating symlink spec/tmp/man/man1/example.1\n" \ 77 | "Problems creating symlink spec/tmp/man/man2/example.2\n" \ 78 | "Problems creating symlink spec/tmp/man/man1/extra.1\n" 79 | ).to_stdout 80 | end 81 | end 82 | -------------------------------------------------------------------------------- /spec/manpages/man_files_spec.rb: -------------------------------------------------------------------------------- 1 | require "fileutils" 2 | 3 | describe Manpages::ManFiles do 4 | context "#manpages" do 5 | it "returns a list of man files" do 6 | expect(Manpages::ManFiles.new("spec/data", "").manpages.map(&:to_s)).to match_array [ 7 | "spec/data/man/example.1", 8 | "spec/data/man/example.2", 9 | "spec/data/man/man1/extra.1", 10 | ] 11 | end 12 | end 13 | 14 | context "#man_dir" do 15 | it "returns the man directory within the gem" do 16 | expect(Manpages::ManFiles.new("spec/data", "").man_dir).to eq Pathname("spec/data/man") 17 | end 18 | end 19 | 20 | context "#manpages_present?" do 21 | it "returns true if manpages are found" do 22 | expect(Manpages::ManFiles.new("spec/data").manpages_present?).to be_truthy 23 | end 24 | 25 | it "returns false if no manpages are found" do 26 | expect(Manpages::ManFiles.new("spec/data2").manpages_present?).to be_falsy 27 | end 28 | end 29 | 30 | context "#man_file_path" do 31 | it "returns the target path of the man file" do 32 | expect( 33 | Manpages::ManFiles.new("spec/data", "spec/tmp/man").man_file_path(Pathname("example.1")) 34 | ).to eq Pathname("spec/tmp/man/man1/example.1") 35 | end 36 | end 37 | end 38 | -------------------------------------------------------------------------------- /spec/manpages/uninstall_spec.rb: -------------------------------------------------------------------------------- 1 | require "fileutils" 2 | 3 | describe Manpages::Uninstall do 4 | before :each do 5 | FileUtils.mkdir_p("spec/tmp/man/man1") 6 | end 7 | 8 | after do 9 | FileUtils.rm_r "spec/tmp" 10 | end 11 | 12 | it "Deletes a manpage if the link is to this gem" do 13 | FileUtils.ln_s("spec/data/man/example.1", "spec/tmp/man/man1/example.1") 14 | Manpages::Uninstall.new( 15 | Gem::Specification.new(name: "manpages_test"), 16 | "spec/data", 17 | "spec/tmp/man" 18 | ).uninstall_manpages 19 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array ["spec/tmp/man/man1"] 20 | end 21 | 22 | it "Does not delete a manpage if it does not link to this gem" do 23 | FileUtils.ln_s("README.md", "spec/tmp/man/man1/example.1") 24 | Manpages::Uninstall.new( 25 | Gem::Specification.new(name: "manpages_test"), 26 | "spec/non_existent", 27 | "spec/tmp/man" 28 | ).uninstall_manpages 29 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array [ 30 | "spec/tmp/man/man1", 31 | "spec/tmp/man/man1/example.1", 32 | ] 33 | end 34 | 35 | it "Does not uninstall if version is too old" do 36 | expect_any_instance_of(Manpages::GemVersion).to receive(:latest?).and_return(false) 37 | FileUtils.ln_s("spec/data/man/example.1", "spec/tmp/man/man1/example.1") 38 | Manpages::Uninstall.new( 39 | Gem::Specification.new(name: "manpages_test"), 40 | "spec/data", 41 | "spec/tmp/man" 42 | ).uninstall_manpages 43 | expect(Dir.glob("spec/tmp/man/**/*")).to match_array [ 44 | "spec/tmp/man/man1", 45 | "spec/tmp/man/man1/example.1", 46 | ] 47 | end 48 | end 49 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__) 2 | require "manpages" 3 | require "pry" 4 | 5 | require_relative "../lib/manpages" 6 | 7 | RSpec.configure do |config| 8 | config.before(:each) do 9 | FileUtils.mkdir_p("spec/tmp") 10 | end 11 | 12 | config.after(:each) do 13 | FileUtils.rm_rf("spec/tmp") 14 | end 15 | end 16 | --------------------------------------------------------------------------------