ruby-pwsh 0.1.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45a4e8fcc1b0bf5eba64fc3798038898f082e1f2306523e197de6c801f61c872
4
- data.tar.gz: 31817197b1a07056dd1f4e6d9296eec1ceb4a39380244a9d00aa937a4ac76aa6
3
+ metadata.gz: 83a03013a6f1fd8f72b90d29d76f211cf1fbba6f32a8e5275bc7b9ce29d7a52a
4
+ data.tar.gz: 8ce907ddb3d833eec4a193ce994e05a990ccc2f20e46518674896efa14bd6328
5
5
  SHA512:
6
- metadata.gz: 5fd66bd52888d7a52bc262d2f977f6100b723531ee283aff31aec7e95ab9b0605e3fce7dcb94e34d13de4b01d0236a56b49ca60e55148e7df4a7dfee63cd8f2d
7
- data.tar.gz: 98668a759b733ddc17651011709c1070ae0b407afb84f4de356ec2b181d8353db0d5b57f1cdc64cf67039c994fb6811c679140a3177ba9e489ba72a3874032d0
6
+ metadata.gz: 71abf1b0cc94d5f742ae6240d08fff15f86e588157a4a482501f2383ac11e5f3644fb43702af5071720193303fa803debeed362bb20f2efec205b0137acb115e
7
+ data.tar.gz: b9c9ce3518e6cbc27c6b0f8126519a1c1ea53158424f72162b75e23ecd28415e80cf5df4e9dc762aadd93a99e30e16a5a91dc405cd9d8571a53184bbe04e4373
data/.gitignore CHANGED
@@ -13,3 +13,6 @@
13
13
 
14
14
  Gemfile.local
15
15
  Gemfile.lock
16
+
17
+ # build output
18
+ /ruby-pwsh-*.gem
@@ -0,0 +1,21 @@
1
+ .bundle
2
+ .yardoc
3
+ doc
4
+ .git
5
+ spec
6
+ .gitattributes
7
+ .gitignore
8
+ .rspec
9
+ .rspec_status
10
+ .rubocop.yml
11
+ .travis.yml
12
+ CODEOWNERS
13
+ CONTRIBUTING.md
14
+ design-comms.png
15
+ DESIGN.md
16
+ pwshlib.md
17
+ Gemfile
18
+ Gemfile.lock
19
+ Rakefile
20
+ ruby-pwsh.gemspec
21
+ *.gem
@@ -1,3 +1,5 @@
1
+ Gemspec/RequiredRubyVersion:
2
+ Enabled: false
1
3
  Layout/EndOfLine:
2
4
  Description: Don't enforce CRLF on Windows.
3
5
  Enabled: false
@@ -19,7 +21,7 @@ Metrics/AbcSize:
19
21
 
20
22
  # requires 2.3's squiggly HEREDOC support, which we can't use, yet
21
23
  # see http://www.virtuouscode.com/2016/01/06/about-the-ruby-squiggly-heredoc-syntax/
22
- Layout/IndentHeredoc:
24
+ Layout/HeredocIndentation:
23
25
  Enabled: false
24
26
  # Need to ignore rubocop complaining about the name of the library.
25
27
  Naming/FileName:
@@ -28,4 +30,12 @@ Naming/FileName:
28
30
  Style/RescueStandardError:
29
31
  Enabled: false
30
32
  Style/ExpandPathArguments:
31
- Enabled: false
33
+ Enabled: false
34
+ Style/Documentation:
35
+ Enabled: false
36
+ Style/ClassAndModuleChildren:
37
+ Exclude:
38
+ - lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb
39
+ Style/ClassVars:
40
+ Exclude:
41
+ - lib/puppet/provider/dsc_base_provider/dsc_base_provider.rb
@@ -19,6 +19,7 @@ script:
19
19
  - 'bundle exec rake $CHECK'
20
20
  rvm:
21
21
  - 2.5.1
22
+ - 2.7
22
23
  matrix:
23
24
  include:
24
25
  - env: CHECK="rubocop"
@@ -0,0 +1,52 @@
1
+ # Change log
2
+
3
+ All notable changes to this project will be documented in this file.The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).
4
+
5
+ ## [0.5.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.5.0) (2020-08-20)
6
+
7
+ [Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.4.1...0.5.0)
8
+
9
+ ### Added
10
+
11
+ - \(IAC-1045\) Add the DSC base Puppet provider to pwshlib [\#39](https://github.com/puppetlabs/ruby-pwsh/pull/39) ([michaeltlombardi](https://github.com/michaeltlombardi))
12
+
13
+ ## [0.4.1](https://github.com/puppetlabs/ruby-pwsh/tree/0.4.1) (2020-02-13)
14
+
15
+ [Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.4.0...0.4.1)
16
+
17
+ ### Fixed
18
+
19
+ - Ensure ruby versions older than 2.3 function correctly [\#30](https://github.com/puppetlabs/ruby-pwsh/pull/30) ([binford2k](https://github.com/binford2k))
20
+
21
+ ## [0.4.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.4.0) (2020-01-14)
22
+
23
+ [Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.3.0...0.4.0)
24
+
25
+ ### Added
26
+
27
+ - \(MODULES-10389\) Add puppet feature for dependent modules to leverage [\#20](https://github.com/puppetlabs/ruby-pwsh/pull/20) ([sanfrancrisko](https://github.com/sanfrancrisko))
28
+
29
+ ## [0.3.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.3.0) (2019-12-04)
30
+
31
+ [Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.2.0...0.3.0)
32
+
33
+ ### Added
34
+
35
+ - \(FEAT\) Add method for symbolizing hash keys [\#16](https://github.com/puppetlabs/ruby-pwsh/pull/16) ([michaeltlombardi](https://github.com/michaeltlombardi))
36
+
37
+ ### Fixed
38
+
39
+ - \(FEAT\) Ensure hash key casing methods work on arrays [\#15](https://github.com/puppetlabs/ruby-pwsh/pull/15) ([michaeltlombardi](https://github.com/michaeltlombardi))
40
+
41
+ ## [0.2.0](https://github.com/puppetlabs/ruby-pwsh/tree/0.2.0) (2019-11-26)
42
+
43
+ [Full Changelog](https://github.com/puppetlabs/ruby-pwsh/compare/0.1.0...0.2.0)
44
+
45
+ ### Added
46
+
47
+ - \(FEAT\) Add quality of life utilities [\#11](https://github.com/puppetlabs/ruby-pwsh/pull/11) ([michaeltlombardi](https://github.com/michaeltlombardi))
48
+ - \(FM-8422\) Make library releasable as a Puppet module [\#8](https://github.com/puppetlabs/ruby-pwsh/pull/8) ([michaeltlombardi](https://github.com/michaeltlombardi))
49
+
50
+
51
+
52
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
@@ -0,0 +1,155 @@
1
+ # Contributing to ruby-pwsh
2
+
3
+ So you want to contribute to the ruby-pwsh gem: Great! Below are some instructions to get you started doing
4
+ that very thing while setting expectations around code quality as well as a few tips for making the
5
+ process as easy as possible.
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Getting Started](#getting-started)
10
+ 1. [Commit Checklist](#commit-checklist)
11
+ 1. [Submission](#submission)
12
+ 1. [More about commits](#more-about-commits)
13
+ 1. [Testing](#testing)
14
+ - [Running Tests](#running-tests)
15
+ - [Writing Tests](#writing-tests)
16
+ 1. [Get Help](#get-help)
17
+
18
+ ## Getting Started
19
+
20
+ - Fork the module repository on GitHub and clone to your workspace
21
+ - Make your changes!
22
+
23
+ ## Commit Checklist
24
+
25
+ ### The Basics
26
+
27
+ - [x] my commit is a single logical unit of work
28
+ - [x] I have checked for unnecessary whitespace with "git diff --check"
29
+ - [x] my commit does not include commented out code or unneeded files
30
+
31
+ ### The Content
32
+
33
+ - [x] my commit includes tests for the bug I fixed or feature I added
34
+ - [x] my commit includes appropriate documentation changes if it is introducing a new feature or changing existing functionality
35
+ - [x] my code passes existing test suites
36
+
37
+ ### The Commit Message
38
+
39
+ - [x] the first line of my commit message includes:
40
+ - [x] an issue number (if applicable), e.g. "(GH-xxxx) This is the first line"
41
+ - [x] a short description (50 characters is the soft limit, excluding issue number(s))
42
+ - [x] the body of my commit message:
43
+ - [x] is meaningful
44
+ - [x] uses the imperative, present tense: "change", not "changed" or "changes"
45
+ - [x] includes motivation for the change, and contrasts its implementation with the previous behavior
46
+
47
+ ## Submission
48
+
49
+ ### Pre-requisites
50
+
51
+ - Make sure you have a [GitHub account](https://github.com/join)
52
+ - [Create an issue](https://github.com/puppetlabs/ruby-pwsh/issues/new/choose), or [watch the issue](https://github.com/puppetlabs/ruby-pwsh/issues) you are patching for.
53
+
54
+ ### Push and PR
55
+
56
+ - Push your changes to your fork
57
+ - [Open a Pull Request](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) against the repository in the puppetlabs organization
58
+
59
+ ## More about commits
60
+
61
+ 1. Make separate commits for logically separate changes.
62
+
63
+ Please break your commits down into logically consistent units which include new or changed tests relevant to the rest of the change.
64
+ The goal of doing this is to make the diff easier to read for whoever is reviewing your code.
65
+ In general, the easier your diff is to read, the more likely someone will be happy to review it and get it into the code base.
66
+
67
+ If you are going to refactor a piece of code, please do so as a separate commit from your feature or bug fix changes.
68
+
69
+ We also really appreciate changes that include tests to make sure the bug is not re-introduced, and that the feature is not accidentally broken.
70
+
71
+ Describe the technical detail of the change(s).
72
+ If your description starts to get too long, that is a good sign that you probably need to split up your commit into more finely grained pieces.
73
+
74
+ Commits which plainly describe the things which help reviewers check the patch and future developers understand the code are much more likely to be merged in with a minimum of bike-shedding or requested changes.
75
+ Ideally, the commit message would include information, and be in a form suitable for inclusion in the release notes for the version of Puppet that includes them.
76
+
77
+ Please also check that you are not introducing any trailing whitespace or other "whitespace errors".
78
+ You can do this by running `git diff --check` on your changes before you commit.
79
+
80
+ 2. Sending your patches
81
+
82
+ To submit your changes via a GitHub pull request, we _highly_ recommend that you have them on a topic branch, instead of directly on "master".
83
+ It makes things much easier to keep track of, especially if you decide to work on another thing before your first change is merged in.
84
+
85
+ GitHub has some pretty good [general documentation](http://help.github.com/) on using their site.
86
+ They also have documentation on [creating pull requests](https://help.github.com/articles/creating-a-pull-request-from-a-fork/).
87
+
88
+ In general, after pushing your topic branch up to your repository on GitHub, you can switch to the branch in the GitHub UI and click "Pull Request" towards the top of the page in order to open a pull request.
89
+
90
+ 3. Update the related GitHub issue.
91
+
92
+ If there is a GitHub issue associated with the change you submitted, then you should update the issue to include the location of your branch, along with any other commentary you may wish to make.
93
+
94
+ # Testing
95
+
96
+ ## Getting Started
97
+
98
+ Our Puppet modules provide [`Gemfile`](./Gemfile)s, which can tell a Ruby package manager such as [bundler](http://bundler.io/) what Ruby packages,
99
+ or Gems, are required to build, develop, and test this software.
100
+
101
+ Please make sure you have [bundler installed](http://bundler.io/#getting-started) on your system, and then use it to
102
+ install all dependencies needed for this project in the project root by running
103
+
104
+ ```shell
105
+ # Unless you're doing a release, you don't need the puppet gem group
106
+ % bundle install --path .bundle/gems --without puppet
107
+ Fetching gem metadata from https://rubygems.org/........
108
+ Fetching gem metadata from https://rubygems.org/..
109
+ Using rake (10.1.0)
110
+ Using builder (3.2.2)
111
+ -- 8><-- many more --><8 --
112
+ Your bundle is complete!
113
+ Use `bundle show [gemname]` to see where a bundled gem is installed.
114
+ ```
115
+
116
+ NOTE: some systems may require you to run this command with sudo.
117
+
118
+ If you already have those gems installed, make sure they are up-to-date:
119
+
120
+ ```shell
121
+ % bundle update
122
+ ```
123
+
124
+ ## Running Tests
125
+
126
+ With all dependencies in place and up-to-date, run the tests:
127
+
128
+ ### Unit Tests
129
+
130
+ ```shell
131
+ % bundle exec rake spec
132
+ ```
133
+
134
+ This executes all the [rspec tests](https://rspec.info/) in the `spec` directory.
135
+
136
+ ## If you have commit access to the repository
137
+
138
+ Even if you have commit access to the repository, you still need to go through the process above, and have someone else review and merge
139
+ in your changes.
140
+ The rule is that **all changes must be reviewed by a project developer that did not write the code to ensure that all changes go through a code review process.**
141
+
142
+ The record of someone performing the merge is the record that they performed the code review.
143
+ Again, this should be someone other than the author of the topic branch.
144
+
145
+ ## Get Help
146
+
147
+ ### On the web
148
+
149
+ - [General GitHub documentation](http://help.github.com/)
150
+ - [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
151
+
152
+ ### On chat
153
+
154
+ - Slack (slack.puppet.com) #forge-modules, #puppet-dev, #windows, #voxpupuli
155
+ - IRC (freenode) #puppet-dev, #voxpupuli
data/Gemfile CHANGED
@@ -11,27 +11,26 @@ group :test do
11
11
  gem 'rspec', '~> 3.0'
12
12
  gem 'rspec-collection_matchers', '~> 1.0'
13
13
  gem 'rspec-its', '~> 1.0'
14
- gem 'rubocop'
14
+ gem 'rubocop', '>= 0.77'
15
15
  gem 'rubocop-rspec'
16
16
  gem 'simplecov'
17
17
  end
18
18
 
19
19
  group :development do
20
- # TODO: Use gem instead of git. Section mapping is merged into master, but not yet released
21
- gem 'github_changelog_generator', git: 'https://github.com/skywinder/github-changelog-generator.git', ref: '20ee04ba1234e9e83eb2ffb5056e23d641c7a018'
20
+ gem 'github_changelog_generator', '~> 1.15' if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.3.0')
22
21
  gem 'yard'
23
22
  end
24
23
 
24
+ group :puppet do
25
+ gem 'pdk', '~> 1.0'
26
+ gem 'puppet'
27
+ end
28
+
25
29
  group :pry do
26
30
  gem 'fuubar'
27
31
 
28
- if RUBY_VERSION == '1.8.7'
29
- gem 'debugger'
30
- elsif RUBY_VERSION =~ /^2\.[01]/
31
- gem 'byebug', '~> 9.0.0'
32
+ if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.4.0')
32
33
  gem 'pry-byebug'
33
- elsif RUBY_VERSION =~ /^2\.[23456789]/
34
- gem 'pry-byebug' # rubocop:disable Bundler/DuplicatedGem
35
34
  else
36
35
  gem 'pry-debugger'
37
36
  end
data/README.md CHANGED
@@ -60,10 +60,60 @@ ps_version = posh.execute('[String]$PSVersionTable.PSVersion')[:stdout].strip
60
60
  pp("The PowerShell version of the currently running Manager is #{ps_version}")
61
61
  ```
62
62
 
63
+ ## Reference
64
+
65
+ You can find the full reference documentation online, [here](https://rubydoc.info/gems/ruby-pwsh).
66
+
63
67
  <!-- ## Development
64
68
 
65
69
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
66
70
 
67
71
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). -->
68
72
 
73
+ ## Releasing the Gem and Puppet Module
74
+
75
+ Steps to release an update to the gem and module include:
76
+
77
+ 1. Ensure that the release branch is up to date with the master:
78
+ ```bash
79
+ git push upstream upstream/master:release --force
80
+ ```
81
+ 1. Checkout a new working branch for the release prep (where xyz is the appropriate version, sans periods):
82
+ ```bash
83
+ git checkout -b maint/release/prep-xyz upstream/release
84
+ ```
85
+ 1. Update the version in `lib/pwsh/version.rb` and `metadata.json` to the appropriate version for the new release.
86
+ 1. Run the changelog update task (make sure to verify the changelog, correctly tagging PRs as needed):
87
+ ```bash
88
+ bundle exec rake changelog
89
+ ```
90
+ 1. Commit your changes with a short, sensible commit message, like:
91
+ ```text
92
+ git add lib/pwsh/version.rb
93
+ git add metadata.json
94
+ git add CHANGELOG.md
95
+ git commit -m '(MAINT) Prep for x.y.z release'
96
+ ```
97
+ 1. Push your changes and submit a pull request for review _against the **release** branch_:
98
+ ```bash
99
+ git push -u origin maint/release-prep-xyz
100
+ ```
101
+ 1. Ensure tests pass and the code is merged to `release`.
102
+ 1. Grab the commit hash from the merge commit on release, use that as the tag for the version (replacing `x.y.z` with the appropriate version and `commithash` with the relevant one), then push the tags to upstream:
103
+ ```bash
104
+ bundle exec rake tag['x.y.z', 'commithash']
105
+ ```
106
+ 1. Build the Ruby gem and publish:
107
+ ```bash
108
+ bundle exec rake build
109
+ bundle exec rake push['ruby-pwsh-x.y.z.gem']
110
+ ```
111
+ 1. Verify that the correct version now exists on [RubyGems](https://rubygems.org/search?query=ruby-pwsh)
112
+ 1. Build the Puppet module:
113
+ ```bash
114
+ bundle exec rake build_module
115
+ ```
116
+ 1. Publish the updated module version (found in the `pkg` folder) to [the Forge](https://forge.puppet.com/puppetlabs/pwshlib).
117
+ 1. Submit the [mergeback PR from the release branch to master](https://github.com/puppetlabs/ruby-pwsh/compare/master...release).
118
+
69
119
  ## Known Issues
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rubocop/rake_task'
4
+ require 'fileutils'
4
5
  require 'github_changelog_generator/task'
6
+ require 'open3'
5
7
  require 'pwsh/version'
6
8
  require 'rspec/core/rake_task'
7
9
  require 'yard'
@@ -10,8 +12,8 @@ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
10
12
  config.user = 'puppetlabs'
11
13
  config.project = 'ruby-pwsh'
12
14
  config.future_release = Pwsh::VERSION
13
- config.since_tag = '0.0.1'
14
- config.exclude_labels = ['maintenance']
15
+ config.since_tag = '0.1.0'
16
+ config.exclude_labels = ['maint']
15
17
  config.header = "# Change log\n\nAll notable changes to this project will be documented in this file." \
16
18
  'The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org).'
17
19
  config.add_pr_wo_labels = true
@@ -42,3 +44,57 @@ task default: :spec
42
44
 
43
45
  YARD::Rake::YardocTask.new do |t|
44
46
  end
47
+
48
+ # Executes a command locally.
49
+ #
50
+ # @param command [String] command to execute.
51
+ # @return [Object] the standard out stream.
52
+ def run_local_command(command)
53
+ stdout, stderr, status = Open3.capture3(command)
54
+ error_message = "Attempted to run\ncommand:'#{command}'\nstdout:#{stdout}\nstderr:#{stderr}"
55
+ raise error_message unless status.to_i.zero?
56
+
57
+ stdout
58
+ end
59
+
60
+ # Build the gem
61
+ desc 'Build the gem'
62
+ task :build do
63
+ gemspec_path = File.join(Dir.pwd, 'ruby-pwsh.gemspec')
64
+ run_local_command("bundle exec gem build '#{gemspec_path}'")
65
+ end
66
+
67
+ # Tag the repo with a version in preparation for the release
68
+ #
69
+ # @param :version [String] a semantic version to tag the code with
70
+ # @param :sha [String] the sha at which to apply the version tag
71
+ desc 'Tag the repo with a version in preparation for release'
72
+ task :tag, [:version, :sha] do |_task, args|
73
+ raise "Invalid version #{args[:version]} - must be like '1.2.3'" unless args[:version] =~ /^\d+\.\d+\.\d+$/
74
+
75
+ run_local_command('git fetch upstream')
76
+ run_local_command("git tag -a #{args[:version]} -m #{args[:version]} #{args[:sha]}")
77
+ run_local_command('git push upstream --tags')
78
+ end
79
+
80
+ # Push the built gem to RubyGems
81
+ #
82
+ # @param :path [String] optional, the full or relative path to the built gem to be pushed
83
+ desc 'Push to RubyGems'
84
+ task :push, [:path] do |_task, args|
85
+ raise 'No discoverable gem for pushing' if Dir.glob("ruby-pwsh*\.gem").empty? && args[:path].nil?
86
+ raise "No file found at specified path: '#{args[:path]}'" unless File.exist?(args[:path])
87
+
88
+ path = args[:path] || File.join(Dir.pwd, Dir.glob("ruby-pwsh*\.gem")[0])
89
+ run_local_command("bundle exec gem push #{path}")
90
+ end
91
+
92
+ desc 'Build for Puppet'
93
+ task :build_module do
94
+ actual_readme_content = File.read('README.md')
95
+ FileUtils.copy_file('pwshlib.md', 'README.md')
96
+ # Build
97
+ run_local_command('pdk build --force')
98
+ # Cleanup
99
+ File.open('README.md', 'wb') { |file| file.write(actual_readme_content) }
100
+ end