sweetie 1.0.2 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (172) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +30 -0
  3. data/.gitignore +3 -0
  4. data/.rubocop.yml +16 -0
  5. data/Gemfile +3 -2
  6. data/README.md +224 -28
  7. data/Rakefile +3 -2
  8. data/lib/sweetie/bitbucket.rb +22 -197
  9. data/lib/sweetie/bitbucket_stati_helper.rb +247 -0
  10. data/lib/sweetie/conversion.rb +91 -62
  11. data/lib/sweetie/helper.rb +60 -51
  12. data/lib/sweetie/version.rb +2 -1
  13. data/lib/sweetie.rb +2 -2
  14. data/spec/fixtures/bitbucket/expected_repositories.txt +1 -0
  15. data/spec/fixtures/bitbucket/repositories.json +1 -0
  16. data/spec/fixtures/jekyll/_config.yml +4 -0
  17. data/spec/fixtures/jekyll/_config_repositories.yml +7 -0
  18. data/spec/fixtures/jekyll/_expected_config.yml +4 -0
  19. data/spec/{source → fixtures/jekyll}/site/404.html +0 -0
  20. data/spec/{source → fixtures/jekyll}/site/about.html +0 -0
  21. data/spec/{source → fixtures/jekyll}/site/archiv.html +0 -0
  22. data/spec/{source → fixtures/jekyll}/site/atom.xml +0 -0
  23. data/spec/{source → fixtures/jekyll}/site/colophon.html +0 -0
  24. data/spec/{source → fixtures/jekyll}/site/contact.html +0 -0
  25. data/spec/{source → fixtures/jekyll}/site/follow.html +0 -0
  26. data/spec/{source → fixtures/jekyll}/site/images/2_avatars.gif +0 -0
  27. data/spec/{source → fixtures/jekyll}/site/images/favicon.png +0 -0
  28. data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther.jpg +0 -0
  29. data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_normal.jpg +0 -0
  30. data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_small.jpg +0 -0
  31. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/closebox.png +0 -0
  32. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-fill.png +0 -0
  33. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-l.png +0 -0
  34. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-r.png +0 -0
  35. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow1.png +0 -0
  36. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow2.png +0 -0
  37. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow3.png +0 -0
  38. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow4.png +0 -0
  39. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow5.png +0 -0
  40. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow6.png +0 -0
  41. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow7.png +0 -0
  42. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow8.png +0 -0
  43. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-1.png +0 -0
  44. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-10.png +0 -0
  45. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-11.png +0 -0
  46. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-12.png +0 -0
  47. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-2.png +0 -0
  48. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-3.png +0 -0
  49. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-4.png +0 -0
  50. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-5.png +0 -0
  51. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-6.png +0 -0
  52. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-7.png +0 -0
  53. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-8.png +0 -0
  54. data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-9.png +0 -0
  55. data/spec/{source → fixtures/jekyll}/site/images/rails3.jpg +0 -0
  56. data/spec/{source → fixtures/jekyll}/site/index.html +0 -0
  57. data/spec/{source → fixtures/jekyll}/site/robots.txt +0 -0
  58. data/spec/{source → fixtures/jekyll}/site/sitemap.xml +0 -0
  59. data/spec/{source → fixtures/jekyll}/site/why-i-use-jekyll-for-blogging.html +0 -0
  60. data/spec/fixtures/middleman/build/2012-01-meetup/index.html +238 -0
  61. data/spec/fixtures/middleman/build/2012-03-meetup/index.html +217 -0
  62. data/spec/fixtures/middleman/build/2012-05-meetup/index.html +214 -0
  63. data/spec/fixtures/middleman/build/2012-07-meetup/index.html +210 -0
  64. data/spec/fixtures/middleman/build/2012-08-workshop/index.html +228 -0
  65. data/spec/fixtures/middleman/build/2012-09-meetup/index.html +231 -0
  66. data/spec/fixtures/middleman/build/2012-10-workshop/index.html +227 -0
  67. data/spec/fixtures/middleman/build/2012-11-meetup/index.html +229 -0
  68. data/spec/fixtures/middleman/build/2012-unusual-december-meetup/index.html +186 -0
  69. data/spec/fixtures/middleman/build/2013-01-meetup/index.html +226 -0
  70. data/spec/fixtures/middleman/build/404/index.html +157 -0
  71. data/spec/fixtures/middleman/build/CNAME +1 -0
  72. data/spec/fixtures/middleman/build/april-2014-meetup/index.html +221 -0
  73. data/spec/fixtures/middleman/build/april-2015-meetup/index.html +204 -0
  74. data/spec/fixtures/middleman/build/april-2017-meetup/index.html +210 -0
  75. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-144x144.png +0 -0
  76. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-192x192.png +0 -0
  77. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-36x36.png +0 -0
  78. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-48x48.png +0 -0
  79. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-72x72.png +0 -0
  80. data/spec/fixtures/middleman/build/assets/favicons/android-chrome-96x96.png +0 -0
  81. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-114x114.png +0 -0
  82. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-120x120.png +0 -0
  83. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-144x144.png +0 -0
  84. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-152x152.png +0 -0
  85. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-180x180.png +0 -0
  86. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-57x57.png +0 -0
  87. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-60x60.png +0 -0
  88. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-72x72.png +0 -0
  89. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-76x76.png +0 -0
  90. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-precomposed.png +0 -0
  91. data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon.png +0 -0
  92. data/spec/fixtures/middleman/build/assets/favicons/browserconfig.xml +12 -0
  93. data/spec/fixtures/middleman/build/assets/favicons/favicon-16x16.png +0 -0
  94. data/spec/fixtures/middleman/build/assets/favicons/favicon-32x32.png +0 -0
  95. data/spec/fixtures/middleman/build/assets/favicons/favicon-96x96.png +0 -0
  96. data/spec/fixtures/middleman/build/assets/favicons/favicon.ico +0 -0
  97. data/spec/fixtures/middleman/build/assets/favicons/manifest.json +41 -0
  98. data/spec/fixtures/middleman/build/assets/favicons/mstile-144x144.png +0 -0
  99. data/spec/fixtures/middleman/build/assets/favicons/mstile-150x150.png +0 -0
  100. data/spec/fixtures/middleman/build/assets/favicons/mstile-310x150.png +0 -0
  101. data/spec/fixtures/middleman/build/assets/favicons/mstile-310x310.png +0 -0
  102. data/spec/fixtures/middleman/build/assets/favicons/mstile-70x70.png +0 -0
  103. data/spec/fixtures/middleman/build/assets/favicons/safari-pinned-tab.svg +450 -0
  104. data/spec/fixtures/middleman/build/assets/images/launch_co_logo.png +0 -0
  105. data/spec/fixtures/middleman/build/assets/images/vimfest.png +0 -0
  106. data/spec/fixtures/middleman/build/assets/javascripts/application.js +12 -0
  107. data/spec/fixtures/middleman/build/assets/javascripts/jquery.utils.js +12 -0
  108. data/spec/fixtures/middleman/build/assets/javascripts/lib/validate.js +1 -0
  109. data/spec/fixtures/middleman/build/assets/stylesheets/application.css +5 -0
  110. data/spec/fixtures/middleman/build/assets/stylesheets/vendor/bootstrap.css +5 -0
  111. data/spec/fixtures/middleman/build/august-2013-meetup/index.html +208 -0
  112. data/spec/fixtures/middleman/build/blog/index.html +500 -0
  113. data/spec/fixtures/middleman/build/book-club-about-the-viml-primer/index.html +182 -0
  114. data/spec/fixtures/middleman/build/contact/index.html +155 -0
  115. data/spec/fixtures/middleman/build/data/vimberlin-2013-09_ctags/index.html +98 -0
  116. data/spec/fixtures/middleman/build/data/vimberlin-2013-09_vimprofiling/index.html +157 -0
  117. data/spec/fixtures/middleman/build/data/vimberlin-2014-01_vim_writing/index.html +70 -0
  118. data/spec/fixtures/middleman/build/december-2015-meetup/index.html +199 -0
  119. data/spec/fixtures/middleman/build/december-2016-meetup/index.html +224 -0
  120. data/spec/fixtures/middleman/build/february-2013-vim-beer-lin/index.html +190 -0
  121. data/spec/fixtures/middleman/build/february-2015-meetup/index.html +233 -0
  122. data/spec/fixtures/middleman/build/february-2016-meetup/index.html +271 -0
  123. data/spec/fixtures/middleman/build/feed.xml +2106 -0
  124. data/spec/fixtures/middleman/build/fonts/FontAwesome.otf +0 -0
  125. data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.eot +0 -0
  126. data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.svg +655 -0
  127. data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.ttf +0 -0
  128. data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff +0 -0
  129. data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff2 +0 -0
  130. data/spec/fixtures/middleman/build/humans.txt +12 -0
  131. data/spec/fixtures/middleman/build/imprint/index.html +177 -0
  132. data/spec/fixtures/middleman/build/index.html +157 -0
  133. data/spec/fixtures/middleman/build/january-2014-meetup/index.html +257 -0
  134. data/spec/fixtures/middleman/build/january-2015-meetup/index.html +243 -0
  135. data/spec/fixtures/middleman/build/january-2016-meetup/index.html +202 -0
  136. data/spec/fixtures/middleman/build/january-2017-meetup/index.html +228 -0
  137. data/spec/fixtures/middleman/build/july-2015-meetup/index.html +207 -0
  138. data/spec/fixtures/middleman/build/june-2016-meetup/index.html +260 -0
  139. data/spec/fixtures/middleman/build/march-2-2017-meetup/index.html +201 -0
  140. data/spec/fixtures/middleman/build/march-2014-meetup/index.html +219 -0
  141. data/spec/fixtures/middleman/build/march-2016-meetup/index.html +221 -0
  142. data/spec/fixtures/middleman/build/march-2017-meetup/index.html +222 -0
  143. data/spec/fixtures/middleman/build/may-2013-meetup/index.html +234 -0
  144. data/spec/fixtures/middleman/build/may-2014-meetup/index.html +198 -0
  145. data/spec/fixtures/middleman/build/may-2015-meetup/index.html +202 -0
  146. data/spec/fixtures/middleman/build/may-2016-meetup/index.html +245 -0
  147. data/spec/fixtures/middleman/build/newsletter/index.html +171 -0
  148. data/spec/fixtures/middleman/build/november-2013-meetup/index.html +199 -0
  149. data/spec/fixtures/middleman/build/november-2015-meetup/index.html +402 -0
  150. data/spec/fixtures/middleman/build/november-2016-meetup/index.html +224 -0
  151. data/spec/fixtures/middleman/build/october-2013-meetup/index.html +210 -0
  152. data/spec/fixtures/middleman/build/october-2014-meetup/index.html +196 -0
  153. data/spec/fixtures/middleman/build/october-2016-meetup/index.html +222 -0
  154. data/spec/fixtures/middleman/build/robots.txt +6 -0
  155. data/spec/fixtures/middleman/build/september-2013-meetup/index.html +225 -0
  156. data/spec/fixtures/middleman/build/september-2014-meetup/index.html +211 -0
  157. data/spec/fixtures/middleman/build/sitemap.xml +297 -0
  158. data/spec/fixtures/middleman/build/vimfest-october-2015/index.html +303 -0
  159. data/spec/fixtures/middleman/config.rb +4 -0
  160. data/spec/fixtures/middleman/config_repositories.rb +7 -0
  161. data/spec/fixtures/middleman/expected_config.rb +4 -0
  162. data/spec/spec_helper.rb +2 -2
  163. data/spec/sweetie_bitbucket_spec.rb +26 -51
  164. data/spec/sweetie_bitbucket_stati_helper_spec.rb +124 -0
  165. data/spec/sweetie_conversion_spec.rb +105 -17
  166. data/spec/sweetie_helper_spec.rb +140 -0
  167. data/sweetie.gemspec +10 -9
  168. metadata +163 -56
  169. data/.travis.yml +0 -7
  170. data/spec/source/_config.yml +0 -18
  171. data/spec/source/bitbucket/user_repositories.json +0 -161
  172. data/spec/source/bitbucket/user_repositories_expectation.txt +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: aaa05aba881687ee4bbda9e9c31574e54bb20fc3
4
- data.tar.gz: 06a7b0afe7466ebac59a5c534e7b780d65e7bd5e
2
+ SHA256:
3
+ metadata.gz: c1db059c1e669df16935ce777d10950815b50a92f5358cf9b5a85d1a62c9ab5a
4
+ data.tar.gz: d4f75478d20b6a6d5a0c2394c40d1b4c01a8bd406775c00fc866f969eb4c85f4
5
5
  SHA512:
6
- metadata.gz: bab1e490132c38e57a363f9848e0ea47f2322dddf1ab1d34d8dd97b67546c4a44cc33ba0e3a649a275bb8969ffd6d83c6b13cb948ff1aa6d4fffff388bfb5c12
7
- data.tar.gz: a22e2335b8f86a240af105fe8eaf0eaff1b30426c5e435e2e8f38964e2269f4e82f56a59e6deef1c7b6866c125d52ee85d7b19b8bd3c3655c979c564ac4b99ba
6
+ metadata.gz: 844e97b5dd14342c2e7119fa03d88a95527adcb6ac08ce65041f44eb7239262ab9251ac06baead2766b9eb25b5db0396a634e2fd12dfa33ae9a3e229f2b321b1
7
+ data.tar.gz: 0a4bc5e88a63a34103fb34bf225d462b541326350553fd7af76412e1e310f0af90378cc1694ba697419c3879622665305061c57950ff0fc8b527afb8ef674419
@@ -0,0 +1,30 @@
1
+ version: 2.1
2
+ orbs:
3
+ ruby: circleci/ruby@0.1.2
4
+
5
+ jobs:
6
+ build:
7
+ parameters:
8
+ ruby-version:
9
+ type: string
10
+ docker:
11
+ - image: circleci/ruby:<< parameters.ruby-version >>
12
+ executor: ruby/default
13
+ steps:
14
+ - checkout
15
+ - run:
16
+ name: Which bundler?
17
+ command: gem install bundler:2.2.26
18
+ - ruby/bundle-install
19
+ - run:
20
+ name: Run rspec tests
21
+ command: bundle exec rspec
22
+ workflows:
23
+ build_and_test:
24
+ jobs:
25
+ - build:
26
+ matrix:
27
+ parameters:
28
+ # https://github.com/CircleCI-Public/cimg-ruby
29
+ # only supports the last three ruby versions
30
+ ruby-version: ["2.6.0", "2.6.5", "2.7.4", "3.0.2"]
data/.gitignore CHANGED
@@ -4,3 +4,6 @@
4
4
  *.sass-cache
5
5
  .yardoc/*
6
6
  Gemfile.lock
7
+ doc/
8
+ bin/
9
+ .mucksrc
data/.rubocop.yml ADDED
@@ -0,0 +1,16 @@
1
+ Documentation:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Max: 150
6
+ Metrics/BlockLength:
7
+ Max: 150
8
+
9
+ Layout/TrailingBlankLines:
10
+ EnforcedStyle: final_blank_line
11
+
12
+ Style/RedundantSelf:
13
+ Enabled: false
14
+ Style/HashSyntax:
15
+ EnforcedStyle: no_mixed_keys
16
+
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
- source "http://rubygems.org"
1
+ source 'http://rubygems.org'
2
2
 
3
- gem "codeclimate-test-reporter", group: :test, require: nil
3
+ gem 'pry'
4
4
 
5
5
  gemspec
6
+
data/README.md CHANGED
@@ -1,6 +1,28 @@
1
- Sweetie is a plugin for [jekyll](https://github.com/mojombo/jekyll) to count all links, images, pages, and the last
2
- build time on a jekyll site. It can also grab the last changes of your bitbucket repositories.
3
- You can then use this information at a any place in your jekyll project.
1
+ Sweetie is a plugin for to get statistics for [jekyll](http://jekyllrb.com/ "jekyll") and
2
+ [middleman](https://middlemanapp.com/ "middleman") projects. The statistics includes the unique number of all links,
3
+ images, pages, and the last build time of the given project. You can specify the location the generated files
4
+ (normally `_site` for jekyll and `build` for middleman apps) and of the `config` file where the changes
5
+ will be written.
6
+
7
+
8
+ It can also grab the last changes of your bitbucket repositories. You can then use the information on various places in
9
+ your project
10
+
11
+ [![Gem Version](https://badge.fury.io/rb/sweetie.svg)](http://badge.fury.io/rb/sweetie)
12
+ [![CircleCI](https://circleci.com/gh/wikimatze/sweetie.svg?style=svg)](https://app.circleci.com/pipelines/github/wikimatze/sweetie)
13
+
14
+
15
+ ## Toc
16
+
17
+ - [Installation](#installation)
18
+ - [Usage create stati](#usage-create-stati)
19
+ - [Jekyll](#jekyll "Jekyll projects")
20
+ - [Configuration variables for Jekyll](#configuration-variables-for-jekyll "Configuration variables for Jekyll")
21
+ - [Middleman](#middleman "Middleman projects")
22
+ - [Configuration variables for Middleman](#configuration-variables-for-middleman "Configuration variables for Middleman")
23
+ - [Usage bitbucket repositories](#usage-bitbucket-repositories "Usage bitbucket repositories")
24
+ - [Middleman](#middleman-1 "Middleman")
25
+ - [Jekyll](#jekyll-1 "Jekyll")
4
26
 
5
27
 
6
28
  ## Installation
@@ -10,7 +32,9 @@ $ gem install sweetie
10
32
  ```
11
33
 
12
34
 
13
- ## Usage
35
+ ## Usage create stati
36
+
37
+ ### Jekyll
14
38
 
15
39
  The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
16
40
 
@@ -18,29 +42,42 @@ Before you build your page, you can run a rake task to update the status informa
18
42
 
19
43
 
20
44
  ```ruby
21
- desc 'write stats in the _config.yml'
45
+ require 'sweetie'
46
+
47
+ desc 'write stats in the _config.yml file'
22
48
  task :create_stati do
23
- Sweetie::Conversion.conversion
49
+ sweetie = Sweetie::Conversion.new('./site', './_config.yml')
50
+ sweetie.create_stati
24
51
  end
25
52
  ```
26
53
 
27
54
 
28
- A similar task can be implemented for the bitbucket repositories:
55
+ Make sure that the following fields are set in your `_config.yml`:
56
+
57
+
58
+ ```yml
59
+ build:
60
+ htmlpages:
61
+ images:
62
+ links:
63
+ ```
64
+
65
+
66
+ After running the script, the changes in `_config.yml` will look like:
29
67
 
30
68
 
31
69
  ```ruby
32
- desc 'write stats in the _config.yml'
33
- task :create_bitbucket do
34
- Sweetie::Bitbucket.bitbucket("yourname")
35
- end
70
+ build: 6-18-2017
71
+ htmlpages: 600
72
+ images: 20
73
+ links: 271
36
74
  ```
37
75
 
38
76
 
39
- ## Configuration variables of jekyll
77
+ ### Configuration variables for Jekyll
78
+
79
+ You can use the `build`, `htmlpages`, `images`, and `links` variables defined in your `_config.yml` file everywhere in your page with the liquid snippet for example:
40
80
 
41
- Call the class method `Sweetie::Bitbucket.bitbucket("yourname")` and it will automatically append
42
- the `build`, `htmlpages`, `images`, and `links` in your `_config.yml` file. You can then use them
43
- everywhere in your page with the liquid snippet for example:
44
81
 
45
82
  - `{{ site.build }}`
46
83
  - `{{ site.htmlpages }}`
@@ -48,34 +85,107 @@ everywhere in your page with the liquid snippet for example:
48
85
  - `{{ site.links }}`
49
86
 
50
87
 
51
- ## Last changes of bitbucket repository
88
+ If you also make use of [Usage for Bitbucket repositories](#usage-for-bitbucket-repositories "Usage for Bitbucket repositories") you can also use the last update value for your repositories:
89
+
90
+
91
+ ```html
92
+ <section class="lastupdate">
93
+ Last update {{ site.git }}
94
+ </section>
95
+ ...
96
+
97
+
98
+ <section class="lastupdate">
99
+ Last update {{ site.pmwiki-twitter-recipe }}
100
+ </section>
101
+ ...
102
+ ```
52
103
 
53
- Call the class method `Sweetie::Bitbucket.bitbucket("yourname")` and it will automatically append the repository name an
54
- the last change of the repository in your `_config.yml`. Here is an example:
104
+
105
+ will result the following html:
106
+
107
+
108
+ ```html
109
+ <h3 id="git">Git</h3>
110
+
111
+ <section class="lastupdate">
112
+ Last update 2011-10-16
113
+ </section>
114
+
115
+
116
+ <h3 id="twitter">Twitter</h3>
117
+
118
+ <section class="lastupdate">
119
+ Last update 2011-10-16
120
+ </section>
121
+ ```
122
+
123
+
124
+
125
+ ### Middleman
126
+
127
+ The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
128
+
129
+ Before you build your page, you can run a rake task to update the status information of a page:
130
+
131
+
132
+ ```ruby
133
+ require 'sweetie'
134
+
135
+ desc 'write stats in the config.rb file'
136
+ task :create_stati do
137
+ sweetie = Sweetie::Conversion.new('./build', './config.rb')
138
+ sweetie.create_stati
139
+ end
140
+ ```
141
+
142
+
143
+ Make sure that the following fields are set in your `config.rb`:
55
144
 
56
145
 
57
146
  ```yml
58
- git: 2011-10-16
59
- pmwiki-twitter-recipe: 2011-10-29
147
+ set :build,
148
+ set :images,
149
+ set :htmlpages,
150
+ set :links,
151
+ ```
152
+
153
+
154
+ After running the script, the changes in `config.rb` will look like for example:
155
+
156
+
157
+ ```ruby
158
+ set :build, 6-18-2017
159
+ set :images, 75
160
+ set :htmlpages, 111
161
+ set :links, 694
60
162
  ```
61
163
 
62
164
 
63
- You can then use this variables in the view of your jekyll project with the liquid template. For example:
165
+ ### Configuration variables for Middleman
64
166
 
167
+ You can use the `build`, `htmlpages`, `images`, and `links` variables defined in your `_config.yml` file everywhere in your page with the erb snippet for example:
65
168
 
66
- ```markdown
67
- ### git
169
+
170
+ - `<%= config[:build] %>
171
+ - `<%= config[:htmlpages] %>
172
+ - `<%= config[:images] %>
173
+ - `<%= config[:links] %>
174
+
175
+
176
+ If you also make use of [Usage for Bitbucket repositories](#usage-for-bitbucket-repositories "Usage for Bitbucket repositories") you can also use the last update value for your repositories:
177
+
178
+
179
+ ```html
68
180
 
69
181
  <section class="lastupdate">
70
- Last update {{ site.git }}
182
+ Last update <%= config[:git] %>
71
183
  </section>
72
184
  ...
73
185
 
74
186
 
75
- ### Twitter
76
-
77
187
  <section class="lastupdate">
78
- Last update {{ site.pmwiki-twitter-recipe }}
188
+ Last update <%= config[:pmwiki_twitter_recipe %>
79
189
  </section>
80
190
  ...
81
191
  ```
@@ -100,8 +210,94 @@ Last update 2011-10-16
100
210
  ```
101
211
 
102
212
 
213
+ ## Usage Bitbucket repositories
214
+
215
+ ### Middleman
216
+
217
+ The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
218
+
219
+ Before you build your page, you can run a rake task to update the status of the repositories for the given `config-file` and `username`:
220
+
221
+
222
+ ```ruby
223
+ require 'sweetie'
224
+
225
+ desc 'write repositories stats in the config.rb file'
226
+ task :create_bitbucket do
227
+ stati_helper = Sweetie::BitbucketStatiHelper.new('./config.rb', 'wikimatze')
228
+ bitbucket = Sweetie::Bitbucket.new(stati_helper)
229
+ bitbucket.update_stati
230
+ end
231
+ ```
232
+
233
+ Please note that you have to change `wikimatze` to your bitbucket user name
234
+
235
+
236
+ ```ruby
237
+ set :pmwiki_dropcaps_recipe,
238
+ set :pmwiki_syntaxlove_recipe,
239
+ set :pmwiki_twitter_recipe,
240
+ set :pmwiki_linkicons_recipe,
241
+ set :pmwiki_headlineimage_recipe,
242
+ ```
243
+
244
+
245
+ After running the script, the names in `config.rb` above will be changed to:
246
+
247
+
248
+ ```ruby
249
+ set :pmwiki_dropcaps_recipe, 2017-02-24
250
+ set :pmwiki_syntaxlove_recipe, 2017-02-26
251
+ set :pmwiki_twitter_recipe, 2017-02-26
252
+ set :pmwiki_linkicons_recipe, 2017-02-26
253
+ set :pmwiki_headlineimage_recipe, 2017-02-25
254
+ ```
255
+
256
+
257
+ ### Jekyll
258
+
259
+ The easiest way is to add `require 'sweetie'` on the top of your Rakefile.
260
+
261
+ Before you build your page, you can run a rake task to update the status of the repositories for the given `config-file` and `username`:
262
+
263
+
264
+ ```ruby
265
+ require 'sweetie'
266
+
267
+ desc 'write repositories stats in the _config.yml file'
268
+ desc 'write stats in the _config.yml'
269
+ task :create_bitbucket do
270
+ stati_helper = Sweetie::BitbucketStatiHelper.new('./_config.yml', 'wikimatze')
271
+ bitbucket = Sweetie::Bitbucket.new(stati_helper)
272
+ bitbucket.update_stati
273
+ end
274
+ ```
275
+
276
+ Please note that you have to change `wikimatze` to your bitbucket user name
277
+
278
+
279
+ ```ruby
280
+ set :pmwiki_dropcaps_recipe,
281
+ set :pmwiki_syntaxlove_recipe,
282
+ set :pmwiki_twitter_recipe,
283
+ set :pmwiki_linkicons_recipe,
284
+ set :pmwiki_headlineimage_recipe,
285
+ ```
286
+
287
+
288
+ After running the script, the names in `config.rb` above will be changed to:
289
+
290
+
291
+ ```ruby
292
+ set :pmwiki_dropcaps_recipe, 2017-02-24
293
+ set :pmwiki_syntaxlove_recipe, 2017-02-26
294
+ set :pmwiki_twitter_recipe, 2017-02-26
295
+ set :pmwiki_linkicons_recipe, 2017-02-26
296
+ set :pmwiki_headlineimage_recipe, 2017-02-25
297
+ ```
298
+
103
299
  ## License
104
300
 
105
301
  This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).
106
302
 
107
- © 2011-2015 Matthias Günther <matthias@wikimatze.de>.
303
+ © 2011-2019 Matthias Günther <matze@wikimatze.de>.
data/Rakefile CHANGED
@@ -1,7 +1,8 @@
1
1
  task :spec do
2
- Dir.glob("spec/**/*_spec.rb") do |file|
3
- system ("rspec #{file}")
2
+ Dir.glob('spec/**/*_spec.rb') do |file|
3
+ system "rspec #{file}"
4
4
  end
5
5
  end
6
6
 
7
7
  task :default => :spec
8
+
@@ -1,204 +1,29 @@
1
1
  require 'sweetie/helper'
2
+ require 'sweetie/bitbucket_stati_helper'
3
+ require 'json'
4
+
2
5
  module Sweetie
6
+ # The class to get the repositorie updates from Bitbucket
3
7
  class Bitbucket
4
- require 'json'
5
-
6
- @@config = "_config.yml"
7
-
8
- class << self
9
- include Sweetie::Helper
10
-
11
- # getter for class variable @@config
12
- def config
13
- @@config
14
- end
15
-
16
- # setter for the class variable @@config
17
- def config=(config)
18
- @@config = config
19
- end
20
-
21
- # Public: Wrapper to start all the other methods
22
- #
23
- # user - The String of the bitbucket user
24
- #
25
- # Example:
26
- #
27
- # bitbucket('wikimatze')
28
- #
29
- # Returns nothing but write the changes in the _config.yml file
30
- def bitbucket(user)
31
- json_repositories = get_repositories(user)
32
- repositories_change_hashs = get_repositories_changes(json_repositories)
33
- write_repository_changes(repositories_change_hashs)
34
- end
35
-
36
- # Public: Fire up curl request to bitbucket
37
- #
38
- # user - The String of the bitbucket user
39
- #
40
- # Example:
41
- #
42
- # bitbucket('wikimatze')
43
- #
44
- # # =>
45
- # {
46
- # "repositories": [
47
- # {
48
- # "scm": "git",
49
- # "has_wiki": false,
50
- # "last_updated": "2012-07-01 07:03:08",
51
- # "creator": null,
52
- # "created_on": "2012-07-01 07:03:08",
53
- # "owner": "wikimatze",
54
- # "logo": null,
55
- # "email_mailinglist": "",
56
- # "is_mq": false,
57
- # "size": 580,
58
- # "read_only": false,
59
- # "fork_of": null,
60
- # "mq_of": null,
61
- # "followers_count": 1,
62
- # "state": "available",
63
- # "utc_created_on": "2012-07-01 05:03:08+00:00",
64
- # "website": "",
65
- # "description": "",
66
- # "has_issues": false,
67
- # "is_fork": false,
68
- # "slug": "knoppix-6-01",
69
- # "is_private": false,
70
- # "name": "knoppix-6-01",
71
- # "language": "",
72
- # "utc_last_updated": "2012-07-01 05:03:08+00:00",
73
- # "email_writers": true,
74
- # "no_public_forks": false,
75
- # "resource_uri": "/1.0/repositories/wikimatze/knoppix-6-01"
76
- # },
77
- # ... other repositories
78
- # }
79
- # ],
80
- # "user": {
81
- # "username": "wikimatze",
82
- # "first_name": "Matthias",
83
- # "last_name": "Guenther",
84
- # "avatar": "https://secure.gravatar.com/avatar/208673d619b63131cbfd7205366ad16e?d=identicon&s=32",
85
- # "resource_uri": "/1.0/users/wikimatze"
86
- # }
87
- # }
88
- #
89
- # Returns a json representation the specified user
90
- def get_repositories(user)
91
- `curl -s https://api.bitbucket.org/1.0/users/#{user}/`
92
- end
93
-
94
- # Public: Grab for each repository the recent update
95
- #
96
- # json_repositories: A json object of the bitbucket API response
97
- #
98
- # Example:
99
- #
100
- # get_repositories_changes(wikimatze_json)
101
- # # => {"pmwiki-headlineimage-recipe"=>"2011-10-29", "pmwiki-linkicons-recipe"=>"2011-10-29"}
102
- #
103
- # Returns a hash of the form {repository_name => last_updated}
104
- def get_repositories_changes(json_repositories)
105
- repository_hash = parse_json(json_repositories)
106
- repositories_changsets = {}
107
-
108
- repository_hash["repositories"].each do |repository|
109
- repository_name = repository['name']
110
- repository_last_updated = parse_timestamp(repository['last_updated'])
111
- repositories_changsets.merge!({repository_name => repository_last_updated})
112
- end
113
-
114
- repositories_changsets
115
- end
116
-
117
- # Public: Wrapper for calling the json_parsing
118
- #
119
- # file: A String in JSON format
120
- #
121
- # Example:
122
- #
123
- # json = {
124
- # "user": {
125
- # "username": "wikimatze",
126
- # "first_name": "Matthias",
127
- # "last_name": "Guenther",
128
- # "resource_uri": "/1.0/users/wikimatze"
129
- # }
130
- # }
131
-
132
- # parse_json(json)
133
- # # => {"user"=>{"username"=>"wikimatze", "first_name"=>"Matthias", "last_name"=>"Guenther", "resource_uri"=>"/1.0/users/wikimatze"}}
134
- #
135
- # Returns Parse JSON file to format be read by ruby
136
- def parse_json(json)
137
- JSON.parse(json)
138
- end
139
-
140
- # Public: Parse a timestamp in a wanted format
141
- #
142
- # timestamp - A string in the form 2011-04-20 11:31:39
143
- #
144
- # Example:
145
- #
146
- # parse_timestamp("2011-04-20 11:31:39")
147
- # # => 2011-04-20
148
- #
149
- # Returns a string in the format "yyyy-mm-dd"
150
- def parse_timestamp(timestamp)
151
- regex = Regexp.new(/(\d+)-(\d+)-(\d+)/)
152
- regex.match(timestamp)[0]
153
- end
154
-
155
- # Public: Parse a hash and write its key/value pairs in a file
156
- #
157
- # repositories - A hash in the form {<name> => <last_updated}
158
- #
159
- # Example:
160
- #
161
- # write_repository_changes({"svn" => "2011-10-26", "pmwiki" => "2011-10-26"})
162
- # # => svn: 2011-10-26\npmwiki: 2011-10-26
163
- #
164
- # Returns nothing but writes the information in the specified _config.yml file
165
- def write_repository_changes(repositories)
166
- repositories.each do |name, last_updated|
167
- file = File.open(@@config)
168
- text = ""
169
- match = false
170
- while line = file.gets
171
- if line.match(/#{name}/)
172
- match = true
173
- # create string and replace this line with the new changes
174
- text << entry_text(name, last_updated) + "\n"
175
- else
176
- text << line
177
- end
178
- end
179
-
180
- # append the name if it is not in there
181
- text << entry_text(name, last_updated) unless match
182
-
183
- file.close
184
- write_config(@@config, text)
185
- end
186
- end
8
+ include Sweetie::Helper
9
+
10
+ # A basic initialize method.
11
+ #
12
+ # @param bitbucket_stati_helper [BitbucketStatiHelper]
13
+ # @return [BitbucketStatiHelper]
14
+ def initialize(bitbucket_stati_helper)
15
+ @bitbucket_stati_helper = bitbucket_stati_helper
16
+ end
187
17
 
188
- # Public: Create a string representation of a repository entry
189
- #
190
- # name - A string containing the name of the repository
191
- # last_updated - A string containing the date of the last change of the repo
192
- #
193
- # Example:
194
- #
195
- # entry_text({"pmwiki" => "2011-10-26"}
196
- # # => "pmwiki: 2011-10-26"
197
- #
198
- # Return a string in the form "<name>: <last_updated>"
199
- def entry_text(name, last_updated)
200
- "#{name}: #{last_updated}"
201
- end
18
+ # Wrapper to start all the other methods which will use methods
19
+ # to write the changes of the bitbucket in the config file,
20
+ # which can be configured in the BitbucketStatiHelper
21
+ #
22
+ # @return [nil]
23
+ def update_stati
24
+ json_repositories = @bitbucket_stati_helper.get_repositories
25
+ repositories_change_hashs = @bitbucket_stati_helper.get_repositories_changes(json_repositories)
26
+ @bitbucket_stati_helper.write_repository_changes(repositories_change_hashs)
202
27
  end
203
28
  end
204
29
  end