sweetie 1.0.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +30 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +16 -0
- data/Gemfile +3 -2
- data/README.md +224 -28
- data/Rakefile +3 -2
- data/lib/sweetie/bitbucket.rb +22 -197
- data/lib/sweetie/bitbucket_stati_helper.rb +247 -0
- data/lib/sweetie/conversion.rb +91 -62
- data/lib/sweetie/helper.rb +60 -51
- data/lib/sweetie/version.rb +2 -1
- data/lib/sweetie.rb +2 -2
- data/spec/fixtures/bitbucket/expected_repositories.txt +1 -0
- data/spec/fixtures/bitbucket/repositories.json +1 -0
- data/spec/fixtures/jekyll/_config.yml +4 -0
- data/spec/fixtures/jekyll/_config_repositories.yml +7 -0
- data/spec/fixtures/jekyll/_expected_config.yml +4 -0
- data/spec/{source → fixtures/jekyll}/site/404.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/about.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/archiv.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/atom.xml +0 -0
- data/spec/{source → fixtures/jekyll}/site/colophon.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/contact.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/follow.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/2_avatars.gif +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/favicon.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_normal.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/matthias_guenther_thumbnail_small.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/closebox.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-fill.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-l.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-caption-r.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow1.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow2.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow3.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow4.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow5.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow6.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow7.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-shadow8.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-1.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-10.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-11.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-12.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-2.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-3.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-4.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-5.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-6.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-7.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-8.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/images-global/zoom/zoom-spin-9.png +0 -0
- data/spec/{source → fixtures/jekyll}/site/images/rails3.jpg +0 -0
- data/spec/{source → fixtures/jekyll}/site/index.html +0 -0
- data/spec/{source → fixtures/jekyll}/site/robots.txt +0 -0
- data/spec/{source → fixtures/jekyll}/site/sitemap.xml +0 -0
- data/spec/{source → fixtures/jekyll}/site/why-i-use-jekyll-for-blogging.html +0 -0
- data/spec/fixtures/middleman/build/2012-01-meetup/index.html +238 -0
- data/spec/fixtures/middleman/build/2012-03-meetup/index.html +217 -0
- data/spec/fixtures/middleman/build/2012-05-meetup/index.html +214 -0
- data/spec/fixtures/middleman/build/2012-07-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/2012-08-workshop/index.html +228 -0
- data/spec/fixtures/middleman/build/2012-09-meetup/index.html +231 -0
- data/spec/fixtures/middleman/build/2012-10-workshop/index.html +227 -0
- data/spec/fixtures/middleman/build/2012-11-meetup/index.html +229 -0
- data/spec/fixtures/middleman/build/2012-unusual-december-meetup/index.html +186 -0
- data/spec/fixtures/middleman/build/2013-01-meetup/index.html +226 -0
- data/spec/fixtures/middleman/build/404/index.html +157 -0
- data/spec/fixtures/middleman/build/CNAME +1 -0
- data/spec/fixtures/middleman/build/april-2014-meetup/index.html +221 -0
- data/spec/fixtures/middleman/build/april-2015-meetup/index.html +204 -0
- data/spec/fixtures/middleman/build/april-2017-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-192x192.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-36x36.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-48x48.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-72x72.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/android-chrome-96x96.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-114x114.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-120x120.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-152x152.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-180x180.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-57x57.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-60x60.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-72x72.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-76x76.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon-precomposed.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/apple-touch-icon.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/browserconfig.xml +12 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-16x16.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-32x32.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon-96x96.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/favicon.ico +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/manifest.json +41 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-144x144.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-150x150.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-310x150.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-310x310.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/mstile-70x70.png +0 -0
- data/spec/fixtures/middleman/build/assets/favicons/safari-pinned-tab.svg +450 -0
- data/spec/fixtures/middleman/build/assets/images/launch_co_logo.png +0 -0
- data/spec/fixtures/middleman/build/assets/images/vimfest.png +0 -0
- data/spec/fixtures/middleman/build/assets/javascripts/application.js +12 -0
- data/spec/fixtures/middleman/build/assets/javascripts/jquery.utils.js +12 -0
- data/spec/fixtures/middleman/build/assets/javascripts/lib/validate.js +1 -0
- data/spec/fixtures/middleman/build/assets/stylesheets/application.css +5 -0
- data/spec/fixtures/middleman/build/assets/stylesheets/vendor/bootstrap.css +5 -0
- data/spec/fixtures/middleman/build/august-2013-meetup/index.html +208 -0
- data/spec/fixtures/middleman/build/blog/index.html +500 -0
- data/spec/fixtures/middleman/build/book-club-about-the-viml-primer/index.html +182 -0
- data/spec/fixtures/middleman/build/contact/index.html +155 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2013-09_ctags/index.html +98 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2013-09_vimprofiling/index.html +157 -0
- data/spec/fixtures/middleman/build/data/vimberlin-2014-01_vim_writing/index.html +70 -0
- data/spec/fixtures/middleman/build/december-2015-meetup/index.html +199 -0
- data/spec/fixtures/middleman/build/december-2016-meetup/index.html +224 -0
- data/spec/fixtures/middleman/build/february-2013-vim-beer-lin/index.html +190 -0
- data/spec/fixtures/middleman/build/february-2015-meetup/index.html +233 -0
- data/spec/fixtures/middleman/build/february-2016-meetup/index.html +271 -0
- data/spec/fixtures/middleman/build/feed.xml +2106 -0
- data/spec/fixtures/middleman/build/fonts/FontAwesome.otf +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.eot +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.svg +655 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.ttf +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff +0 -0
- data/spec/fixtures/middleman/build/fonts/fontawesome-webfont.woff2 +0 -0
- data/spec/fixtures/middleman/build/humans.txt +12 -0
- data/spec/fixtures/middleman/build/imprint/index.html +177 -0
- data/spec/fixtures/middleman/build/index.html +157 -0
- data/spec/fixtures/middleman/build/january-2014-meetup/index.html +257 -0
- data/spec/fixtures/middleman/build/january-2015-meetup/index.html +243 -0
- data/spec/fixtures/middleman/build/january-2016-meetup/index.html +202 -0
- data/spec/fixtures/middleman/build/january-2017-meetup/index.html +228 -0
- data/spec/fixtures/middleman/build/july-2015-meetup/index.html +207 -0
- data/spec/fixtures/middleman/build/june-2016-meetup/index.html +260 -0
- data/spec/fixtures/middleman/build/march-2-2017-meetup/index.html +201 -0
- data/spec/fixtures/middleman/build/march-2014-meetup/index.html +219 -0
- data/spec/fixtures/middleman/build/march-2016-meetup/index.html +221 -0
- data/spec/fixtures/middleman/build/march-2017-meetup/index.html +222 -0
- data/spec/fixtures/middleman/build/may-2013-meetup/index.html +234 -0
- data/spec/fixtures/middleman/build/may-2014-meetup/index.html +198 -0
- data/spec/fixtures/middleman/build/may-2015-meetup/index.html +202 -0
- data/spec/fixtures/middleman/build/may-2016-meetup/index.html +245 -0
- data/spec/fixtures/middleman/build/newsletter/index.html +171 -0
- data/spec/fixtures/middleman/build/november-2013-meetup/index.html +199 -0
- data/spec/fixtures/middleman/build/november-2015-meetup/index.html +402 -0
- data/spec/fixtures/middleman/build/november-2016-meetup/index.html +224 -0
- data/spec/fixtures/middleman/build/october-2013-meetup/index.html +210 -0
- data/spec/fixtures/middleman/build/october-2014-meetup/index.html +196 -0
- data/spec/fixtures/middleman/build/october-2016-meetup/index.html +222 -0
- data/spec/fixtures/middleman/build/robots.txt +6 -0
- data/spec/fixtures/middleman/build/september-2013-meetup/index.html +225 -0
- data/spec/fixtures/middleman/build/september-2014-meetup/index.html +211 -0
- data/spec/fixtures/middleman/build/sitemap.xml +297 -0
- data/spec/fixtures/middleman/build/vimfest-october-2015/index.html +303 -0
- data/spec/fixtures/middleman/config.rb +4 -0
- data/spec/fixtures/middleman/config_repositories.rb +7 -0
- data/spec/fixtures/middleman/expected_config.rb +4 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/sweetie_bitbucket_spec.rb +26 -51
- data/spec/sweetie_bitbucket_stati_helper_spec.rb +124 -0
- data/spec/sweetie_conversion_spec.rb +105 -17
- data/spec/sweetie_helper_spec.rb +140 -0
- data/sweetie.gemspec +10 -9
- metadata +163 -56
- data/.travis.yml +0 -7
- data/spec/source/_config.yml +0 -18
- data/spec/source/bitbucket/user_repositories.json +0 -161
- data/spec/source/bitbucket/user_repositories_expectation.txt +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c1db059c1e669df16935ce777d10950815b50a92f5358cf9b5a85d1a62c9ab5a
|
4
|
+
data.tar.gz: d4f75478d20b6a6d5a0c2394c40d1b4c01a8bd406775c00fc866f969eb4c85f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
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
data/README.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
|
-
Sweetie is a plugin for [jekyll](
|
2
|
-
|
3
|
-
|
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
|
-
|
45
|
+
require 'sweetie'
|
46
|
+
|
47
|
+
desc 'write stats in the _config.yml file'
|
22
48
|
task :create_stati do
|
23
|
-
Sweetie::Conversion.
|
49
|
+
sweetie = Sweetie::Conversion.new('./site', './_config.yml')
|
50
|
+
sweetie.create_stati
|
24
51
|
end
|
25
52
|
```
|
26
53
|
|
27
54
|
|
28
|
-
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
70
|
+
build: 6-18-2017
|
71
|
+
htmlpages: 600
|
72
|
+
images: 20
|
73
|
+
links: 271
|
36
74
|
```
|
37
75
|
|
38
76
|
|
39
|
-
|
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
|
-
|
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
|
-
|
54
|
-
|
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
|
-
|
59
|
-
|
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
|
-
|
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
|
-
|
67
|
-
|
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
|
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
|
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-
|
303
|
+
© 2011-2019 Matthias Günther <matze@wikimatze.de>.
|
data/Rakefile
CHANGED
data/lib/sweetie/bitbucket.rb
CHANGED
@@ -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
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
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
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
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
|