majic 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/library/majic.rb +1 -1
- data/library/majic/generator.rb +24 -6
- data/library/majic/templates/project/%underscore_name%.gemspec.tt +36 -0
- data/library/majic/templates/project/Gemfile +5 -1
- data/library/majic/templates/project/LICENSE.tt +1 -1
- data/library/majic/templates/project/library/{%downcase_name%.rb.tt → %underscore_name%.rb.tt} +1 -3
- data/library/majic/templates/project/library/%underscore_name%/version.rb.tt +11 -0
- data/library/majic/templates/project/specifications/%underscore_name%_spec.rb.tt +9 -0
- data/library/majic/templates/project/specifications/spec_helper.rb.tt +14 -0
- data/library/majic/units.rb +22 -0
- data/specifications/majic/ansi_escape_spec.rb +23 -0
- data/specifications/majic/generator_spec.rb +69 -0
- data/specifications/majic/logging_spec.rb +0 -0
- data/specifications/majic/units_spec.rb +52 -0
- data/specifications/spec_helper.rb +9 -0
- metadata +63 -8
- data/library/majic/templates/project/%downcase_name%.gemspec.tt +0 -26
- data/library/majic/templates/project/executables/%downcase_name%.rb.tt +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 089e1ac504d26a0a87d0b2c7cf660999a0bfd448
|
4
|
+
data.tar.gz: 88f44636343545a4c2c587c099e73b120f25f098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 231cfd9e88c6b7fbac141f23440c339fa499882e5a79cf07560c9086004ecad2ab0dd44621ef1fcfdb4d3a7e6916a8062d506b292ef7e8f9f8396b7734a44ee6
|
7
|
+
data.tar.gz: 6bb95635186b1dfa01d82eebf1466aae27d83f35bec579dc7cbb0f93d63f8dd1bbf043385280d8e686465b57daf1327acbef939c9c9d90e387bf6322a99d73f1
|
data/library/majic.rb
CHANGED
data/library/majic/generator.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'thor'
|
4
|
+
require 'active_support/inflector'
|
5
|
+
|
6
|
+
Inflectior = ActiveSupport::Inflector
|
4
7
|
|
5
8
|
module Majic
|
6
9
|
class Generator < Thor
|
@@ -12,18 +15,33 @@ module Majic
|
|
12
15
|
@name = name
|
13
16
|
|
14
17
|
directory 'templates/project', name
|
15
|
-
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@name.downcase
|
19
|
+
inside name do
|
20
|
+
run "bundle install"
|
21
|
+
run "git init"
|
21
22
|
end
|
23
|
+
end
|
22
24
|
|
23
|
-
|
25
|
+
no_commands do
|
26
|
+
# Return the name.
|
24
27
|
def name
|
25
28
|
@name
|
26
29
|
end
|
30
|
+
|
31
|
+
# Return the undercase version of the name.
|
32
|
+
def underscore_name
|
33
|
+
@name.underscore
|
34
|
+
end
|
35
|
+
|
36
|
+
# Return the users full name (relies on `git config`)!
|
37
|
+
def user_full_name
|
38
|
+
%x{git config --global --get user.name}.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
# Return the users e-mail address (relies on `git config`)!
|
42
|
+
def user_email_address
|
43
|
+
%x{git config --global --get user.email}.strip
|
44
|
+
end
|
27
45
|
end
|
28
46
|
end
|
29
47
|
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/gem build
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
$:.unshift File.dirname(__FILE__) + '/library'
|
5
|
+
require '<%= underscore_name %>'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
# The project description.
|
9
|
+
spec.name = "<%= underscore_name %>"
|
10
|
+
spec.version = <%= name %>::Version
|
11
|
+
spec.summary = %{No summary}
|
12
|
+
spec.description = <<-eos
|
13
|
+
No description
|
14
|
+
eos
|
15
|
+
|
16
|
+
# The project license.
|
17
|
+
spec.license "MIT"
|
18
|
+
|
19
|
+
# The author(s) full name.
|
20
|
+
spec.author = "<%= user_full_name %>"
|
21
|
+
|
22
|
+
# The author(s) e-mail address.
|
23
|
+
spec.email = "<%= user_email_address %>"
|
24
|
+
|
25
|
+
# The exported files.
|
26
|
+
spec.files = Dir["library/**/*.rb", "README.md", "LICENSE", ".yardopts"]
|
27
|
+
|
28
|
+
# The library directory.
|
29
|
+
spec.require_path = "library"
|
30
|
+
|
31
|
+
# The dependencies.
|
32
|
+
spec.add_runtime_dependency 'majic', '~> <%= Majic::Version %>'
|
33
|
+
spec.add_development_dependency 'rspec', '> 2.0'
|
34
|
+
end
|
35
|
+
|
36
|
+
# vim: set syntax=ruby
|
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) <%= Date.today.year %>,
|
1
|
+
Copyright (c) <%= Date.today.year %>, <%= user_full_name %> <<%= user_email_address %>>
|
2
2
|
|
3
3
|
Permission to use, copy, modify, and/or distribute this software for any
|
4
4
|
purpose with or without fee is hereby granted, provided that the above
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.dirname(__FILE__) + '/../library'
|
2
|
+
|
3
|
+
require '<%= underscore_name %>'
|
4
|
+
|
5
|
+
RSpec.configure do |config|
|
6
|
+
config.expect_with :rspec do |c|
|
7
|
+
c.syntax = :expect
|
8
|
+
end
|
9
|
+
|
10
|
+
# Returns the path to the directory with the fixtures.
|
11
|
+
def fixture_path
|
12
|
+
File.join File.dirname(__FILE__), 'fixtures'
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Majic
|
4
|
+
module SizeUnits
|
5
|
+
Units = %w{bytes kilobytes megabytes gigabytes terabytes}
|
6
|
+
|
7
|
+
def bytes; self end
|
8
|
+
def kilobytes; self * 1024 end
|
9
|
+
def megabytes; self * 1024 ** 2 end
|
10
|
+
def gigabytes; self * 1024 ** 3 end
|
11
|
+
def terabytes; self * 1024 ** 4 end
|
12
|
+
|
13
|
+
Units.each do |unit|
|
14
|
+
plural = unit
|
15
|
+
singular = plural.chop
|
16
|
+
|
17
|
+
alias_method singular, plural
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
Numeric.send :include, SizeUnits
|
22
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe ANSIEscape do
|
4
|
+
describe ".[]" do
|
5
|
+
it "should insert an escape sequence" do
|
6
|
+
expect(subject[:reset]).to match /\033\[([0-9;]+)m/
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should insert the requested color" do
|
10
|
+
expect(subject[:red]).to include '0;31'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe String do
|
15
|
+
describe "#ansi_escape" do
|
16
|
+
it "should call ANSIEscape.[]" do
|
17
|
+
expect(ANSIEscape).to receive(:[]).and_return("").at_least(:twice)
|
18
|
+
|
19
|
+
"hello world".ansi_escape :red
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
|
3
|
+
describe Majic::Generator do
|
4
|
+
before do
|
5
|
+
allow(subject).to receive :directory
|
6
|
+
end
|
7
|
+
|
8
|
+
describe ".namespace" do
|
9
|
+
it "should be in the generator namespace" do
|
10
|
+
expect(subject.class.namespace).to eq 'generate'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "#project" do
|
15
|
+
it "should set a project name" do
|
16
|
+
subject.project 'test-project'
|
17
|
+
|
18
|
+
expect(subject.instance_variable_get(:@name)).to eq 'test-project'
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should generate a project" do
|
22
|
+
subject.project 'test-project'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe "#downcase_name" do
|
27
|
+
it "should return the project name in lowercase" do
|
28
|
+
subject.project 'TEST-PROJECT'
|
29
|
+
|
30
|
+
expect(subject.downcase_name).to eq 'test-project'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#name" do
|
35
|
+
it "should return the project name" do
|
36
|
+
subject.project 'test-project'
|
37
|
+
|
38
|
+
expect(subject.name).to eq 'test-project'
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe "#user_full_name" do
|
43
|
+
it "should return a string" do
|
44
|
+
subject.project 'test-project'
|
45
|
+
|
46
|
+
expect(subject.user_full_name).to be_kind_of String
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should not be an empty string" do
|
50
|
+
subject.project 'test-project'
|
51
|
+
|
52
|
+
expect(subject.user_full_name).to_not be_empty
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe "#user_email_address" do
|
57
|
+
it "should return a string" do
|
58
|
+
subject.project 'test-project'
|
59
|
+
|
60
|
+
expect(subject.user_email_address).to be_kind_of String
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should not be an empty string" do
|
64
|
+
subject.project 'test-project'
|
65
|
+
|
66
|
+
expect(subject.user_email_address).to_not be_empty
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
File without changes
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'majic/units'
|
3
|
+
|
4
|
+
describe Majic::SizeUnits do
|
5
|
+
it "should include itself to Numeric" do
|
6
|
+
expect(Numeric).to include Majic::SizeUnits
|
7
|
+
end
|
8
|
+
|
9
|
+
describe Numeric do
|
10
|
+
describe "#bytes" do
|
11
|
+
it "should return the same number" do
|
12
|
+
expect(1024.bytes).to eq 1024
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#kilobytes" do
|
17
|
+
it "should return the number multiplied by kilobytes" do
|
18
|
+
expect(1000.kilobytes).to eq 1000 * 1024
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#megabytes" do
|
23
|
+
it "should return the number multiplied by megabytes" do
|
24
|
+
expect(1000.megabytes).to eq 1000 * 1024 ** 2
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe "#gigabytes" do
|
29
|
+
it "should return the number multiplied by gigabytes" do
|
30
|
+
expect(1000.gigabytes).to eq 1000 * 1024 ** 3
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe "#terabytes" do
|
35
|
+
it "should return the number multiplied by terabytes" do
|
36
|
+
expect(1000.terabytes).to eq 1000 * 1024 ** 4
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "#byte" do
|
42
|
+
it "should return the same as #bytes" do
|
43
|
+
expect(10.byte).to eq 10.bytes
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe "#megabyte" do
|
48
|
+
it "should return the same as #megabytes" do
|
49
|
+
expect(10.megabyte).to eq 10.megabytes
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: majic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mikkel Kroman
|
8
8
|
autorequire:
|
9
9
|
bindir: executables
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
13
55
|
description: Toolkit for Ruby
|
14
56
|
email: mk@uplink.io
|
15
57
|
executables:
|
@@ -22,13 +64,21 @@ files:
|
|
22
64
|
- library/majic/logging.rb
|
23
65
|
- library/majic/core_extensions/string.rb
|
24
66
|
- library/majic/core_extensions/object.rb
|
25
|
-
- library/majic/templates/project/library/%
|
26
|
-
- library/majic/templates/project/
|
67
|
+
- library/majic/templates/project/library/%underscore_name%.rb.tt
|
68
|
+
- library/majic/templates/project/library/%underscore_name%/version.rb.tt
|
69
|
+
- library/majic/templates/project/%underscore_name%.gemspec.tt
|
27
70
|
- library/majic/templates/project/LICENSE.tt
|
28
|
-
- library/majic/templates/project/%downcase_name%.gemspec.tt
|
29
71
|
- library/majic/templates/project/README.md.tt
|
30
72
|
- library/majic/templates/project/Gemfile
|
73
|
+
- library/majic/templates/project/specifications/%underscore_name%_spec.rb.tt
|
74
|
+
- library/majic/templates/project/specifications/spec_helper.rb.tt
|
31
75
|
- library/majic/ansi_escape.rb
|
76
|
+
- library/majic/units.rb
|
77
|
+
- specifications/majic/generator_spec.rb
|
78
|
+
- specifications/majic/units_spec.rb
|
79
|
+
- specifications/majic/logging_spec.rb
|
80
|
+
- specifications/majic/ansi_escape_spec.rb
|
81
|
+
- specifications/spec_helper.rb
|
32
82
|
- executables/majic
|
33
83
|
homepage: http://uplink.io
|
34
84
|
licenses:
|
@@ -49,11 +99,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
99
|
- !ruby/object:Gem::Version
|
50
100
|
version: '0'
|
51
101
|
requirements:
|
52
|
-
- '
|
102
|
+
- 'thor: if you plan to use the generator'
|
53
103
|
rubyforge_project:
|
54
104
|
rubygems_version: 2.0.3
|
55
105
|
signing_key:
|
56
106
|
specification_version: 4
|
57
107
|
summary: A set of utillities for Ruby
|
58
|
-
test_files:
|
108
|
+
test_files:
|
109
|
+
- specifications/majic/generator_spec.rb
|
110
|
+
- specifications/majic/units_spec.rb
|
111
|
+
- specifications/majic/logging_spec.rb
|
112
|
+
- specifications/majic/ansi_escape_spec.rb
|
113
|
+
- specifications/spec_helper.rb
|
59
114
|
has_rdoc:
|
@@ -1,26 +0,0 @@
|
|
1
|
-
#!/usr/bin/gem build
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
$:.unshift File.dirname(__FILE__) + '/library'
|
5
|
-
require '<%= downcase_name %>'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "<%= downcase_name %>"
|
9
|
-
spec.version = <%= name %>::Version
|
10
|
-
spec.summary = %{No summary.}
|
11
|
-
spec.description = <<-eos
|
12
|
-
No description.
|
13
|
-
eos
|
14
|
-
|
15
|
-
spec.license = "ISC"
|
16
|
-
|
17
|
-
spec.author = "John Doe"
|
18
|
-
spec.email = "john.doe@gmail.com"
|
19
|
-
|
20
|
-
spec.files = Dir["library/**/*.rb"]
|
21
|
-
spec.require_path = "library"
|
22
|
-
|
23
|
-
spec.add_dependency "majic"
|
24
|
-
end
|
25
|
-
|
26
|
-
# vim: set syntax=ruby:
|