opencode_theme 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b31d3bda90a5294781ad0976e613e1d8aad3a86
4
- data.tar.gz: 0c527af5921856b60d29db88cb1a7457fe25f982
3
+ metadata.gz: d32b5b18d920e22d02ba4c850da4ef68853c2daa
4
+ data.tar.gz: f7b12347cfe1ba76d221f1081994ebb96b0eb505
5
5
  SHA512:
6
- metadata.gz: 05dbbb461ccd12335fa79189680c628c79d3b6705062e780d4cee9fc49cf4a951628ee94d662d6d05f0a476ffa78b50bd557ab1627d45873badf8c4b402fe37d
7
- data.tar.gz: 9349963d73f29cbc2e5d90692fe8624b5c613c0cb5a95ec9c8fe11fdd65909be980523b42df4c03f2dd8b90d627cea6ffee318fb4c52e18abe9259d296479b6c
6
+ metadata.gz: fed4316d1379b5c1ca7f25693f50abb607c241ebaee2d968857c3ac76cf85457bc61fbe94e64cf00bed54790edcaa794848ee26d01898509e496d83560bcd6c4
7
+ data.tar.gz: 04606cb545fe61c40b9d2294522f36252e18a268ee87c63740c05532d9ed2fe0138425cb077392520270f1d5b6d47ba4c35e16a2b6e1ed8cdd87e16d4a27f1aa
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
-
3
2
  # Specify your gem's dependencies in opencode_theme.gemspec
4
3
  gemspec
data/README.md CHANGED
@@ -1,68 +1,36 @@
1
- # Opencode Theme
2
- [![RubyGems][gem_version_badge]][ruby_gems]
3
- [![RubyGems][gem_downloads_badge]][ruby_gems]
1
+ # fastBuy
2
+ Compra Rapida (Home)
4
3
 
5
- Opencode Theme Command Line tool for developing themes in [TrayCommerce](https://github.com/tray-tecnologia).
6
- ## Dependencies
4
+ ![example](https://github.com/TaahSene/opencode-components/blob/master/fastBuy/example.gif)
7
5
 
8
- * Ruby v2.1.3 or greater
6
+ Adicione o arquivo [fastBuy.js](https://github.com/TaahSene/opencode-components/blob/master/fastBuy/js/molules/fastBuy.js) a sua pasta `js/modules`, o arquivo [fastBuy.html](https://github.com/TaahSene/opencode-components/blob/master/fastBuy/elements/snippets/fastBuy.html) na pasta `elements/snippets`, e o arquivo [fastBuy.css](https://github.com/TaahSene/opencode-components/blob/master/fastBuy/css/fastBuy.css) na pasta `css`.
9
7
 
10
- ## Installation
8
+ Adicione ao arquivo `default.html` a chamada do script:
11
9
 
12
- Install Opencode Theme from RubyGems with the command:
13
-
14
- ```bash
15
- $ gem install opencode_theme
16
- ```
17
-
18
- or install from source with:
19
-
20
- ```bash
21
- $ git clone https://github.com/tray-tecnologia/opencode_theme
22
- cd opencode_theme
23
- bundle install
24
- bundle exec opencode -h
10
+ ```javascript
11
+ <link rel="stylesheet" href="{{ asset('css/fastBuy.css') }}" type="text/css">
12
+ <script type="text/javascript" src="{{ asset('js/modules/fastBuy.js') }}"></script>
25
13
  ```
26
14
 
27
- ## Usage
15
+ Faça a chamada abaixo, no snippet de produto, onde deseja exibir o campo de quantidade.
28
16
 
29
- Run:
30
-
31
- ```bash
32
- $ opencode configure API_KEY PASSWORD THEME_ID
17
+ ```sh
18
+ {% element 'snippets/fastBuy' {"product": product} %}
33
19
  ```
34
20
 
35
- You can see more in `opencode -h`, and details here: [CLI Commands](http://dev.tray.com.br/hc/pt-br/articles/215996428-Comandos-da-GEM-OpenCode).
36
-
37
- ## Versioning
38
-
39
- Opencode Theme follows the [Semantic Versioning](http://semver.org/) standard.
40
-
41
- ## Issues
42
-
43
- If you have problems, see [ISSUES.md](https://github.com/tray-tecnologia/opencode_theme/blob/master/CONTRIBUTING.md) and please create a [Github Issue](https://github.com/tray-tecnologia/opencode_theme/issues).
44
-
45
- ## Contributing
46
-
47
- Please see [CONTRIBUTING.md](https://github.com/tray-tecnologia/opencode_theme/blob/master/CONTRIBUTING.md) for details.
48
-
49
- ## Release
50
-
51
- Follow this steps to release a new version of the gem:
52
-
53
- 1. Test if everything is running ok;
54
- 2. Change version of the gem on `VERSION` constant;
55
- 3. Add the release date on the `CHANGELOG`;
56
- 4. Do a commit "vX.X.X", follow the semantic version;
57
- 5. Run `$ rake release`, this will send the gem to the RubyGems;
58
- 6. Check if the gem is on the RubyGems and the tags are correct on the github;
59
-
60
- This gem was created and is maintained by [TrayCommerce](https://github.com/tray-tecnologia).
21
+ #### Opções de data-attributes (quantidade)
61
22
 
62
- ![Tray-logo](https://avatars1.githubusercontent.com/u/3370163?v=3&s=220)
23
+ | Opções | Descrição |
24
+ | ------------- |:-------------:|
25
+ | data-app ="product.qty" | Dispara a ação de acrescentar ou decrementar um produto |
26
+ | data-product ="{{ product.id }}" | Deve trazer o id do produto. |
27
+ | id="qtd{{ product.id }}" | O input deverá conter esse id para que o valor seja obtido corretamente.|
28
+ | data-action="minus" | Decrementa 1 produto do Total |
29
+ | data-action="plus"| Acrescenta 1 ao total de produtos|
63
30
 
31
+ #### Opções de data-attributes (botão Comprar)
64
32
 
65
- [tray_commerce]: http://www.tray.com.br
66
- [gem_version_badge]: http://img.shields.io/gem/v/opencode_theme.svg?style=flat
67
- [gem_downloads_badge]: http://img.shields.io/gem/dt/opencode_theme.svg?style=flat
68
- [ruby_gems]: http://rubygems.org/gems/opencode_theme
33
+ | Opções | Descrição |
34
+ | ------------- |:-------------:|
35
+ | data-app="product.buy-button" | Dispara a ação de adicionar ao carrinho |
36
+ | data-product ="{{ product.id }}" | Deve trazer o id do produto. |
@@ -1,9 +1,12 @@
1
1
  require 'httparty'
2
2
 
3
3
  module OpencodeTheme
4
+
4
5
  include HTTParty
5
6
  default_options.update(verify: false)
7
+
6
8
  @@current_api_call_count = 0
9
+
7
10
  URL_API = 'https://opencode.tray.com.br'
8
11
 
9
12
  def self.api_usage
@@ -21,7 +24,8 @@ module OpencodeTheme
21
24
  end
22
25
 
23
26
  def self.list_opencode_components
24
- response = opencode_theme.get('/api/themes/'+config[:theme_id]+'/components', query: { gem_version: OpencodeTheme::VERSION })
27
+ url_target = "/api/themes/#{config[:theme_id]}/components"
28
+ response = opencode_theme.get( url_target, query: { gem_version: OpencodeTheme::VERSION })
25
29
  { success: response.success?, response: parser_json(response.body) }
26
30
  end
27
31
 
@@ -60,7 +64,10 @@ module OpencodeTheme
60
64
  def self.asset_list
61
65
  response = opencode_theme.get(path, parser: NOOPParser, query: { gem_version: OpencodeTheme::VERSION })
62
66
  if response.code == 200
63
- assets = response.code == 200 ? parser_json(response.body)['assets'].map { |a| a['key'][1..a['key'].length] } : response.body
67
+ # assets = response.code == 200 ? parser_json(response.body)['assets'].map { |a| { } } : response.body
68
+ assets = parser_json(response.body)['assets'].map do |file|
69
+ { asset: file['path'][1..file['path'].length], public_url: file['uri'] }
70
+ end
64
71
  assets
65
72
  end
66
73
  end
@@ -137,23 +137,23 @@ module OpencodeTheme
137
137
  total_assets = assets_list.count
138
138
  assets_list
139
139
  else
140
- keys
140
+ [{ asset: keys.first, public_url: nil }]
141
141
  end
142
142
  say("encontrado: #{total_assets} arquivos" , :green)
143
143
  say("o tempo de download depende da quantidade de arquivos, por favor aguarde:" , :green)
144
144
  start_time = Time.now
145
- return report_error(Time.now, 'Não foi possível listar os arquivos', JSON.parse(assets)) if assets.is_a? String
146
- assets = assets.delete_if { |asset| asset =~ Regexp.new(options['exclude']) } if options['exclude']
147
-
148
- assets.to_enum.with_index(1).map do |asset, accumator|
149
- download = download_asset(URI.decode(asset))
150
- return say("Error: #{asset}", :red) unless options['quiet'] unless download
151
- say("[#{total_assets}/#{accumator}] Downloaded: #{asset}", :green) unless options['quiet'] #|| !download
145
+ if assets.count > 1
146
+ assets.to_enum.with_index(1).map do |file, accumator|
147
+ download_asset_uniq(file[:asset], file[:public_url])
148
+ say("[#{total_assets}/#{accumator}] Downloaded: #{file[:asset]}", :green)
149
+ end
150
+ finish_time = Time.now
151
+ elapsed_seconds = ((finish_time.to_f - start_time.to_f)).to_i
152
+ say("tempo total de download: #{elapsed_seconds.to_i}s")
153
+ else
154
+ download_asset_uniq(assets.first[:asset], assets.first[:public_url])
155
+ say("Downloaded: #{assets.first[:asset]}", :green)
152
156
  end
153
-
154
- finish_time = Time.now
155
- elapsed_seconds = ((finish_time.to_f - start_time.to_f)).to_i
156
- say("tempo total de download: #{elapsed_seconds.to_i}s")
157
157
  end
158
158
 
159
159
  desc 'upload FILE', 'Sobe o arquivo informado ou todos se FILE for omitido'
@@ -223,6 +223,7 @@ module OpencodeTheme
223
223
 
224
224
  def show_list_components
225
225
  response = OpencodeTheme.list_opencode_components
226
+
226
227
  say('Nome: Descrição:', :blue)
227
228
  response[:response]['list'].map do |list|
228
229
  say(list["name"] + ' ' + list['description'] , :blue)
@@ -237,12 +238,16 @@ module OpencodeTheme
237
238
  if components[:success]
238
239
  OpencodeTheme.install_opencode_components_notification(name, user, origin)
239
240
  end
241
+
240
242
  files.map do |file|
243
+ next if file[:path].split('/').first.include?('.')
241
244
  if file[:type] == "tree"
242
- FileUtils.mkpath(file[:path])
245
+ FileUtils.mkdir_p(file[:path])
243
246
  else
244
- content = HTTParty.get(file[:url])
245
- IO.write(file[:path], content)
247
+ content = HTTParty.get(file[:url])
248
+ format = 'w+b'
249
+
250
+ File.open(file[:path], format) { |f| f.write content }
246
251
  say("Componente #{name} Downloaded: #{file[:path]}", :green)
247
252
  end
248
253
  end
@@ -297,6 +302,7 @@ module OpencodeTheme
297
302
  else
298
303
  report_error(Time.now, "Nao foi possível fazer upload #{asset}", response)
299
304
  end
305
+
300
306
  end
301
307
 
302
308
  def temp_files?(file_name)
@@ -367,23 +373,35 @@ module OpencodeTheme
367
373
  /^[0-9a-zA-Z\-_.]+\.(ttf|otf|eot|svg|woff|woff2|css|scss|styl|html|js|jpg|gif|png|json|TTF|OTF|EOT|SVG|WOFF|WOFF2|CSS|SCSS|STYL|HTML|JS|PNG|GIF|JPG|JSON)$/ === name
368
374
  end
369
375
 
370
- def download_asset(key)
376
+ def download_asset(key, public_url = nil)
371
377
  return unless valid_name?(key)
372
378
  return unless valid?(key)
379
+ directory = File.dirname(key)
380
+ FileUtils.mkpath(directory)
381
+ if public_url
382
+ content = HTTParty.get(public_url)
383
+ return IO.write(key, content)
384
+ else
385
+ response = OpencodeTheme.get_asset(URI.encode(key))
386
+ content = Base64.decode64(response['content'])
387
+ # content = content.force_encoding('ISO-8859-1')
388
+ return IO.write(key, content)
389
+ end
390
+ end
391
+
392
+ def download_asset_uniq(key, public_url = nil)
393
+ return unless valid_name?(key)
394
+ return unless valid?(key)
395
+ directory = File.dirname(key)
396
+ FileUtils.mkpath(directory)
373
397
  response = OpencodeTheme.get_asset(URI.encode(key))
374
- return report_error(Time.now, "Não foi possível efetuar o download do arquivo: #{key}", response) unless response['key']
375
398
  if response['content']
376
- content = Base64.decode64(response['content'])
377
- content = content.force_encoding('ISO-8859-1')
378
- format = 'w+b:ISO-8859-1'
379
- elsif response['attachment']
380
- content = Base64.decode64(response['attachment'])
381
- format = 'w+b'
399
+ content = Base64.decode64(response['content'])
400
+ return IO.write(key, content)
382
401
  end
383
- FileUtils.mkdir_p(File.dirname(URI.decode(key)))
384
- File.open(key, format) { |f| f.write content }
385
402
  end
386
403
 
404
+
387
405
  def show_during(message = '', quiet = false, &block)
388
406
  print(message) unless quiet
389
407
  result = yield
@@ -1,3 +1,3 @@
1
1
  module OpencodeTheme
2
- VERSION = '1.0.6'.freeze
2
+ VERSION = '1.0.7'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opencode_theme
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rafael Takashi Tanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -256,7 +256,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
256
  version: '0'
257
257
  requirements: []
258
258
  rubyforge_project:
259
- rubygems_version: 2.6.12
259
+ rubygems_version: 2.6.13
260
260
  signing_key:
261
261
  specification_version: 4
262
262
  summary: Provides simple commands to upload and download files from a themes