itamae-plugin-resource-opam 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +12 -0
- data/Dockerfile +11 -0
- data/Gemfile +6 -0
- data/README.md +50 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/itamae-plugin-resource-opam.gemspec +29 -0
- data/lib/itamae/plugin/resource/opam.rb +90 -0
- data/samples/recipe.rb +5 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e94380578ff78d07d34e226be040270a95b3a883f1a30661dfb631087d03e4da
|
4
|
+
data.tar.gz: d129c69fd20991c49579ddd385162fbe6d53d36561c317dc827845760b2dfdf5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7e6773e86181d31ce1ac32c8819fc8e152b98fe651004ce469ca9c8e28ca604709873ce197c9138bbcc445f31e31362ef1ee62220636bdc4ad93d3b2d85f5615
|
7
|
+
data.tar.gz: fe831425b20486f5bd8295b6dc4472ccfcc0f7147846dfabf6f1a35c14d8a8f10f172585ad77dba31715a85b43c1f395d45ceb0bf67f2ca67350f4415ab90d99
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Dockerfile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
FROM ruby
|
2
|
+
|
3
|
+
RUN apt-get update
|
4
|
+
RUN apt-get install -y opam
|
5
|
+
RUN opam init
|
6
|
+
RUN opam switch 4.06.0
|
7
|
+
RUN gem install bundler
|
8
|
+
ADD . /itamae-plugin-resource-opam
|
9
|
+
WORKDIR /itamae-plugin-resource-opam
|
10
|
+
RUN bundle install --path .bundle/gems
|
11
|
+
RUN bundle exec itamae local ./samples/recipe.rb
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# Itamae::Plugin::Resource::Opam [![Build Status](https://travis-ci.org/katsyoshi/itamae-plugin-resource-opam.svg?branch=master)](https://travis-ci.org/katsyoshi/itamae-plugin-resource-opam)
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/itamae/plugin/resource/opam`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'itamae-plugin-resource-opam'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install itamae-plugin-resource-opam
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
write recipe:
|
26
|
+
```ruby
|
27
|
+
require 'itamae/plugin/resource/opam'
|
28
|
+
|
29
|
+
opam "coq" do
|
30
|
+
opam_binary "/usr/local/bin/opam"
|
31
|
+
version "4.1"
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
run script:
|
36
|
+
```console
|
37
|
+
$ itamae local recipe.rb
|
38
|
+
```
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
43
|
+
|
44
|
+
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).
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/katyoshi/itamae-plugin-resource-opam. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
49
|
+
|
50
|
+
### Contributors
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "itamae/plugin/resource/opam"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "itamae-plugin-resource-opam"
|
7
|
+
spec.version = "0.1.0"
|
8
|
+
spec.authors = ["MATSUMOTO, Katsuyoshi"]
|
9
|
+
spec.email = ["github@katsyoshi.org"]
|
10
|
+
|
11
|
+
spec.summary = %q{itamae plugin for OPAM}
|
12
|
+
spec.description = %q{itamae plugin for OPAM}
|
13
|
+
spec.homepage = "https://github.com/katsyoshi/itamae-plugin-resource-opam"
|
14
|
+
|
15
|
+
# Specify which files should be added to the gem when it is released.
|
16
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
17
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
18
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_dependency "itamae"
|
25
|
+
|
26
|
+
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "rake"
|
28
|
+
spec.add_development_dependency "serverspec"
|
29
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require "itamae/resource/base"
|
2
|
+
|
3
|
+
module Itamae
|
4
|
+
module Plugin
|
5
|
+
module Resource
|
6
|
+
class Opam < Itamae::Resource::Base
|
7
|
+
define_attribute :action, default: :install
|
8
|
+
define_attribute :opam_binary, type: [String, Array], default: 'opam'
|
9
|
+
define_attribute :package_name, type: String, default_name: true
|
10
|
+
define_attribute :version, type: String, default: false
|
11
|
+
|
12
|
+
def pre_action
|
13
|
+
case @current_action
|
14
|
+
when :install
|
15
|
+
attributes.installed = true
|
16
|
+
when :uninstall
|
17
|
+
attributes.installed = false
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def set_current_attributes
|
22
|
+
installed = installed_opams.find{|opam| opam[:name] == attributes.package_name }
|
23
|
+
current.installed = !!installed
|
24
|
+
|
25
|
+
if current.installed
|
26
|
+
version = installed[:version]
|
27
|
+
current.version = version if version != attributes.version
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def action_install(action_options)
|
32
|
+
if current.installed
|
33
|
+
if attributes.version && current.version != attributes.version
|
34
|
+
action!
|
35
|
+
updated!
|
36
|
+
end
|
37
|
+
else
|
38
|
+
action!
|
39
|
+
updated!
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def action_upgrade(action_options)
|
44
|
+
return if current.installed && attributes.version && attributes.version == current.version
|
45
|
+
action!
|
46
|
+
updated!
|
47
|
+
end
|
48
|
+
|
49
|
+
def action_uninstall(action_options)
|
50
|
+
action!
|
51
|
+
updated!
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def installed_opams
|
57
|
+
opams = []
|
58
|
+
run_command([*Array(attributes.opam_binary), 'list']).stdout.each_line do |line|
|
59
|
+
name, version, *_descriptions = line.split(/\s+/)
|
60
|
+
opams << {name: name, version: version}
|
61
|
+
end
|
62
|
+
opams
|
63
|
+
rescue Backend::CommandExecutionError
|
64
|
+
[]
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_aciotn_opam_command
|
68
|
+
cmd = [*Array(attributes.opam_binary)]
|
69
|
+
case @current_action
|
70
|
+
when :install
|
71
|
+
cmd << 'install'
|
72
|
+
when :uninstall
|
73
|
+
cmd << 'uninstall'
|
74
|
+
end
|
75
|
+
cmd << '-y'
|
76
|
+
|
77
|
+
cmd << attributes.package_name if attributes.package_name
|
78
|
+
if @current_action != :switch && attributes.version
|
79
|
+
cmd[-1] = "#{attributes.package_name}.#{attributes.version}"
|
80
|
+
end
|
81
|
+
cmd
|
82
|
+
end
|
83
|
+
|
84
|
+
def action!
|
85
|
+
run_command(build_aciotn_opam_command)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
data/samples/recipe.rb
ADDED
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: itamae-plugin-resource-opam
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- MATSUMOTO, Katsuyoshi
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-09-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: itamae
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: serverspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: itamae plugin for OPAM
|
70
|
+
email:
|
71
|
+
- github@katsyoshi.org
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Dockerfile
|
79
|
+
- Gemfile
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- bin/console
|
83
|
+
- bin/setup
|
84
|
+
- itamae-plugin-resource-opam.gemspec
|
85
|
+
- lib/itamae/plugin/resource/opam.rb
|
86
|
+
- samples/recipe.rb
|
87
|
+
homepage: https://github.com/katsyoshi/itamae-plugin-resource-opam
|
88
|
+
licenses: []
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.7.6
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: itamae plugin for OPAM
|
110
|
+
test_files: []
|