nem 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8a7945839cd5f9f9b686a2ff82ba0ad421c4bd1e
4
+ data.tar.gz: ef991e709c4e106526149871f3bb114a46d10922
5
+ SHA512:
6
+ metadata.gz: 43b78cf65df55b70f85155810a4ac5dfbed356d3ead7ce0f4a203c7c724739cd98e61dfc71d60b8edd1a3561b7bef75b5914bd9e9895559f5ea254b00cb7b9bb
7
+ data.tar.gz: b22e3ce683e0163ae683a13bf0b29eada3fc880f5507473ffaff063c4f311e22c9e4ad92856f1eb7d99bdae066416e63cc4654ee0bf9fb1288711e61ee334ff5
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+
4
+ script: bundle exec ruby spec/nem_spec.rb
5
+
6
+ rvm:
7
+ - 2.2
8
+ - 2.1
9
+ - 2.0
10
+ - rbx-2
11
+ - jruby-head
12
+ - jruby-9000
13
+
@@ -0,0 +1,6 @@
1
+ ## CHANGELOG
2
+
3
+ ### 1.0.0
4
+
5
+ * Inital release
6
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'minitest'
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Jan Lelis, mail@janlelis.de
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,65 @@
1
+ # nem [![[gem]](https://badge.fury.io/rb/nem.svg)](https://badge.fury.io/rb/nem) [![[npm]](https://img.shields.io/npm/v/nem.svg)](https://www.npmjs.com/package/nem)
2
+
3
+ Contrary to common belief, npm[https://www.npmjs.com/] does not stand for "node package manager". In fact it is a [package make installer](https://docs.npmjs.com/misc/faq#if-npm-is-an-acronym-why-is-it-never-capitalized), which just happens to be written in node. Hence it is not only meant to be used for node (or iojs[https://iojs.org/]) modules. It is also great for command-line tools written in Ruby!
4
+
5
+ ## Install
6
+
7
+ Either via rubygems:
8
+
9
+ $ gem install nem
10
+
11
+ Or via npm:
12
+
13
+ $ npm install -g nem
14
+
15
+ ## Usage
16
+
17
+ * Build your Ruby CLI gem as usual
18
+ * Don't use any dependencies (other than included in Ruby's standard library)
19
+ * Write your gemspec (example: [nem.gemspec](https://github.com/janlelis/nem/blob/master/nem.gemspec))
20
+ * Run the following command to generate a `package.json` file:
21
+
22
+ $ nem
23
+
24
+ * Optional: Command-line arguments to `nem` will be interpreted as keywords for npm's search
25
+ * That's it. Only step left: Publish it on the rubygems & npm public registries
26
+
27
+ nem's own [package.json](https://github.com/janlelis/nem/blob/master/package.json) was generated by:
28
+
29
+ $ nem ruby gem npm
30
+
31
+ ## Install it locally
32
+ ### Via npm
33
+
34
+ [Instructions](https://docs.npmjs.com/cli/install). In short:
35
+
36
+ $ npm install .
37
+
38
+ ### Via rubygems
39
+
40
+ [Instructions](http://guides.rubygems.org/make-your-own-gem/). In short:
41
+
42
+ $ gem build *.gemspec
43
+ $ gem install *.gem
44
+
45
+ (replace * with the actual gem name)
46
+
47
+ ## Publish
48
+ ### On npm
49
+
50
+ [Instructions](https://docs.npmjs.com/cli/publish). In short:
51
+
52
+ $ npm publish .
53
+
54
+ ### On rubygems
55
+
56
+ [Instructions](http://guides.rubygems.org/publishing/#publishing-to-rubygemsorg). In short:
57
+
58
+ $ gem build *.gemspec
59
+ $ gem push *.gem
60
+
61
+ (replace * with the actual gem name)
62
+
63
+ ## Legal
64
+
65
+ nem is relaesed under the MIT license. npm is © npm, Inc. nem is not affiliated with npm in any way.
@@ -0,0 +1,22 @@
1
+ gemspec_file = Dir['*.gemspec'].first
2
+ gemspec = eval File.read(gemspec_file), binding, gemspec_file
3
+ info = "#{gemspec.name} | #{gemspec.version} | " \
4
+ "#{gemspec.runtime_dependencies.size} dependencies | " \
5
+ "#{gemspec.files.size} files"
6
+
7
+ desc info
8
+ task :gem do
9
+ puts info + "\n\n"
10
+ print " "; sh "gem build #{gemspec_file}"
11
+ FileUtils.mkdir_p 'pkg'
12
+ FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
13
+ puts; sh %{gem install --no-document pkg/#{gemspec.name}-#{gemspec.version}.gem}
14
+ end
15
+
16
+ desc "#{gemspec.name} | SPECS"
17
+ task :specs do
18
+ ruby "spec/*"
19
+ end
20
+
21
+ task default: :specs
22
+
data/bin/nem ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/nem'
4
+
5
+ Nem.new($stdin.tty?, *ARGV).run
@@ -0,0 +1,65 @@
1
+ require_relative "nem/version"
2
+
3
+ require "json"
4
+
5
+ class Nem
6
+ def initialize(tty = false, *keywords)
7
+ @keywords = keywords
8
+ @tty = tty
9
+
10
+ if @tty
11
+ @gemspec_file = Dir['*.gemspec'].first
12
+
13
+ unless File.file?(@gemspec_file)
14
+ raise ArgumentError, "no gemspec in your current directory found"
15
+ end
16
+
17
+ gemspec_content = File.read(@gemspec_file)
18
+ else
19
+ @gemspec_file = '-'
20
+ gemspec_content = $stdin.read
21
+ end
22
+
23
+ @gemspec = eval gemspec_content, binding, @gemspec_file
24
+ end
25
+
26
+ def validate
27
+ unless @gemspec.runtime_dependencies.empty?
28
+ raise ArgumentError, 'dependencies are not supported'
29
+ end
30
+
31
+ if @gemspec.executables.empty?
32
+ raise ArgumentError, "you must specify at least one executable"
33
+ end
34
+ end
35
+
36
+ def run
37
+ validate
38
+ if @tty
39
+ File.write "package.json", generate
40
+ puts "Converted #@gemspec_file to package.json"
41
+ else
42
+ puts generate
43
+ end
44
+ end
45
+
46
+ def generate
47
+ JSON.pretty_generate(
48
+ "name" => @gemspec.name,
49
+ "version" => @gemspec.version,
50
+ "description" => @gemspec.description,
51
+ "homepage" => @gemspec.homepage,
52
+ "author" => {
53
+ "name" => @gemspec.author || Array(@gemspec.authors).first,
54
+ "email" => Array(@gemspec.email).first,
55
+ },
56
+ "keywords" => ["nem", *@keywords],
57
+ "preferGlobal" => true,
58
+ "bin" => Hash[@gemspec.executables.map{ |bin|
59
+ [File.basename(bin), "bin/#{File.basename(bin)}"]
60
+ }],
61
+ "license" => @gemspec.license
62
+ )
63
+ end
64
+ end
65
+
@@ -0,0 +1,4 @@
1
+ class Nem
2
+ VERSION = "1.0.0".freeze
3
+ end
4
+
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + "/lib/nem/version"
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "nem"
7
+ gem.version = Nem::VERSION
8
+ gem.summary = "npm + gem = nem"
9
+ gem.description = "npm + gem = nem: Publish dependency free Ruby CLI gems on npm"
10
+ gem.authors = ["Jan Lelis"]
11
+ gem.email = ["mail@janlelis.de"]
12
+ gem.homepage = "https://github.com/janlelis/nem"
13
+ gem.license = "MIT"
14
+
15
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.required_ruby_version = "~> 2.0"
21
+ end
@@ -0,0 +1,21 @@
1
+ {
2
+ "name": "nem",
3
+ "version": "1.0.0",
4
+ "description": "npm + gem = nem: Publish dependency free Ruby CLI gems on npm",
5
+ "homepage": "https://github.com/janlelis/nem",
6
+ "author": {
7
+ "name": "Jan Lelis",
8
+ "email": "mail@janlelis.de"
9
+ },
10
+ "keywords": [
11
+ "nem",
12
+ "ruby",
13
+ "gem",
14
+ "npm"
15
+ ],
16
+ "preferGlobal": true,
17
+ "bin": {
18
+ "nem": "bin/nem"
19
+ },
20
+ "license": "MIT"
21
+ }
@@ -0,0 +1,49 @@
1
+ require "minitest/autorun"
2
+ require "shellwords"
3
+
4
+ describe "nem" do
5
+ it "takes a gemspec and generates a package.json out of it" do
6
+ assert_equal <<PACKAGE_JSON, `echo #{<<NEM_GEMSPEC.shellescape} | #{File.dirname(__FILE__)}/../bin/nem ruby gem npm`
7
+ {
8
+ "name": "nem",
9
+ "version": "1.0.0",
10
+ "description": "Publish dependency free Ruby CLI gems on npm",
11
+ "homepage": "https://github.com/janlelis/nem",
12
+ "author": {
13
+ "name": "Jan Lelis",
14
+ "email": "mail@janlelis.de"
15
+ },
16
+ "keywords": [
17
+ "nem",
18
+ "ruby",
19
+ "gem",
20
+ "npm"
21
+ ],
22
+ "preferGlobal": true,
23
+ "bin": {
24
+ "nem": "bin/nem"
25
+ },
26
+ "license": "MIT"
27
+ }
28
+ PACKAGE_JSON
29
+ Gem::Specification.new do |gem|
30
+ gem.name = "nem"
31
+ gem.version = "1.0.0"
32
+ gem.summary = "npm + gem = nem"
33
+ gem.description = "Publish dependency free Ruby CLI gems on npm"
34
+ gem.authors = ["Jan Lelis"]
35
+ gem.email = ["mail@janlelis.de"]
36
+ gem.homepage = "https://github.com/janlelis/nem"
37
+ gem.license = "MIT"
38
+
39
+ gem.files = Dir["{**/}{.*,*}"].select{ |path| File.file?(path) && path !~ /^pkg/ }
40
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
41
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
42
+ gem.require_paths = ["lib"]
43
+
44
+ gem.required_ruby_version = "~> 2.0"
45
+ end
46
+ NEM_GEMSPEC
47
+ end
48
+ end
49
+
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nem
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-01 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: 'npm + gem = nem: Publish dependency free Ruby CLI gems on npm'
14
+ email:
15
+ - mail@janlelis.de
16
+ executables:
17
+ - nem
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - ".gitignore"
22
+ - ".travis.yml"
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - Gemfile.lock
26
+ - MIT-LICENSE.txt
27
+ - README.md
28
+ - Rakefile
29
+ - bin/nem
30
+ - lib/nem.rb
31
+ - lib/nem/version.rb
32
+ - nem.gemspec
33
+ - package.json
34
+ - spec/nem_spec.rb
35
+ homepage: https://github.com/janlelis/nem
36
+ licenses:
37
+ - MIT
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubyforge_project:
55
+ rubygems_version: 2.4.6
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: npm + gem = nem
59
+ test_files:
60
+ - spec/nem_spec.rb
61
+ has_rdoc: