bloc 0.0.1
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.
- data/.gitignore +4 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/README.md +11 -0
- data/Rakefile +1 -0
- data/bin/bloc +15 -0
- data/bloc.gemspec +24 -0
- data/lib/bloc.rb +10 -0
- data/lib/bloc/command.rb +6 -0
- data/lib/bloc/command/validate.rb +22 -0
- data/lib/bloc/version.rb +3 -0
- data/spec/command/validate_spec.rb +30 -0
- data/spec/spec_helper.rb +3 -0
- metadata +148 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.2@bloc-gem --create
|
data/Gemfile
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/bloc
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "rubygems"
|
4
|
+
require "bundler/setup"
|
5
|
+
require "bloc"
|
6
|
+
|
7
|
+
if ARGV.length == 1 && ARGV.first == "validate"
|
8
|
+
begin
|
9
|
+
Bloc::Command::Validate.run
|
10
|
+
rescue => e
|
11
|
+
puts e
|
12
|
+
end
|
13
|
+
else
|
14
|
+
raise "Usage: bloc validate"
|
15
|
+
end
|
data/bloc.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require "./lib/bloc/version"
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "bloc"
|
6
|
+
s.version = Bloc::VERSION
|
7
|
+
s.authors = ["Roshan Choxi"]
|
8
|
+
s.email = ["roshan.choxi@gmail.com"]
|
9
|
+
s.summary = %q{A CLI For Bloc}
|
10
|
+
s.description = %q{A command-line tool for Bloc}
|
11
|
+
|
12
|
+
s.rubyforge_project = "bloc"
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
|
19
|
+
s.add_development_dependency "rspec"
|
20
|
+
s.add_development_dependency "fakefs"
|
21
|
+
s.add_development_dependency "ruby-debug19"
|
22
|
+
s.add_runtime_dependency "json"
|
23
|
+
s.add_runtime_dependency "colorize"
|
24
|
+
end
|
data/lib/bloc.rb
ADDED
data/lib/bloc/command.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Bloc
|
2
|
+
module Command
|
3
|
+
class Validate
|
4
|
+
MANIFEST_NOT_FOUND = "Unable to find Bloc Manifest in bloc/bloc_manifest.json".red
|
5
|
+
MANIFEST_PATH = File.join("bloc", "bloc_manifest.json")
|
6
|
+
INVALID_MANIFEST = "Invalid JSON in Bloc Manifest: #{MANIFEST_PATH}".red
|
7
|
+
VALID_MANIFEST = "Valid Bloc Monifest".green
|
8
|
+
|
9
|
+
def self.run(*args)
|
10
|
+
raise MANIFEST_NOT_FOUND unless File.exists?(MANIFEST_PATH)
|
11
|
+
manifest= File.read(MANIFEST_PATH)
|
12
|
+
|
13
|
+
begin
|
14
|
+
JSON.parse(manifest)
|
15
|
+
puts VALID_MANIFEST
|
16
|
+
rescue
|
17
|
+
raise INVALID_MANIFEST
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
data/lib/bloc/version.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "./spec/spec_helper"
|
2
|
+
require "fakefs"
|
3
|
+
require "stringio"
|
4
|
+
|
5
|
+
module Bloc::Command
|
6
|
+
describe Validate do
|
7
|
+
it "raises an exception if the Bloc manifest can not be found" do
|
8
|
+
lambda { Validate.run() }.should raise_error(Validate::MANIFEST_NOT_FOUND)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "raises an exception if the Bloc manifest has invalid JSON" do
|
12
|
+
FileUtils.mkdir_p("bloc")
|
13
|
+
File.open(Validate::MANIFEST_PATH, 'w+') {|f| f.write "<<invalid json>>" }
|
14
|
+
|
15
|
+
lambda { Validate.run() }.should raise_error(Validate::INVALID_MANIFEST)
|
16
|
+
end
|
17
|
+
|
18
|
+
it "prints a success message if the manifest is valid" do
|
19
|
+
FileUtils.mkdir_p("bloc")
|
20
|
+
File.open(Validate::MANIFEST_PATH, 'w+') {|f| f.write %Q({"json": "true" }) }
|
21
|
+
|
22
|
+
out = StringIO.new
|
23
|
+
$stdout = out
|
24
|
+
Validate.run()
|
25
|
+
$stdout = STDOUT
|
26
|
+
out.string.chomp.should == Validate::VALID_MANIFEST
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bloc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Roshan Choxi
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-01 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :development
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: fakefs
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: ruby-debug19
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :development
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: json
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 3
|
71
|
+
segments:
|
72
|
+
- 0
|
73
|
+
version: "0"
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: colorize
|
78
|
+
prerelease: false
|
79
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
hash: 3
|
85
|
+
segments:
|
86
|
+
- 0
|
87
|
+
version: "0"
|
88
|
+
type: :runtime
|
89
|
+
version_requirements: *id005
|
90
|
+
description: A command-line tool for Bloc
|
91
|
+
email:
|
92
|
+
- roshan.choxi@gmail.com
|
93
|
+
executables:
|
94
|
+
- bloc
|
95
|
+
extensions: []
|
96
|
+
|
97
|
+
extra_rdoc_files: []
|
98
|
+
|
99
|
+
files:
|
100
|
+
- .gitignore
|
101
|
+
- .rvmrc
|
102
|
+
- Gemfile
|
103
|
+
- README.md
|
104
|
+
- Rakefile
|
105
|
+
- bin/bloc
|
106
|
+
- bloc.gemspec
|
107
|
+
- lib/bloc.rb
|
108
|
+
- lib/bloc/command.rb
|
109
|
+
- lib/bloc/command/validate.rb
|
110
|
+
- lib/bloc/version.rb
|
111
|
+
- spec/command/validate_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage:
|
114
|
+
licenses: []
|
115
|
+
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 3
|
127
|
+
segments:
|
128
|
+
- 0
|
129
|
+
version: "0"
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
none: false
|
132
|
+
requirements:
|
133
|
+
- - ">="
|
134
|
+
- !ruby/object:Gem::Version
|
135
|
+
hash: 3
|
136
|
+
segments:
|
137
|
+
- 0
|
138
|
+
version: "0"
|
139
|
+
requirements: []
|
140
|
+
|
141
|
+
rubyforge_project: bloc
|
142
|
+
rubygems_version: 1.8.17
|
143
|
+
signing_key:
|
144
|
+
specification_version: 3
|
145
|
+
summary: A CLI For Bloc
|
146
|
+
test_files:
|
147
|
+
- spec/command/validate_spec.rb
|
148
|
+
- spec/spec_helper.rb
|