CarmineContraption 0.0.6 → 0.1.0

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.
@@ -0,0 +1,14 @@
1
+ require 'aws/s3'
2
+
3
+ module CarmineContraption
4
+ class Uploader
5
+ def initialize connection_args={}, target_bucket
6
+ AWS::S3::Base.establish_connection! connection_args
7
+ @target_bucket = target_bucket
8
+ end
9
+
10
+ def upload media
11
+ AWS::S3::S3Object.store(media.remote_path, open(media.local_path), @target_bucket, :access => :public_read, 'Cache-Control' => 'max-age=3136000')
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module CarmineContraption
2
- VERSION = '0.0.6'
2
+ VERSION = '0.1.0'
3
3
  end
@@ -8,6 +8,12 @@
8
8
  <meta name="viewport" content="initial-scale=1.0, width=device-width" />
9
9
  <script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
10
10
  <script type="text/javascript" src="js/openclose.js"></script>
11
+ <script type="text/javascript" src="http://files.rampantmonkey.com/highlight.pack.js"></script>
12
+ <script type="text/javascript">
13
+ $(document).ready(function() {
14
+ $('code').each(function(i, e) {hljs.highlightBlock(e)});
15
+ });
16
+ </script>
11
17
  <meta charset="UTF-8">
12
18
  <!--<![endif]-->
13
19
 
Binary file
@@ -0,0 +1,17 @@
1
+ Testing... Testing...
2
+ Type: Article
3
+ Tags: Test
4
+ Summary: Testing.
5
+ Published: Sun, 9 Dec 2012 19:37:58 EST
6
+
7
+ Testing whether the markdown support works.
8
+
9
+ Code sample
10
+ #include<iostream>
11
+
12
+ int main(){
13
+ std::cout << "Hello World.\n";
14
+ return 0;
15
+ }
16
+
17
+ Some __bold text__.
@@ -0,0 +1,19 @@
1
+ Testing... Testing...
2
+ Type: Article
3
+ Tags: Test
4
+ Summary: Testing.
5
+ Published: Sun, 9 Dec 2012 19:37:58 EST
6
+
7
+ Testing whether the markdown support works.
8
+
9
+ Code sample
10
+ #include<iostream>
11
+
12
+ int main(){
13
+ std::cout << "Hello World.\n";
14
+ return 0;
15
+ }
16
+
17
+ Some __bold text__.
18
+
19
+ ![captain adama](adama.jpg)
@@ -0,0 +1,22 @@
1
+ require 'test/unit'
2
+ require 'shoulda'
3
+ require_relative '../lib/carmine_contraption/media'
4
+
5
+ module CarmineContraption
6
+ class TestMedia < Test::Unit::TestCase
7
+ context "public instance api" do
8
+ setup do
9
+ @methods = Media.instance_methods false
10
+ @required_methods = [:local_path, :name, :remote_path, :update]
11
+ end
12
+
13
+ should "include required methods" do
14
+ @required_methods.each { |m| assert @methods.include?(m), "#{m} should be a public instance method." }
15
+ end
16
+
17
+ should "not include anything else" do
18
+ @methods.each { |m| assert @required_methods.include?(m), "#{m} should not be a public instance method." }
19
+ end
20
+ end
21
+ end
22
+ end
data/test/test_post.rb CHANGED
@@ -2,106 +2,174 @@ require 'test/unit'
2
2
  require 'shoulda'
3
3
  require_relative '../lib/carmine_contraption/post'
4
4
 
5
- class TestPost < Test::Unit::TestCase
6
- context "Parsing Tags" do
7
- should "Return zero tags" do
8
- assert_equal CarmineContraption::Post.parse_tags(""), []
9
- end
5
+ module CarmineContraption
6
+ class TestPost < Test::Unit::TestCase
7
+ context "Parsing Tags" do
8
+ should "Return zero tags" do
9
+ assert_equal Post.send(:parse_tags, ""), []
10
+ end
11
+
12
+ should "Return one tag" do
13
+ assert_equal Post.send(:parse_tags, "boogers"), ["boogers"]
14
+ end
10
15
 
11
- should "Return one tag" do
12
- assert_equal CarmineContraption::Post.parse_tags("boogers"), ["boogers"]
13
- end
16
+ should "Return three tags" do
17
+ assert_equal Post.send(:parse_tags, "a, b, c"), ["a", "b", "c"]
18
+ end
19
+
20
+ should "Return lots of tags" do
21
+ tags = Array.new(999, "z")
22
+ assert_equal Post.send(:parse_tags, tags.join(", ")), tags
23
+ end
24
+ end
25
+
26
+ context "Markdown" do
27
+ should "return same text" do
28
+ text = "<p></p>\n"
29
+ assert_equal text, Post.send(:translate_markdown, text)
30
+ end
31
+
32
+ should "convert to code block" do
33
+ text = " int main(){"
34
+ assert_equal "<pre><code>int main(){\n</code></pre>\n", Post.send(:translate_markdown, text)
35
+ end
36
+
37
+ should "convert to link" do
38
+ assert_equal %Q{<p><a href="http://rampantmonkey.com">Website</a></p>\n}, Post.send(:translate_markdown, %q{[Website](http://rampantmonkey.com)})
39
+ end
40
+
41
+ should "translate to html" do
42
+ content = %Q{Testing whether the markdown support works.\nCode sample\n\n #include<iostream>\n int main(){\n std::cout << "Hello World.\\n";\n return 0;\n }}
43
+ expected = %Q{<p>Testing whether the markdown support works.\nCode sample</p>\n\n<pre><code>#include&lt;iostream&gt;\nint main(){\nstd::cout &lt;&lt; &quot;Hello World.\\n&quot;;\nreturn 0;\n}\n</code></pre>\n}
44
+ assert_equal expected, Post.send(:translate_markdown, content)
45
+ end
46
+ end
47
+
48
+ context "Date Importing" do
49
+ should "return date" do
50
+ d = "2010-02-21 18:42:49 -0400"
51
+ assert_equal d, Post.send(:convert_date, d)
52
+ end
53
+
54
+ should "return formatted date" do
55
+ assert_equal "2012-11-20 08:56:32 -0500",
56
+ Post.send(:convert_date, "Tue, 20 Nov 2012 08:56:32 EST")
57
+ end
58
+ end
14
59
 
15
- should "Return three tags" do
16
- assert_equal CarmineContraption::Post.parse_tags("a, b, c"), ["a", "b", "c"]
17
- end
60
+ context "Date Processing" do
61
+ setup do
62
+ @the_post = Post.new published: "2010-02-21 18:00:00 -0400"
63
+ end
64
+
65
+ should "return year" do
66
+ assert_respond_to @the_post, :year
67
+ assert_equal "2010", @the_post.year
68
+ end
69
+
70
+ should "return month" do
71
+ assert_respond_to @the_post, :month
72
+ assert_equal "02", @the_post.month
73
+ end
74
+
75
+ should "return day" do
76
+ assert_respond_to @the_post, :day
77
+ assert_equal "21", @the_post.day
78
+ end
79
+ end
80
+
81
+ context "Separator" do
82
+ should "ignore separator" do
83
+ assert_equal nil, Post.send(:ignore_separator, "=")
84
+ end
85
+
86
+ should "ignore longer separator" do
87
+ assert_equal nil, Post.send(:ignore_separator, "="*10)
88
+ end
89
+
90
+ should "not ignore valid title" do
91
+ title = "This is the Title"
92
+ assert_equal title, Post.send(:ignore_separator, title)
93
+ end
94
+
95
+ should "not ignore empty string" do
96
+ title = ""
97
+ assert_equal title, Post.send(:ignore_separator, title)
98
+ end
99
+ end
100
+
101
+ context "Rejoining Strings" do
102
+ should "return nothing" do
103
+ assert Post.send(:rejoin_string, ["word"]).empty?
104
+ end
105
+
106
+ should "return original word" do
107
+ assert_equal "word", Post.send(:rejoin_string, ["a", "word"])
108
+ end
109
+
110
+ should "return all but the first word" do
111
+ assert_equal "word: play", Post.send(:rejoin_string, ["a", "word", "play"])
112
+ end
113
+ end
18
114
 
19
- should "Return lots of tags" do
20
- tags = Array.new(999, "z")
21
- assert_equal CarmineContraption::Post.parse_tags(tags.join(", ")), tags
115
+ context "GUID from file" do
116
+ should "be test (html)" do
117
+ the_post = Post.from_file("test/data/posts/20121209-test.html")
118
+ assert_equal "test", the_post.guid
119
+ end
120
+
121
+ should "be test (md)" do
122
+ the_post = Post.from_file("test/data/posts/20121209-test.md", ".md")
123
+ assert_equal "test", the_post.guid
124
+ end
125
+ end
126
+
127
+ context "Parse content for media" do
128
+ should "have no media" do
129
+ the_post = Post.new
130
+ assert the_post.media.empty?
131
+ end
132
+
133
+ should "still have no media" do
134
+ the_post = Post.from_file("test/data/posts/20121209-test.md", ".md")
135
+ assert the_post.media.empty?
136
+ end
137
+
138
+ should "have one image" do
139
+ the_post = Post.from_file("test/data/posts/20121210-test-with-image.md", ".md")
140
+ assert_equal 1, the_post.media.size, "the_post contains #{the_post.media.size} pieces of media"
141
+ assert_equal Media, the_post.media.first.class
142
+ end
22
143
  end
23
- end
24
144
 
25
- context "Markdown" do
26
- should "return same text" do
27
- text = "<p></p>\n"
28
- assert_equal text, CarmineContraption::Post.translate_markdown(text)
29
- end
145
+ context "public class api" do
146
+ setup do
147
+ @methods = Post.singleton_class.instance_methods false
148
+ @required_methods = [:from_file]
149
+ end
30
150
 
31
- should "convert to code block" do
32
- text = " int main(){"
33
- assert_equal "<pre><code>int main(){\n</code></pre>\n", CarmineContraption::Post.translate_markdown(text)
34
- end
35
-
36
- should "convert to link" do
37
- assert_equal %Q{<p><a href="http://rampantmonkey.com">Website</a></p>\n}, CarmineContraption::Post.translate_markdown(%q{[Website](http://rampantmonkey.com)})
38
- end
39
- end
151
+ should "include required methods" do
152
+ @required_methods.each { |m| assert @methods.include?(m), "#{m} should be a public class method." }
153
+ end
40
154
 
41
- context "Date Importing" do
42
- should "return date" do
43
- d = "2010-02-21 18:42:49 -0400"
44
- assert_equal d, CarmineContraption::Post.convert_date(d)
155
+ should "not include anything else" do
156
+ @methods.each { |m| assert @required_methods.include?(m), "#{m} should not be a public class method." }
157
+ end
45
158
  end
46
159
 
47
- should "return formatted date" do
48
- assert_equal "2012-11-20 08:56:32 -0500",
49
- CarmineContraption::Post.convert_date("Tue, 20 Nov 2012 08:56:32 EST")
50
- end
51
- end
52
-
53
- context "Date Processing" do
54
- setup do
55
- @the_post = CarmineContraption::Post.new('', '', '', '', '', "2010-02-21 18:00:00 -0400", '', '', '')
56
- end
57
-
58
- should "return year" do
59
- assert_respond_to @the_post, :year
60
- assert_equal "2010", @the_post.year
61
- end
62
-
63
- should "return month" do
64
- assert_respond_to @the_post, :month
65
- assert_equal "02", @the_post.month
66
- end
67
-
68
- should "return day" do
69
- assert_respond_to @the_post, :day
70
- assert_equal "21", @the_post.day
71
- end
72
- end
73
-
74
- context "Separator" do
75
- should "ignore separator" do
76
- assert_equal nil, CarmineContraption::Post.ignore_separator("=")
77
- end
78
-
79
- should "ignore longer separator" do
80
- assert_equal nil, CarmineContraption::Post.ignore_separator("="*10)
81
- end
82
-
83
- should "not ignore valid title" do
84
- title = "This is the Title"
85
- assert_equal title, CarmineContraption::Post.ignore_separator(title)
86
- end
87
-
88
- should "not ignore empty string" do
89
- title = ""
90
- assert_equal title, CarmineContraption::Post.ignore_separator(title)
91
- end
92
- end
93
-
94
- context "Rejoining Strings" do
95
- should "return nothing" do
96
- assert CarmineContraption::Post.rejoin_string(["word"]).empty?
97
- end
98
-
99
- should "return original word" do
100
- assert_equal "word", CarmineContraption::Post.rejoin_string(["a", "word"])
101
- end
160
+ context "public instance api" do
161
+ setup do
162
+ @methods = Post.instance_methods false
163
+ @required_methods = [:content, :day, :extra, :formatted_output, :guid, :media, :month, :original_path, :published, :status, :summary, :tags, :title, :type, :year, :update, :<=>]
164
+ end
165
+
166
+ should "include required methods" do
167
+ @required_methods.each { |m| assert @methods.include?(m), "#{m} should be a public instance method." }
168
+ end
102
169
 
103
- should "return all but the first word" do
104
- assert_equal "word: play", CarmineContraption::Post.rejoin_string(["a", "word", "play"])
170
+ should "not include anything else" do
171
+ @methods.each { |m| assert @required_methods.include?(m), "#{m} should not be a public instance method." }
172
+ end
105
173
  end
106
174
  end
107
175
  end
@@ -0,0 +1,35 @@
1
+ require 'test/unit'
2
+ require 'shoulda'
3
+ require_relative '../lib/carmine_contraption/uploader'
4
+ require_relative '../lib/carmine_contraption/media'
5
+ require_relative '../lib/carmine_contraption/options'
6
+
7
+ module CarmineContraption
8
+ class TestUploader < Test::Unit::TestCase
9
+ context "public instance api" do
10
+ setup do
11
+ @methods = Uploader.instance_methods false
12
+ @required_methods = [:upload]
13
+ end
14
+
15
+ should "include required methods" do
16
+ @required_methods.each { |m| assert @methods.include?(m), "#{m} should be a public instance method." }
17
+ end
18
+ end
19
+
20
+ # context "upload file" do
21
+ # setup do
22
+ # opts = Options.new ['--skip-repository-update']
23
+ # @connection = Uploader.new({access_key_id: opts.s3_access_key_id,
24
+ # secret_access_key: opts.s3_secret_access_key},
25
+ # 'media.rampantmonkey.com'
26
+ # )
27
+ # @media = Media.new name: 'test.png', local_path: Pathname.new('~/Sites/rmcontent/media/cylon.png').expand_path
28
+ # end
29
+ #
30
+ # should "upload file" do
31
+ # @connection.upload @media
32
+ # end
33
+ # end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CarmineContraption
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-04 00:00:00.000000000 Z
12
+ date: 2013-02-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: shoulda
@@ -59,12 +59,43 @@ dependencies:
59
59
  - - ~>
60
60
  - !ruby/object:Gem::Version
61
61
  version: 0.5.8
62
+ - !ruby/object:Gem::Dependency
63
+ name: redcarpet
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 2.2.2
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 2.2.2
78
+ - !ruby/object:Gem::Dependency
79
+ name: aws-s3
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 0.6.3
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 0.6.3
62
94
  description: Longer and more detailed version of summary...
63
95
  email:
64
96
  - kc@rampantmonkey.com
65
97
  executables:
66
98
  - carmine_contraption
67
- - markdown.pl
68
99
  extensions: []
69
100
  extra_rdoc_files: []
70
101
  files:
@@ -74,24 +105,30 @@ files:
74
105
  - Rakefile
75
106
  - Readme.md
76
107
  - bin/carmine_contraption
77
- - bin/markdown.pl
78
108
  - carmine_contraption.gemspec
79
109
  - lib/carmine_contraption/formatters.rb
80
110
  - lib/carmine_contraption/index.rb
111
+ - lib/carmine_contraption/media.rb
81
112
  - lib/carmine_contraption/month_transform.rb
82
113
  - lib/carmine_contraption/options.rb
83
114
  - lib/carmine_contraption/post.rb
84
115
  - lib/carmine_contraption/runner.rb
116
+ - lib/carmine_contraption/uploader.rb
85
117
  - lib/carmine_contraption/version.rb
86
118
  - lib/photos.rb
87
119
  - lib/templates/default.html.erb
88
120
  - lib/templates/landing_page.html
89
121
  - lib/templates/photo.html
90
122
  - lib/update_repo.sh
123
+ - test/data/media/adama.jpg
124
+ - test/data/posts/20121209-test.md
125
+ - test/data/posts/20121210-test-with-image.md
91
126
  - test/test_index.rb
127
+ - test/test_media.rb
92
128
  - test/test_options.rb
93
129
  - test/test_post.rb
94
130
  - test/test_runner.rb
131
+ - test/test_uploader.rb
95
132
  homepage: ''
96
133
  licenses: []
97
134
  post_install_message:
@@ -106,7 +143,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
143
  version: '0'
107
144
  segments:
108
145
  - 0
109
- hash: -3708087154013416350
146
+ hash: -3297282876702184801
110
147
  required_rubygems_version: !ruby/object:Gem::Requirement
111
148
  none: false
112
149
  requirements:
@@ -115,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
152
  version: '0'
116
153
  segments:
117
154
  - 0
118
- hash: -3708087154013416350
155
+ hash: -3297282876702184801
119
156
  requirements: []
120
157
  rubyforge_project: carmine_contraption
121
158
  rubygems_version: 1.8.23
@@ -123,7 +160,12 @@ signing_key:
123
160
  specification_version: 3
124
161
  summary: Static Website Generator
125
162
  test_files:
163
+ - test/data/media/adama.jpg
164
+ - test/data/posts/20121209-test.md
165
+ - test/data/posts/20121210-test-with-image.md
126
166
  - test/test_index.rb
167
+ - test/test_media.rb
127
168
  - test/test_options.rb
128
169
  - test/test_post.rb
129
170
  - test/test_runner.rb
171
+ - test/test_uploader.rb