gram 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Gemfile.lock +75 -2
- data/bin/gram +6 -1
- data/gram.gemspec +5 -0
- data/lib/gram.rb +4 -1
- data/lib/gram/blog.rb +45 -3
- data/lib/gram/blog/parser.rb +1 -4
- data/lib/gram/gem.rb +30 -0
- data/lib/gram/gem/generator.rb +62 -0
- data/lib/gram/gem/templates/Rakefile.tt +47 -0
- data/lib/gram/gem/templates/Readme.tt +38 -0
- data/lib/gram/gem/templates/gitignore.tt +6 -0
- data/lib/gram/gem/templates/rvmrc.tt +1 -0
- data/lib/gram/gem/templates/spec/spec_helper.tt +18 -0
- data/lib/gram/version.rb +1 -1
- data/spec/gram/blog/parser_spec.rb +5 -3
- data/spec/gram/blog_spec.rb +29 -3
- data/spec/gram/gem/generator_spec.rb +96 -0
- data/spec/gram/gem_spec.rb +17 -0
- metadata +75 -26
data/.gitignore
ADDED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,77 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
gram (0.0
|
4
|
+
gram (0.1.0)
|
5
|
+
activesupport
|
6
|
+
i18n
|
5
7
|
rest-client
|
8
|
+
thor
|
6
9
|
|
7
10
|
GEM
|
8
11
|
remote: http://rubygems.org/
|
9
12
|
specs:
|
13
|
+
abstract (1.0.0)
|
14
|
+
actionmailer (3.0.5)
|
15
|
+
actionpack (= 3.0.5)
|
16
|
+
mail (~> 2.2.15)
|
17
|
+
actionpack (3.0.5)
|
18
|
+
activemodel (= 3.0.5)
|
19
|
+
activesupport (= 3.0.5)
|
20
|
+
builder (~> 2.1.2)
|
21
|
+
erubis (~> 2.6.6)
|
22
|
+
i18n (~> 0.4)
|
23
|
+
rack (~> 1.2.1)
|
24
|
+
rack-mount (~> 0.6.13)
|
25
|
+
rack-test (~> 0.5.7)
|
26
|
+
tzinfo (~> 0.3.23)
|
27
|
+
activemodel (3.0.5)
|
28
|
+
activesupport (= 3.0.5)
|
29
|
+
builder (~> 2.1.2)
|
30
|
+
i18n (~> 0.4)
|
31
|
+
activerecord (3.0.5)
|
32
|
+
activemodel (= 3.0.5)
|
33
|
+
activesupport (= 3.0.5)
|
34
|
+
arel (~> 2.0.2)
|
35
|
+
tzinfo (~> 0.3.23)
|
36
|
+
activeresource (3.0.5)
|
37
|
+
activemodel (= 3.0.5)
|
38
|
+
activesupport (= 3.0.5)
|
39
|
+
activesupport (3.0.5)
|
40
|
+
arel (2.0.9)
|
41
|
+
builder (2.1.2)
|
10
42
|
diff-lcs (1.1.2)
|
43
|
+
erubis (2.6.6)
|
44
|
+
abstract (>= 1.0.0)
|
45
|
+
generator_spec (0.8.2)
|
46
|
+
rails (~> 3.0)
|
47
|
+
rspec-rails
|
48
|
+
i18n (0.5.0)
|
49
|
+
mail (2.2.15)
|
50
|
+
activesupport (>= 2.3.6)
|
51
|
+
i18n (>= 0.4.0)
|
52
|
+
mime-types (~> 1.16)
|
53
|
+
treetop (~> 1.4.8)
|
11
54
|
mime-types (1.16)
|
55
|
+
polyglot (0.3.1)
|
56
|
+
rack (1.2.2)
|
57
|
+
rack-mount (0.6.13)
|
58
|
+
rack (>= 1.0.0)
|
59
|
+
rack-test (0.5.7)
|
60
|
+
rack (>= 1.0)
|
61
|
+
rails (3.0.5)
|
62
|
+
actionmailer (= 3.0.5)
|
63
|
+
actionpack (= 3.0.5)
|
64
|
+
activerecord (= 3.0.5)
|
65
|
+
activeresource (= 3.0.5)
|
66
|
+
activesupport (= 3.0.5)
|
67
|
+
bundler (~> 1.0)
|
68
|
+
railties (= 3.0.5)
|
69
|
+
railties (3.0.5)
|
70
|
+
actionpack (= 3.0.5)
|
71
|
+
activesupport (= 3.0.5)
|
72
|
+
rake (>= 0.8.7)
|
73
|
+
thor (~> 0.14.4)
|
74
|
+
rake (0.8.7)
|
12
75
|
rest-client (1.6.1)
|
13
76
|
mime-types (>= 1.16)
|
14
77
|
rspec (2.5.0)
|
@@ -19,12 +82,22 @@ GEM
|
|
19
82
|
rspec-expectations (2.5.0)
|
20
83
|
diff-lcs (~> 1.1.2)
|
21
84
|
rspec-mocks (2.5.0)
|
85
|
+
rspec-rails (2.5.0)
|
86
|
+
actionpack (~> 3.0)
|
87
|
+
activesupport (~> 3.0)
|
88
|
+
railties (~> 3.0)
|
89
|
+
rspec (~> 2.5.0)
|
90
|
+
thor (0.14.6)
|
91
|
+
treetop (1.4.9)
|
92
|
+
polyglot (>= 0.3.1)
|
93
|
+
tzinfo (0.3.25)
|
22
94
|
|
23
95
|
PLATFORMS
|
24
96
|
ruby
|
25
97
|
|
26
98
|
DEPENDENCIES
|
99
|
+
activemodel
|
27
100
|
bundler (~> 1.0.7)
|
101
|
+
generator_spec (~> 0.8.1)
|
28
102
|
gram!
|
29
|
-
rest-client
|
30
103
|
rspec (~> 2.5.0)
|
data/bin/gram
CHANGED
@@ -3,8 +3,13 @@ $: << 'lib'
|
|
3
3
|
require 'gram'
|
4
4
|
|
5
5
|
component = ARGV.shift
|
6
|
+
action = ARGV.shift
|
6
7
|
args = ARGV
|
7
8
|
|
8
9
|
raise "Unknown Gram component. Available components are: #{Gram::COMPONENTS.join(', ')}" unless Gram::COMPONENTS.include?(component)
|
9
10
|
|
10
|
-
eval("Gram::#{component.capitalize}")
|
11
|
+
component_klass = eval("Gram::#{component.capitalize}")
|
12
|
+
|
13
|
+
raise "Unknown action for #{component} component.\n#{component_klass.banner}\n" unless component_klass::ACTIONS.keys.map(&:to_s).include?(action)
|
14
|
+
|
15
|
+
component_klass.send(action, *args)
|
data/gram.gemspec
CHANGED
@@ -15,9 +15,14 @@ Gem::Specification.new do |s|
|
|
15
15
|
s.rubyforge_project = "gram"
|
16
16
|
|
17
17
|
s.add_runtime_dependency 'rest-client'
|
18
|
+
s.add_runtime_dependency 'thor'
|
19
|
+
s.add_runtime_dependency 'i18n'
|
20
|
+
s.add_runtime_dependency 'activesupport'
|
18
21
|
|
19
22
|
s.add_development_dependency 'bundler', '~> 1.0.7'
|
20
23
|
s.add_development_dependency 'rspec', '~> 2.5.0'
|
24
|
+
s.add_development_dependency 'generator_spec', '~> 0.8.1'
|
25
|
+
s.add_development_dependency 'activemodel'
|
21
26
|
|
22
27
|
s.files = `git ls-files`.split("\n")
|
23
28
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
data/lib/gram.rb
CHANGED
data/lib/gram/blog.rb
CHANGED
@@ -1,19 +1,61 @@
|
|
1
1
|
require 'rest-client'
|
2
|
+
require 'json'
|
2
3
|
|
3
4
|
module Gram
|
4
5
|
module Blog
|
6
|
+
|
7
|
+
ACTIONS = { upload: {
|
8
|
+
description: "Uploads the markdown file with filename FILE",
|
9
|
+
arguments: %w(FILE),
|
10
|
+
},
|
11
|
+
download: {
|
12
|
+
description: "Downloads all blog posts to the current folder.",
|
13
|
+
arguments: %w(),
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
5
17
|
class << self
|
6
18
|
|
7
|
-
def
|
8
|
-
|
19
|
+
def banner
|
20
|
+
out = "Available actions:\n"
|
21
|
+
ACTIONS.each_pair do |action, metadata|
|
22
|
+
out << "\n\t#{action} #{metadata[:arguments].join(' ')}\t\t#{metadata[:description]}"
|
23
|
+
end
|
24
|
+
out
|
25
|
+
end
|
26
|
+
|
27
|
+
# ACTIONS
|
28
|
+
|
29
|
+
def upload(file)
|
9
30
|
raise "File #{file} does not exist." unless File.exists?(file)
|
10
|
-
puts "Gram::Blog
|
31
|
+
puts "Gram::Blog uploading..."
|
11
32
|
post = Parser.parse(file)
|
12
33
|
response = RestClient.post("http://codegram.com/api/posts", token: get_token, post: post )
|
13
34
|
puts "Response Code: #{response.code}"
|
14
35
|
puts "Response Body: #{response.body}"
|
15
36
|
end
|
16
37
|
|
38
|
+
def download
|
39
|
+
posts = JSON.parse(RestClient.get("http://codegram.com/api/posts?token=#{get_token}"))
|
40
|
+
posts.each do |post|
|
41
|
+
post = post["post"]
|
42
|
+
header = """
|
43
|
+
---
|
44
|
+
title: #{post["title"]}
|
45
|
+
tagline: #{post["tagline"]}
|
46
|
+
---
|
47
|
+
|
48
|
+
""".strip
|
49
|
+
puts "Downloading #{post["cached_slug"]}.markdown..."
|
50
|
+
File.open("#{post["cached_slug"]}.markdown", 'w') do |f|
|
51
|
+
f.write header
|
52
|
+
f.write "\n\n"
|
53
|
+
f.write post["body"]
|
54
|
+
f.write "\n"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
17
59
|
private
|
18
60
|
|
19
61
|
def get_token
|
data/lib/gram/blog/parser.rb
CHANGED
@@ -10,12 +10,9 @@ module Gram
|
|
10
10
|
headers = raw_content.match(/---(.*)---/m)
|
11
11
|
yaml = YAML.load($1.strip)
|
12
12
|
|
13
|
-
title = yaml["title"]
|
14
|
-
tagline = yaml["tagline"]
|
15
|
-
|
16
13
|
content = raw_content.gsub(/---.*---/m, '').strip
|
17
14
|
|
18
|
-
{
|
15
|
+
yaml.update({ 'body' => content })
|
19
16
|
end
|
20
17
|
|
21
18
|
end
|
data/lib/gram/gem.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Gram
|
2
|
+
module Gem
|
3
|
+
|
4
|
+
ACTIONS = { create: {
|
5
|
+
description: "Creates a new gem with the given NAME",
|
6
|
+
arguments: %w(NAME [--rails]),
|
7
|
+
},
|
8
|
+
}
|
9
|
+
|
10
|
+
class << self
|
11
|
+
|
12
|
+
def banner
|
13
|
+
out = "Available actions:\n"
|
14
|
+
ACTIONS.each_pair do |action, metadata|
|
15
|
+
out << "\n\t#{action} #{metadata[:arguments].join(' ')}\t\t#{metadata[:description]}"
|
16
|
+
end
|
17
|
+
out
|
18
|
+
end
|
19
|
+
|
20
|
+
# ACTIONS
|
21
|
+
|
22
|
+
def create(name, *options)
|
23
|
+
puts "Gram::Gem generating gem scaffold for #{name}..."
|
24
|
+
Generator.new.generate(name, options)
|
25
|
+
puts "Generated on ./#{name} :)"
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'active_support/inflector'
|
3
|
+
|
4
|
+
module Gram
|
5
|
+
module Gem
|
6
|
+
class Generator < Thor
|
7
|
+
include Thor::Actions
|
8
|
+
|
9
|
+
source_root File.dirname(__FILE__)
|
10
|
+
|
11
|
+
no_tasks do
|
12
|
+
def generate(name, options)
|
13
|
+
@rails = true if options.include?("--rails")
|
14
|
+
@underscored = name.underscore
|
15
|
+
@camelized = name.camelize
|
16
|
+
|
17
|
+
run "bundle gem #{@underscored}"
|
18
|
+
|
19
|
+
remove_file("#{@underscored}/Rakefile")
|
20
|
+
template('templates/Rakefile.tt', "#{@underscored}/Rakefile")
|
21
|
+
|
22
|
+
remove_file("#{@underscored}/.gitignore")
|
23
|
+
template('templates/gitignore.tt', "#{@underscored}/.gitignore")
|
24
|
+
|
25
|
+
template('templates/Readme.tt', "#{@underscored}/Readme.md")
|
26
|
+
template('templates/rvmrc.tt', "#{@underscored}/.rvmrc")
|
27
|
+
|
28
|
+
empty_directory "#{@underscored}/spec"
|
29
|
+
template('templates/spec/spec_helper.tt', "#{@underscored}/spec/spec_helper.rb")
|
30
|
+
|
31
|
+
inject_into_file "#{@underscored}/#{@underscored}.gemspec", :after => "s.rubyforge_project = \"#{@underscored}\"" do
|
32
|
+
runtime_dependencies = []
|
33
|
+
runtime_dependencies << " s.add_runtime_dependency 'activerecord', '~> 3.0.5'" if rails
|
34
|
+
|
35
|
+
development_dependencies = []
|
36
|
+
development_dependencies << " s.add_runtime_dependency 'sqlite3'" if rails
|
37
|
+
development_dependencies += [
|
38
|
+
" s.add_development_dependency 'rspec', '~> 2.5.0'",
|
39
|
+
" s.add_development_dependency 'yard'",
|
40
|
+
" s.add_development_dependency 'bluecloth'" ]
|
41
|
+
|
42
|
+
"\n\n" + runtime_dependencies.join("\n") << "\n\n"<< development_dependencies.join("\n")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def underscored
|
50
|
+
@underscored
|
51
|
+
end
|
52
|
+
|
53
|
+
def camelized
|
54
|
+
@camelized
|
55
|
+
end
|
56
|
+
|
57
|
+
def rails
|
58
|
+
@rails
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
desc "Run <%= underscored %> specs"
|
6
|
+
RSpec::Core::RakeTask.new
|
7
|
+
|
8
|
+
require 'yard'
|
9
|
+
YARD::Rake::YardocTask.new(:docs) do |t|
|
10
|
+
t.files = ['lib/**/*.rb']
|
11
|
+
t.options = ['-m', 'markdown', '--no-private', '-r', 'Readme.md', '--title', '<%= camelized %> documentation']
|
12
|
+
end
|
13
|
+
|
14
|
+
site = 'doc'
|
15
|
+
source_branch = 'master'
|
16
|
+
deploy_branch = 'gh-pages'
|
17
|
+
|
18
|
+
desc "generate and deploy documentation website to github pages"
|
19
|
+
multitask :pages do
|
20
|
+
puts ">>> Deploying #{deploy_branch} branch to Github Pages <<<"
|
21
|
+
require 'git'
|
22
|
+
repo = Git.open('.')
|
23
|
+
puts "\n>>> Checking out #{deploy_branch} branch <<<\n"
|
24
|
+
repo.branch("#{deploy_branch}").checkout
|
25
|
+
(Dir["*"] - [site]).each { |f| rm_rf(f) }
|
26
|
+
Dir["#{site}/*"].each {|f| mv(f, "./")}
|
27
|
+
rm_rf(site)
|
28
|
+
puts "\n>>> Moving generated site files <<<\n"
|
29
|
+
Dir["**/*"].each {|f| repo.add(f) }
|
30
|
+
repo.status.deleted.each {|f, s| repo.remove(f)}
|
31
|
+
puts "\n>>> Commiting: Site updated at #{Time.now.utc} <<<\n"
|
32
|
+
message = ENV["MESSAGE"] || "Site updated at #{Time.now.utc}"
|
33
|
+
repo.commit(message)
|
34
|
+
puts "\n>>> Pushing generated site to #{deploy_branch} branch <<<\n"
|
35
|
+
repo.push
|
36
|
+
puts "\n>>> Github Pages deploy complete <<<\n"
|
37
|
+
repo.branch("#{source_branch}").checkout
|
38
|
+
end
|
39
|
+
|
40
|
+
task :doc => [:docs]
|
41
|
+
|
42
|
+
desc "Generate and open class diagram (needs Graphviz installed)"
|
43
|
+
task :graph do |t|
|
44
|
+
`bundle exec yard graph -d --full --no-private | dot -Tpng -o graph.png && open graph.png`
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => [:spec]
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#<%= underscored %>
|
2
|
+
|
3
|
+
<%= camelized %> is a lightweight gem aimed at saving the world.
|
4
|
+
|
5
|
+
##Install
|
6
|
+
|
7
|
+
$ gem install <%= underscored %>
|
8
|
+
|
9
|
+
Or in your Gemfile:
|
10
|
+
|
11
|
+
gem '<%= underscored %>'
|
12
|
+
|
13
|
+
##Usage
|
14
|
+
|
15
|
+
(usage instructions)
|
16
|
+
|
17
|
+
##Under the hood
|
18
|
+
|
19
|
+
Run the test suite by typing:
|
20
|
+
|
21
|
+
rake spec
|
22
|
+
|
23
|
+
You can also build the documentation with the following command:
|
24
|
+
|
25
|
+
rake docs
|
26
|
+
|
27
|
+
## Note on Patches/Pull Requests
|
28
|
+
|
29
|
+
* Fork the project.
|
30
|
+
* Make your feature addition or bug fix.
|
31
|
+
* Add tests for it. This is important so I don't break it in a
|
32
|
+
future version unintentionally.
|
33
|
+
* Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
34
|
+
* Send us a pull request. Bonus points for topic branches.
|
35
|
+
|
36
|
+
## Copyright
|
37
|
+
|
38
|
+
Copyright (c) 2011 Codegram. See LICENSE for details.
|
@@ -0,0 +1 @@
|
|
1
|
+
rvm --create use ruby-1.9.2@<%= underscored %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require '<%= underscored %>'
|
3
|
+
<% if rails %>
|
4
|
+
|
5
|
+
ActiveRecord::Base.establish_connection(
|
6
|
+
:adapter => 'sqlite3',
|
7
|
+
:database => ':memory:'
|
8
|
+
)
|
9
|
+
|
10
|
+
ActiveRecord::Schema.define do
|
11
|
+
create_table :articles do |t|
|
12
|
+
t.string :name
|
13
|
+
t.integer :price
|
14
|
+
|
15
|
+
t.timestamps
|
16
|
+
end
|
17
|
+
end
|
18
|
+
<% end %>
|
data/lib/gram/version.rb
CHANGED
@@ -11,6 +11,7 @@ module Gram
|
|
11
11
|
---
|
12
12
|
title: My title
|
13
13
|
tagline: My tagline
|
14
|
+
published: false
|
14
15
|
---
|
15
16
|
|
16
17
|
#My post
|
@@ -19,9 +20,10 @@ Blah
|
|
19
20
|
"""
|
20
21
|
File.stub(:read).with(file).and_return raw
|
21
22
|
|
22
|
-
subject.parse(file).should == { title
|
23
|
-
tagline
|
24
|
-
|
23
|
+
subject.parse(file).should == { 'title' => 'My title',
|
24
|
+
'tagline' => 'My tagline',
|
25
|
+
'published' => false,
|
26
|
+
'body' => "#My post\n#\nBlah"}
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
data/spec/gram/blog_spec.rb
CHANGED
@@ -7,11 +7,11 @@ module Gram
|
|
7
7
|
File.stub(:exists?).and_return true
|
8
8
|
end
|
9
9
|
|
10
|
-
describe ".
|
10
|
+
describe ".upload" do
|
11
11
|
it 'parses the file' do
|
12
12
|
subject::Parser.should_receive(:parse).with("my_post.md")
|
13
13
|
expect {
|
14
|
-
subject.
|
14
|
+
subject.upload("my_post.md")
|
15
15
|
}.to raise_error(RestClient::InternalServerError)
|
16
16
|
end
|
17
17
|
it 'sends a post request' do
|
@@ -23,7 +23,33 @@ module Gram
|
|
23
23
|
|
24
24
|
RestClient.should_receive(:post).with("http://codegram.com/api/posts", token: token, post: post).and_return response
|
25
25
|
|
26
|
-
subject.
|
26
|
+
subject.upload("my_post.md")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe ".download" do
|
31
|
+
it 'gets the posts' do
|
32
|
+
RestClient.stub(:get)
|
33
|
+
JSON.should_receive(:parse).and_return [ { "post" => {
|
34
|
+
"title" => "My title",
|
35
|
+
"tagline" => "My tagline",
|
36
|
+
"cached_slug" => "my-post",
|
37
|
+
"body" => "#Hello world"
|
38
|
+
} } ]
|
39
|
+
|
40
|
+
file = double(:file)
|
41
|
+
File.should_receive(:open).with('my-post.markdown', 'w').and_yield file
|
42
|
+
file.should_receive(:write).with """
|
43
|
+
---
|
44
|
+
title: My title
|
45
|
+
tagline: My tagline
|
46
|
+
---
|
47
|
+
""".strip
|
48
|
+
file.should_receive(:write).with "\n\n"
|
49
|
+
file.should_receive(:write).with "#Hello world"
|
50
|
+
file.should_receive(:write).with "\n"
|
51
|
+
|
52
|
+
subject.download
|
27
53
|
end
|
28
54
|
end
|
29
55
|
|
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
require 'action_view'
|
5
|
+
require 'action_controller'
|
6
|
+
ActionView::Template::Handlers::ERB::ENCODING_FLAG = ActionView::ENCODING_FLAG
|
7
|
+
|
8
|
+
require 'generator_spec/test_case'
|
9
|
+
|
10
|
+
module Gram
|
11
|
+
module Gem
|
12
|
+
describe Generator do
|
13
|
+
include GeneratorSpec::TestCase
|
14
|
+
destination File.expand_path('../../../../tmp', __FILE__)
|
15
|
+
tests Generator
|
16
|
+
|
17
|
+
before(:each) do
|
18
|
+
prepare_destination
|
19
|
+
end
|
20
|
+
|
21
|
+
after(:each) do
|
22
|
+
FileUtils.rm_rf File.expand_path('../../../../tmp', __FILE__)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'is a Thor generator' do
|
26
|
+
Generator.ancestors.should include(Thor)
|
27
|
+
end
|
28
|
+
|
29
|
+
describe ".generate" do
|
30
|
+
it 'creates a new gem' do
|
31
|
+
FileUtils.chdir File.expand_path('../../../../tmp', __FILE__)
|
32
|
+
Generator.new.generate('my_gem', [])
|
33
|
+
destination_root.should have_structure {
|
34
|
+
directory "my_gem" do
|
35
|
+
file "Gemfile"
|
36
|
+
file "Rakefile"
|
37
|
+
file ".gitignore"
|
38
|
+
file ".rvmrc"
|
39
|
+
file "Readme.md"
|
40
|
+
file "my_gem.gemspec" do
|
41
|
+
contains "rspec"
|
42
|
+
contains "yard"
|
43
|
+
contains "bluecloth"
|
44
|
+
end
|
45
|
+
directory "lib" do
|
46
|
+
file "my_gem.rb"
|
47
|
+
directory "my_gem" do
|
48
|
+
file "version.rb"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
directory "spec" do
|
52
|
+
file "spec_helper.rb"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
}
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'with --rails' do
|
59
|
+
it 'creates a new rails-ready gem' do
|
60
|
+
FileUtils.chdir File.expand_path('../../../../tmp', __FILE__)
|
61
|
+
Generator.new.generate('my_gem', ['--rails'])
|
62
|
+
destination_root.should have_structure {
|
63
|
+
directory "my_gem" do
|
64
|
+
file "Gemfile"
|
65
|
+
file "Rakefile"
|
66
|
+
file ".gitignore"
|
67
|
+
file ".rvmrc"
|
68
|
+
file "Readme.md"
|
69
|
+
file "my_gem.gemspec" do
|
70
|
+
contains "activerecord"
|
71
|
+
contains "sqlite3"
|
72
|
+
|
73
|
+
contains "rspec"
|
74
|
+
contains "yard"
|
75
|
+
contains "bluecloth"
|
76
|
+
end
|
77
|
+
directory "lib" do
|
78
|
+
file "my_gem.rb"
|
79
|
+
directory "my_gem" do
|
80
|
+
file "version.rb"
|
81
|
+
end
|
82
|
+
end
|
83
|
+
directory "spec" do
|
84
|
+
file "spec_helper.rb" do
|
85
|
+
contains "ActiveRecord"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
}
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module Gram
|
4
|
+
describe Gem do
|
5
|
+
|
6
|
+
describe ".create" do
|
7
|
+
it 'calls a gem generator' do
|
8
|
+
generator = mock(Gem::Generator)
|
9
|
+
Gem::Generator.should_receive(:new).and_return generator
|
10
|
+
generator.should_receive(:generate).with('my_gem', ['--rails'])
|
11
|
+
|
12
|
+
subject.create 'my_gem', '--rails'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gram
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Josep M. Bach
|
@@ -16,7 +12,7 @@ autorequire:
|
|
16
12
|
bindir: bin
|
17
13
|
cert_chain: []
|
18
14
|
|
19
|
-
date: 2011-
|
15
|
+
date: 2011-03-21 00:00:00 +01:00
|
20
16
|
default_executable:
|
21
17
|
dependencies:
|
22
18
|
- !ruby/object:Gem::Dependency
|
@@ -27,41 +23,86 @@ dependencies:
|
|
27
23
|
requirements:
|
28
24
|
- - ">="
|
29
25
|
- !ruby/object:Gem::Version
|
30
|
-
segments:
|
31
|
-
- 0
|
32
26
|
version: "0"
|
33
27
|
type: :runtime
|
34
28
|
version_requirements: *id001
|
35
29
|
- !ruby/object:Gem::Dependency
|
36
|
-
name:
|
30
|
+
name: thor
|
37
31
|
prerelease: false
|
38
32
|
requirement: &id002 !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "0"
|
38
|
+
type: :runtime
|
39
|
+
version_requirements: *id002
|
40
|
+
- !ruby/object:Gem::Dependency
|
41
|
+
name: i18n
|
42
|
+
prerelease: false
|
43
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: "0"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id003
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: activesupport
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id004
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: bundler
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
39
66
|
none: false
|
40
67
|
requirements:
|
41
68
|
- - ~>
|
42
69
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 1
|
45
|
-
- 0
|
46
|
-
- 7
|
47
70
|
version: 1.0.7
|
48
71
|
type: :development
|
49
|
-
version_requirements: *
|
72
|
+
version_requirements: *id005
|
50
73
|
- !ruby/object:Gem::Dependency
|
51
74
|
name: rspec
|
52
75
|
prerelease: false
|
53
|
-
requirement: &
|
76
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
54
77
|
none: false
|
55
78
|
requirements:
|
56
79
|
- - ~>
|
57
80
|
- !ruby/object:Gem::Version
|
58
|
-
segments:
|
59
|
-
- 2
|
60
|
-
- 5
|
61
|
-
- 0
|
62
81
|
version: 2.5.0
|
63
82
|
type: :development
|
64
|
-
version_requirements: *
|
83
|
+
version_requirements: *id006
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: generator_spec
|
86
|
+
prerelease: false
|
87
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ~>
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 0.8.1
|
93
|
+
type: :development
|
94
|
+
version_requirements: *id007
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: activemodel
|
97
|
+
prerelease: false
|
98
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
type: :development
|
105
|
+
version_requirements: *id008
|
65
106
|
description: Internal client for Codegram administration
|
66
107
|
email:
|
67
108
|
- info@codegram.com
|
@@ -72,6 +113,7 @@ extensions: []
|
|
72
113
|
extra_rdoc_files: []
|
73
114
|
|
74
115
|
files:
|
116
|
+
- .gitignore
|
75
117
|
- .rspec
|
76
118
|
- .rvmrc
|
77
119
|
- Gemfile
|
@@ -83,9 +125,18 @@ files:
|
|
83
125
|
- lib/gram.rb
|
84
126
|
- lib/gram/blog.rb
|
85
127
|
- lib/gram/blog/parser.rb
|
128
|
+
- lib/gram/gem.rb
|
129
|
+
- lib/gram/gem/generator.rb
|
130
|
+
- lib/gram/gem/templates/Rakefile.tt
|
131
|
+
- lib/gram/gem/templates/Readme.tt
|
132
|
+
- lib/gram/gem/templates/gitignore.tt
|
133
|
+
- lib/gram/gem/templates/rvmrc.tt
|
134
|
+
- lib/gram/gem/templates/spec/spec_helper.tt
|
86
135
|
- lib/gram/version.rb
|
87
136
|
- spec/gram/blog/parser_spec.rb
|
88
137
|
- spec/gram/blog_spec.rb
|
138
|
+
- spec/gram/gem/generator_spec.rb
|
139
|
+
- spec/gram/gem_spec.rb
|
89
140
|
- spec/gram_spec.rb
|
90
141
|
- spec/spec_helper.rb
|
91
142
|
has_rdoc: true
|
@@ -102,26 +153,24 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
153
|
requirements:
|
103
154
|
- - ">="
|
104
155
|
- !ruby/object:Gem::Version
|
105
|
-
segments:
|
106
|
-
- 0
|
107
156
|
version: "0"
|
108
157
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
158
|
none: false
|
110
159
|
requirements:
|
111
160
|
- - ">="
|
112
161
|
- !ruby/object:Gem::Version
|
113
|
-
segments:
|
114
|
-
- 0
|
115
162
|
version: "0"
|
116
163
|
requirements: []
|
117
164
|
|
118
165
|
rubyforge_project: gram
|
119
|
-
rubygems_version: 1.
|
166
|
+
rubygems_version: 1.5.2
|
120
167
|
signing_key:
|
121
168
|
specification_version: 3
|
122
169
|
summary: Internal client for Codegram administration
|
123
170
|
test_files:
|
124
171
|
- spec/gram/blog/parser_spec.rb
|
125
172
|
- spec/gram/blog_spec.rb
|
173
|
+
- spec/gram/gem/generator_spec.rb
|
174
|
+
- spec/gram/gem_spec.rb
|
126
175
|
- spec/gram_spec.rb
|
127
176
|
- spec/spec_helper.rb
|